Revit.SDK.Samples.CurtainWallGrid.CS.GridDrawing.AddDashLine C# (CSharp) Méthode

AddDashLine() public méthode

add the dash U/V line (used only in "Move grid line" operation)
public AddDashLine ( System mousePosition ) : void
mousePosition System /// the location of the mouse cursor ///
Résultat void
        public void AddDashLine(System.Drawing.Point mousePosition)
        {
            bool mouseInGrid = VerifyMouseLocation(mousePosition);

             // mouse is outside the curtain grid boundary
             if (false == mouseInGrid)
             {
            return;
             }

             double offset = 0.0;

             // the selected grid line is a U grid line (it's the grid line to be moved)
             if (-1 != m_selectedUIndex)
             {
            bool succeeded = AddDashULine(mousePosition);
            // add failed (for example, the mouse locates on another grid line)
            if (false == succeeded)
            {
               return;
            }

            // add the selected grid line (the line to be moved) to the assistant line list
            // (it will be painted in bold and with red color)
            GridLine2D line = m_uGridLines2D[m_selectedUIndex];
            Pen redPen = new Pen(System.Drawing.Color.Red, m_selectedLinePenWidth);
            m_drawObject.Lines2D.Add(new KeyValuePair<Line2D, Pen>(line, redPen));
            m_geometry.MoveOffset = mousePosition.Y - line.StartPoint.Y;

            // convert the 2D data to 3D
            Autodesk.Revit.DB.XYZ xyz = new Autodesk.Revit.DB.XYZ(mousePosition.X, mousePosition.Y, 0);
            Vector4 vec = new Vector4(xyz);
            vec = m_coordinates.RestoreMatrix.Transform(vec);
            offset = vec.Z - m_geometry.LineToBeMoved.FullCurve.get_EndPoint(0).Z;
            offset = Unit.CovertFromAPI(m_myDocument.LengthUnitType, offset);

            // showing the move offset
            m_drawObject.Text = "Offset: " + Math.Round(offset, 1) +
                Properties.Resources.ResourceManager.GetString(m_myDocument.LengthUnitType.ToString());
            m_drawObject.TextPosition = mousePosition;
            m_drawObject.TextPen = redPen;
            return;
             }
             // the selected grid line is a V grid line (it's the grid line to be moved)
             else if (-1 != m_selectedVIndex)
             {
            bool succeeded = AddDashVLine(mousePosition);
            // add failed (for example, the mouse locates on another grid line)
            if (false == succeeded)
            {
               return;
            }

            // add the selected grid line (the line to be moved) to the assistant line list
            // (it will be painted in bold and with red color)
            GridLine2D line = m_vGridLines2D[m_selectedVIndex];
            Pen redPen = new Pen(System.Drawing.Color.Red, m_selectedLinePenWidth);
            m_drawObject.Lines2D.Add(new KeyValuePair<Line2D, Pen>(line, redPen));
            m_geometry.MoveOffset = mousePosition.X - line.StartPoint.X;
            // convert the 2D data to 3D
            Autodesk.Revit.DB.XYZ xyz = new Autodesk.Revit.DB.XYZ(mousePosition.X, mousePosition.Y, 0);
            Vector4 vec = new Vector4(xyz);
            vec = m_coordinates.RestoreMatrix.Transform(vec);
            offset = vec.X - m_geometry.LineToBeMoved.FullCurve.get_EndPoint(0).X;
            offset = Unit.CovertFromAPI(m_myDocument.LengthUnitType, offset);

            // showing the move offset
            m_drawObject.Text = "Offset: " + Math.Round(offset, 1) +
                Properties.Resources.ResourceManager.GetString(m_myDocument.LengthUnitType.ToString());
            m_drawObject.TextPosition = mousePosition;
            m_drawObject.TextPen = redPen;
             }
        }