引用:
using CADImport;
using CADImportForm;
using HPGL2;
using RasterImage;
using ObjectsSelection;
using CADImportFaceModule;
存儲圖形元素
private ArrayList TextFile = new ArrayList();
#region 文本查找
private void ReadAll(string aFileName)
{
if (FCADImage == null) return;
TextFile.Clear();
CADParams = new CADIterate();
CADParams.matrix = new CADMatrix();
CADParams.matrix.data[0, 0] = 1;
CADParams.matrix.data[1, 1] = 1;
CADParams.matrix.data[2, 2] = 1;
FCADImage.Converter.AutoInsert = true; // to get all the elements inside of inserts
FCADImage.Converter.Iterate(new CADEntityProc(ReadCADEntities), CADParams);
}
private void ReadCADEntities(CADEntity Entity)
{
if (Entity is CADText)
{
CADText Sender = (CADText)Entity;
DPoint P;
CADConst.DoScale2D(ref CADParams);
if (Sender.Text == FineText)
{
DPoint tmp_dp = Sender.StartPoint;
tmp_dp.Y += Sender.Height * 1.3; //for not shx
P = CADParams.matrix.PtXMat(tmp_dp);
FineTextPoint.X = float.Parse(P.X.ToString());
FineTextPoint.Y = float.Parse(P.Y.ToString());
}
}
}
private void CADMove(Point proPoint)
{
det1 = true;
if (FCADImage == null) return;
if (det1)
{
if (proPoint.X > cadPictBox.Width / 2)
{
pos.X -= (proPoint.X - cadPictBox.Width / 2);
}
else
{
pos.X += (cadPictBox.Width / 2 - proPoint.X);
}
if (proPoint.Y > cadPictBox.Height / 2)
{
pos.Y -= (proPoint.Y - cadPictBox.Height / 2);
}
else
{
if (cadPictBox.Height / 2 != proPoint.Y)
{
pos.Y += (cadPictBox.Height / 2 - proPoint.Y);
}
}
cadPictBox.Invalidate();
}
det1 = false;
}
#endregion
private void button5_Click(object sender, EventArgs e)
{
if (FCADImage == null) return;
FineText = textBox1.Text.Trim();
ReadAll(FileName);
if (FineTextPoint.X != 0 || FineTextPoint.Y != 0)
{
DPoint d_Pos = SetRealPointUsingsgImagePoint(FineTextPoint.X, FineTextPoint.Y);
Point ProPoint = new Point(Convert.ToInt32(d_Pos.X), Convert.ToInt32(d_Pos.Y));
CADMove(ProPoint);
}
}