the class is designed to help draw the hints and the assistant lines of the curtain grid
Пример #1
0
        /// <summary>
        /// pick up a U grid line by mouse
        /// </summary>
        /// <param name="mousePosition">
        /// the location of the mouse cursor
        /// </param>
        /// <param name="verifyLock">
        /// will locked grid lines be picked (if verifyLock is true, won't pick up locked ones)
        /// </param>
        /// <param name="verifyRemove">
        /// whether grid line without skipped segments be picked (if verifyRemove is true, won't pick up the grid line without skipped segments)
        /// </param>
        public void SelectULine(System.Drawing.Point mousePosition, bool verifyLock, bool verifyRemove)
        {
            for (int i = 0; i < m_uLinePathList.Count; i++)
             {
            GraphicsPath path = m_uLinePathList[i];
            GridLine2D line2D = m_uGridLines2D[i];
            // the verifyLock is true (won't pick up locked ones) and the current pointed grid line is locked
            // so can't select it
            if (true == verifyLock &&
                true == line2D.Locked)
            {
               continue;
            }

            // the verifyRemove is true (only pick up the grid line with skipped segments) and the current pointed grid line
            // has no skipped segments
            if (true == verifyRemove && line2D.RemovedNumber == 0)
            {
               continue;
            }

            Pen redPen = new Pen(System.Drawing.Color.Red, m_outlineSelectPenWidth);

            // the mouse is in the outline of the graphics path
            if (path.IsOutlineVisible(mousePosition, redPen))
            {
               m_selectedUIndex = i;
               m_drawObject = new DrawObject(line2D, new Pen(System.Drawing.Color.Red, m_selectedLinePenWidth));
               // show the lock status of the grid line
               if (false == verifyLock && false == verifyRemove)
               {
                  m_drawObject.Text = (true == line2D.Locked) ? "Locked" : "Unlocked";
                  m_drawObject.TextPosition = mousePosition;
                  m_drawObject.TextPen = redPen;
               }
               return;
            }
             }

             m_drawObject.Clear();
             m_selectedUIndex = -1;
        }
Пример #2
0
        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="geometry">
        /// the referred parent geometry of the curtain grid
        /// </param>
        public GridDrawing(MyDocument myDoc, GridGeometry geometry)
        {
            m_myDocument = myDoc;

             if (null == geometry)
             {
            MessageBox.Show("Error! There's no grid information in the curtain wall.");
             }
             else
             {
            m_geometry = geometry;
            m_coordinates = new GridCoordinates(myDoc, this);
            m_uGridLines2D = new List<GridLine2D>();
            m_vGridLines2D = new List<GridLine2D>();
            m_boundLines2D = new List<GridLine2D>();
            m_uLinePathList = new List<GraphicsPath>();
            m_uSegLinePathListList = new List<List<GraphicsPath>>();
            m_vSegLinePathListList = new List<List<GraphicsPath>>();
            m_vLinePathList = new List<GraphicsPath>();
            m_boundPath = new List<GraphicsPath>();
            m_drawObject = new DrawObject();
             }
        }
