示例#1
0
            /// 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);
                }
            }
示例#2
0
        public static void LineAndLineString(string unparsed)
        {
            Bentley.Interop.MicroStationDGN.Application app = Bentley.MicroStation.InteropServices.Utilities.ComApp;
            Point3d startPnt = app.Point3dZero();
            Point3d endPnt   = startPnt;

            startPnt.X = 10;
            LineElement oLine = app.CreateLineElement2(null, ref startPnt, ref endPnt);

            oLine.Color      = 0;
            oLine.LineWeight = 2;
            app.ActiveModelReference.AddElement(oLine);
            Point3d[] pntArray = new Point3d[5];
            pntArray[0]      = app.Point3dZero();
            pntArray[1]      = app.Point3dFromXY(1, 2);
            pntArray[2]      = app.Point3dFromXY(3, -2);
            pntArray[3]      = app.Point3dFromXY(5, 2);
            pntArray[4]      = app.Point3dFromXY(6, 0);
            oLine            = app.CreateLineElement1(null, ref pntArray);
            oLine.Color      = 1;
            oLine.LineWeight = 2;
            app.ActiveModelReference.AddElement(oLine);
        }