/// Called by the state machine for each mouse move event. /// point: Current cursor location. /// view: Cursor is in this view. /// drawMode: Draw mode supplied by the drawing engine. public void Dynamics(ref Point3d Point, BCOM.View View, MsdDrawingMode DrawMode) { if (m_nPoints != 1) { return; } string[] txtStr = new string[2]; Point3d[] txtPts = new Point3d[2]; Element[] elems = new Element[3]; m_atPoints[1] = Point; txtStr[0] = (myForm.rbEN.Checked ? "E=" : "X=") + m_atPoints[0].X.ToString("F2"); txtStr[1] = (myForm.rbEN.Checked ? "N=" : "Y=") + m_atPoints[0].Y.ToString("F2"); double txtLen = app.ActiveSettings.TextStyle.Width * Math.Max(txtStr[0].Length, txtStr[1].Length); double txtLineSpacing = app.ActiveSettings.TextStyle.Height; if (myForm.rbHorizontal.Checked) { m_atPoints[2].X = m_atPoints[1].X + (m_atPoints[0].X > m_atPoints[1].X ? -txtLen : txtLen) * 1.2; m_atPoints[2].Y = m_atPoints[1].Y; txtPts[0].X = (m_atPoints[1].X + m_atPoints[2].X) / 2; txtPts[0].Y = m_atPoints[1].Y + txtLineSpacing; txtPts[1].X = txtPts[0].X; txtPts[1].Y = m_atPoints[1].Y - txtLineSpacing; } else { m_atPoints[2].X = m_atPoints[1].X; m_atPoints[2].Y = m_atPoints[1].Y + (m_atPoints[0].Y > m_atPoints[1].Y ? -txtLen : txtLen) * 1.2; txtPts[0].X = m_atPoints[1].X - txtLineSpacing; txtPts[0].Y = (m_atPoints[1].Y + m_atPoints[2].Y) / 2; txtPts[1].X = m_atPoints[1].X + txtLineSpacing; txtPts[1].Y = txtPts[0].Y; } elems[0] = app.CreateLineElement1(null, ref m_atPoints); elems[0].LineStyle = app.ActiveDesignFile.LineStyles.Find("0", null); Matrix3d rMatrix = app.Matrix3dIdentity(); for (int i = 1; i < 3; i++) { elems[i] = app.CreateTextElement1(null, txtStr[i - 1], ref txtPts[i - 1], ref rMatrix); elems[i].AsTextElement().TextStyle.Font = app.ActiveDesignFile.Fonts.Find(MsdFontType.MicroStation, "ENGINEERING", null); elems[i].AsTextElement().TextStyle.Justification = MsdTextJustification.CenterCenter; if (myForm.rbVertical.Checked) { elems[i].RotateAboutZ(ref txtPts[i - 1], Math.PI / 2); } } CellElement elemCell = app.CreateCellElement1("NoteCoordCell", ref elems, ref m_atPoints[0], false); elemCell.Redraw(DrawMode); if (MsdDrawingMode.Normal == DrawMode) { app.ActiveModelReference.AddElement(elemCell); } }
public void Dynamics(ref Point3d Point, View View, MsdDrawingMode DrawMode) { if (!ready) { Element label = create_rebar_label(content); Range3d label_range = label.Range; Point3d down_left = label_range.Low, up_right = label_range.High; double line_length = up_right.Y - down_left.Y; Element line = create_line(line_length); label.Move(ref Point); line.Move(ref Point); List <Element> list = new List <Element>(); list.Add(label); list.Add(line); CellElement cell = app.CreateCellElement1("标签", list.ToArray(), Point); cell.Redraw(DrawMode); } else { if (current_point.X != Point.X) { Point.X = current_point.X; } Element guide_line = create_line(current_point, Point); Element label = create_rebar_label(content); Range3d label_range = label.Range; Point3d down_left = label_range.Low, up_right = label_range.High; double line_length = up_right.Y - down_left.Y; Element line = create_line(line_length); if (current_point.Y < Point.Y) { Point.Y = Point.Y + line_length; } label.Move(Point); line.Move(Point); List <Element> list = new List <Element>(); list.Add(label); list.Add(line); list.Add(guide_line); CellElement cell = app.CreateCellElement1("标签1", list.ToArray(), Point); cell.Redraw(DrawMode); } }