Пример #3
0
        /// <summary>
        /// show the candicate new V grid line to be added. In "add vertical grid line" operation,
        /// there'll be a dash line following the movement of the mouse, it's drawn by this method
        /// </summary>
        /// <param name="mousePosition">
        /// the location of the mouse cursor
        /// </param>
        /// <returns>
        /// if added successfully, return true; otherwise false (if the mouse location is invalid, it will return false)
        /// </returns>
        public bool AddDashVLine(System.Drawing.Point mousePosition)
        {
            bool mouseInGrid = VerifyMouseLocation(mousePosition);

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

             // if the mouse laps over another grid line, it's invalid
             bool isOverlapped = IsOverlapped(mousePosition, m_vLinePathList);
             if (true == isOverlapped)
             {
            m_mouseLocationValid = false;
            string msg = "It's not allowed to add grid line lapping over another grid line";
            m_myDocument.Message = new KeyValuePair<string, bool>(msg, true);
            return false;
             }
             // there's no "overlap", it's valid
             else
             {
            string msg = "Specify a point within the curtain grid to locate the grid line";
            m_myDocument.Message = new KeyValuePair<string, bool>(msg, false);
             }

             m_mouseLocationValid = true;
             // get a parallel V line first
             GridLine2D vLine2D;
             // for "Curtain Wall: Curtain Wall 1", there's no initial U/V grid lines, so we use the boundary
             // line instead (the same result)
             if (null == m_vGridLines2D || 0 == m_vGridLines2D.Count)
             {
            vLine2D = m_boundLines2D[1];
             }
             else
             {
            vLine2D = m_vGridLines2D[0];
             }
             System.Drawing.Point startPoint = vLine2D.StartPoint;
             System.Drawing.Point endPoint = vLine2D.EndPoint;

             // move the start point and the end point parallelly
             startPoint.X = mousePosition.X;
             endPoint.X = mousePosition.X;
             // get the dash u line
             GridLine2D dashVLine = new GridLine2D(startPoint, endPoint);

             // initialize the pan
             Pen redPen = new Pen(System.Drawing.Color.Red, m_sketchPenWidth);
             Brush brush = Brushes.Red;
             redPen.DashCap = DashCap.Flat;
             redPen.DashStyle = DashStyle.Dash;

             // add the dash line to the assistant line list for drawing
             m_drawObject = new DrawObject(dashVLine, redPen);
             return true;
        }
Пример #4
0
        /// <summary>
        /// pick up a segment of a V grid line
        /// </summary>
        /// <param name="mousePosition">
        /// the location of the mouse cursor
        /// </param>
        public void SelectVSegment(System.Drawing.Point mousePosition)
        {
            for (int i = 0; i < m_vSegLinePathListList.Count; i++)
             {
            GridLine2D gridLine2D = m_vGridLines2D[i];
            List<GraphicsPath> pathList = m_vSegLinePathListList[i];
            Pen redPen = new Pen(System.Drawing.Color.Red, m_outlineSelectPenWidth);

            // find out which segment it's on and which grid line does the segment belong to
            for (int j = 0; j < pathList.Count; j++)
            {
               SegmentLine2D segLine2D = m_vGridLines2D[i].Segments[j];
               GraphicsPath path = pathList[j];

               if (path.IsOutlineVisible(mousePosition, redPen))
               {
                  if (LineOperationType.AddSegment == m_myDocument.ActiveOperation.OpType)
                  {
                     // the operation is add segment, but the selected segment hasn't been removed
                     // so skip this segment
                     if (false == segLine2D.Removed)
                     {
                        string msg = "It's only allowed to add segment on a removed segment";
                        KeyValuePair<string, bool> statusMsg = new KeyValuePair<string, bool>(msg, true);
                        m_myDocument.Message = statusMsg;
                        return;
                     }
                  }
                  else if (LineOperationType.RemoveSegment == m_myDocument.ActiveOperation.OpType)
                  {
                     // the operation is remove segment, but the selected segment has been removed
                     // so skip this segment
                     if (true == segLine2D.Removed)
                     {
                        return;
                     }
                     // if there's only segment existing, forbid to delete it
                     if (gridLine2D.RemovedNumber == gridLine2D.Segments.Count - 1)
                     {
                        string msg = "It's not allowed to delete the last segment";
                        KeyValuePair<string, bool> statusMsg = new KeyValuePair<string, bool>(msg, true);
                        m_myDocument.Message = statusMsg;
                        return;
                     }
                  }

                  m_selectedVIndex = i;
                  m_selectedVSegmentIndex = j;
                  m_drawObject = new DrawObject(segLine2D, new Pen(System.Drawing.Color.Red, m_selectedSegmentPenWidth));

                  // update the status strip hint
                  {
                     string msg = "Left-click to finish the operation";
                     KeyValuePair<string, bool> statusMsg = new KeyValuePair<string, bool>(msg, false);
                     m_myDocument.Message = statusMsg;
                  }
                  return;
               }
            }
             }

             m_drawObject.Clear();
             // selection failed
             m_selectedVIndex = -1;
             m_selectedVSegmentIndex = -1;
             // update the status hint
             {
            string msg = "Select a segment";
            KeyValuePair<string, bool> statusMsg = new KeyValuePair<string, bool>(msg, false);
            m_myDocument.Message = statusMsg;
             }
        }