Ejemplo n.º 1
0
        override public void UnExecute()
        {
            ///处理直线
            HandleUnLine();
            ///处理矩形
            HandleUnRect();

            //刷新区域
            Rectangle invalRect;

            if (MovedLine.IsRow)
            {
                invalRect = Utility.Draw.PointToRectangle(
                    new Point(MovedLine.Start, FirstBorderLine.Position),
                    new Point(MovedLine.End, SecondBorderLine.Position));
            }
            else
            {
                invalRect = Utility.Draw.PointToRectangle(
                    new Point(FirstBorderLine.Position, MovedLine.Start),
                    new Point(SecondBorderLine.Position, MovedLine.End));
            }
            CommonFuns.Invalidate(TDPanel.DrawPanel,
                                  TDPanel.DrawPanel.PenSize,
                                  invalRect,
                                  TDPanel.DrawPanel.CurZoom);
        }
Ejemplo n.º 2
0
        override public void UnExecute()
        {
            foreach (PartitionLine line in DisSelectedLines)
            {
                TDPanel.DrawPanel.ListLine.SelectLine(line);
                TDPanel.DrawPanel.DrawLine(line);
            }
            foreach (PartitionLine line in SelectedLines)
            {
                TDPanel.DrawPanel.ListLine.UnSelectLine(line);

                CommonFuns.Invalidate(TDPanel.DrawPanel,
                                      TDPanel.DrawPanel.PenSize * TDPanel.DrawPanel.BoldPenTimes,
                                      line,
                                      TDPanel.DrawPanel.CurZoom);
            }

            foreach (Rect rect in DisSelectedRects)
            {
                rect.SelectRect();
                CommonFuns.Invalidate(TDPanel.DrawPanel,
                                      TDPanel.DrawPanel.PenSize,
                                      rect,
                                      TDPanel.DrawPanel.CurZoom);
            }
            foreach (Rect rect in SelectedRects)
            {
                rect.UnSelectRect();
                CommonFuns.Invalidate(TDPanel.DrawPanel,
                                      TDPanel.DrawPanel.PenSize,
                                      rect,
                                      TDPanel.DrawPanel.CurZoom);
            }
        }
Ejemplo n.º 3
0
        override public void UnExecute()
        {
            TDPanel.DrawPanel.ListLine.UnDeleteRectLine(this);
            TDPanel.DrawPanel.UnMergeSelectedRects(this);
            CommonFuns.Invalidate(TDPanel.DrawPanel,
                                  TDPanel.DrawPanel.PenSize,
                                  BoundaryRect,
                                  TDPanel.DrawPanel.CurZoom);

            TDPanel.Modified = true;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到矩形的边界线
        /// </summary>
        /// <param name="pt1"></param>
        /// <param name="pt2"></param>
        /// <returns></returns>
        public static PartitionLine[] GetRectBorderLines(Point pt1, Point pt2)
        {
            PartitionLine[] borderLines = new PartitionLine[4];
            Rectangle       rect        = CommonFuns.PointToRectangle(pt1, pt2);

            borderLines[0] = new PartitionLine(rect.X, rect.X + rect.Width, rect.Y, true);
            borderLines[1] = new PartitionLine(rect.X, rect.X + rect.Width, rect.Y + rect.Height, true);
            borderLines[2] = new PartitionLine(rect.Y, rect.Y + rect.Height, rect.X, false);
            borderLines[3] = new PartitionLine(rect.Y, rect.Y + rect.Height, rect.X + rect.Width, false);
            return(borderLines);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 使包含两点的局部矩形重绘
        /// </summary>
        /// <param name="ctl"></param>
        /// <param name="pixel"></param>
        /// <param name="pt1"></param>
        /// <param name="pt2"></param>
        public static void Invalidate(Control ctl, int pixel, Point pt1, Point pt2)
        {
            Rectangle rect = CommonFuns.PointToRectangle(pt1, pt2);

            if (rect.Width == 0)
            {
                rect.Width = 1;
            }
            if (rect.Height == 0)
            {
                rect.Height = 1;
            }
            ctl.Invalidate(new Rectangle(rect.X - pixel, rect.Y - pixel, rect.Width + 4 * pixel, rect.Height + 4 * pixel));
        }
Ejemplo n.º 6
0
        public static void Invalidate(Control ctl, int pixel, Point pt1, Point pt2, float zoom)
        {
            Rectangle rect = CommonFuns.PointToRectangle(pt1, pt2);

            if (rect.Width == 0)
            {
                rect.Width = 1;
            }
            if (rect.Height == 0)
            {
                rect.Height = 1;
            }
            CommonFuns.Invalidate(ctl, pixel, rect, zoom);
        }
Ejemplo n.º 7
0
        override public void UnExecute()
        {
            TDPanel.DrawPanel.ListLine.UnDeleteLine(Start, End, Position, IsRow);
            TDPanel.DrawPanel.DrawLine(new PartitionLine(Start, End, Position, IsRow));

            TDPanel.DrawPanel.ListRect.UnDeleteLine(this);
            foreach (Rect rect in RemovedRects)
            {
                CommonFuns.Invalidate(TDPanel.DrawPanel,
                                      TDPanel.DrawPanel.PenSize,
                                      rect,
                                      TDPanel.DrawPanel.CurZoom);
            }
        }
Ejemplo n.º 8
0
 override public void UnExecute()
 {
     foreach (Rect rect in UnLockedRects)
     {
         rect.LockRect();
         CommonFuns.Invalidate(TDPanel.DrawPanel,
                               TDPanel.DrawPanel.PenSize,
                               rect,
                               TDPanel.DrawPanel.CurZoom);
     }
     foreach (PartitionLine line in UnLockedLines)
     {
         line.LockLine();
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// 是否可以合并被选择的矩形
        /// </summary>
        /// <returns></returns>
        public bool IsRectMergable()
        {
            List <Rect> selectedRects = GetSelectedRects();
            Rectangle   rectangle     = CommonFuns.FindRectsBorder(selectedRects);
            int         rectSquare    = 0;

            ///求面积之和
            foreach (Rect rect in selectedRects)
            {
                rectSquare += rect.Width * rect.Height;
            }

            return(GetSelectedRects().Count >= 2 &&
                   (GetDisMergableRects().Count < 1) &&
                   rectSquare == rectangle.Width * rectangle.Height);
        }
Ejemplo n.º 10
0
        public MergeRectCommand(DesignPanel tdPanel)
        {
            TDPanel = tdPanel;

            List <Rect> selectedRects = tdPanel.DrawPanel.ListRect.GetSelectedRects();
            Rectangle   boundaryRect  = CommonFuns.FindRectsBorder(selectedRects);

            ///保存边界矩形
            BoundaryRect = new Rectangle(
                boundaryRect.X,
                boundaryRect.Y,
                boundaryRect.Width,
                boundaryRect.Height
                );

            CommandInfo = "合并矩形";
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 实现执行函数
        /// </summary>
        override public void Execute()
        {
            TDPanel.DrawPanel.ListLine.DeleteLine(Start, End, Position, IsRow);
            CommonFuns.Invalidate(TDPanel.DrawPanel,
                                  TDPanel.DrawPanel.PenSize * TDPanel.DrawPanel.BoldPenTimes,
                                  new PartitionLine(Start, End, Position, IsRow),
                                  TDPanel.DrawPanel.CurZoom);
            TDPanel.DrawPanel.ListRect.DeleteLine(this);

            foreach (Rect rect in AddedRects)
            {
                CommonFuns.Invalidate(TDPanel.DrawPanel,
                                      TDPanel.DrawPanel.PenSize,
                                      rect,
                                      TDPanel.DrawPanel.CurZoom);
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 实现执行函数
        /// </summary>
        override public void Execute()
        {
            foreach (PartitionLine line in AddedLines)
            {
                TDPanel.DrawPanel.ListLine.AddLine(line.Start, line.End, line.Position, line.IsRow);
                TDPanel.DrawPanel.DrawLine(line);
            }

            TDPanel.DrawPanel.ListRect.AddLine(this);
            foreach (Rect rect in RemovedRects)
            {
                CommonFuns.Invalidate(TDPanel.DrawPanel,
                                      TDPanel.DrawPanel.PenSize,
                                      rect,
                                      TDPanel.DrawPanel.CurZoom);
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 返回没有被选择之矩形的最大边界中未被选择之矩形和选定却被锁定之矩形
        /// </summary>
        /// <returns></returns>
        public List <Rect> GetDisMergableRects()
        {
            List <Rect>    selectedRects = GetSelectedRects();
            Rectangle      rectangle     = CommonFuns.FindRectsBorder(selectedRects);
            FindRectByRect findRect      = new FindRectByRect(rectangle);
            List <Rect>    totalRects    = this.SnipRectList.FindAll(findRect.FindInRectPredicate);

            List <Rect> dismergableRects = CommonFuns.RemainRectList(totalRects, selectedRects);;

            foreach (Rect rect in selectedRects)
            {
                if (rect.IsLocked)
                {
                    dismergableRects.Add(rect);
                }
            }
            return(dismergableRects);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 绘画像素标尺指示线(用于替代Invaliate,减少刷新,减少标尺闪动)
        /// </summary>
        /// <param name="g"></param>
        private void DrawRulerPixelLine(Graphics g)
        {
            if (CurZoom == 1)
            {
                float offset = Height;
                int   pos    = (int)StartPos + CurPos;
                if (CurPos % 50 == 0)
                {
                    offset = 0;
                    g.DrawLine(Pens.Black, offset, pos, Width, pos);
                }
                else if (CurPos % 25 == 0)
                {
                    offset = (Width * 3) / 5;
                    g.DrawLine(Pens.Black, offset, pos, Width, pos);
                }
                else if (CurPos % 5 == 0)
                {
                    offset = (Width * 3) / 4;
                    g.DrawLine(Pens.Black, offset, pos, Width, pos);
                }

                if (CurPos % 50 < 25)
                {
                    int    intPos = (CurPos / 50) * 50;
                    string str    = intPos.ToString();
                    offset = 0;
                    int i = 0;
                    foreach (char ch in str)
                    {
                        g.DrawString(ch.ToString(),
                                     new Font("Tahoma", 7),
                                     new SolidBrush(Color.Black),
                                     0,
                                     intPos + (int)StartPos + i * 8);
                        i++;
                    }
                }
            }
            else
            {
                CommonFuns.Invalidate(this, 0, 0, (int)StartPos + CurPos, Width - 1, 1);
            }
        }
Ejemplo n.º 15
0
 /// <summary>
 /// 实现执行函数,在执行命令前已经把_removedRects和_addedRects、_inRectLines初始化。
 /// </summary>
 override public void Execute()
 {
     foreach (Rect rect in AddedRects)
     {
         rect.IsDeleted = false;
     }
     foreach (PartitionLine line in AddedLines)
     {
         TDPanel.DrawPanel.ListLine.AddLine(line.Start, line.End, line.Position, line.IsRow);
     }
     foreach (Rect rect in RemovedRects)
     {
         rect.IsDeleted = true;
         CommonFuns.Invalidate(TDPanel.DrawPanel,
                               TDPanel.DrawPanel.PenSize,
                               rect,
                               TDPanel.DrawPanel.CurZoom);
     }
 }
Ejemplo n.º 16
0
        /// <summary>
        /// 实现执行函数
        /// </summary>
        override public void Execute()
        {
            if (!TDPanel.DrawPanel.MergeSelectedRects(this))
            {
                return;
            }
            TDPanel.DrawPanel.ListLine.DeleteRectLine(this);

            if (!IsRedo)
            {
                IsRedo = true;
            }
            CommonFuns.Invalidate(TDPanel.DrawPanel,
                                  TDPanel.DrawPanel.PenSize,
                                  BoundaryRect,
                                  TDPanel.DrawPanel.CurZoom);

            TDPanel.Modified = true;
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 绘画像素标尺指示线(用于替代Invaliate,减少刷新,减少标尺闪动)
        /// </summary>
        /// <param name="g"></param>
        private void DrawRulerPixelLine(Graphics g)
        {
            if (CurZoom == 1)
            {
                float offset = Height;
                int   pos    = (int)StartPos + CurPos;
                if (CurPos % 50 == 0)
                {
                    offset = 0;
                    g.DrawLine(Pens.Black, pos, offset, pos, Height);
                }
                else if (CurPos % 25 == 0)
                {
                    offset = (Height * 3) / 5;
                    g.DrawLine(Pens.Black, pos, offset, pos, Height);
                }
                else if (CurPos % 5 == 0)
                {
                    offset = (Height * 3) / 4;
                    g.DrawLine(Pens.Black, pos, offset, pos, Height);
                }

                if (CurPos % 50 < 20)
                {
                    int intpos = (CurPos / 50) * 50;
                    offset = 0;
                    g.DrawString(intpos.ToString(),
                                 new Font("Tahoma", 7),
                                 new SolidBrush(Color.Black),
                                 intpos + +(int)StartPos,
                                 0);
                }
            }
            else
            {
                CommonFuns.Invalidate(this, 0, (int)StartPos + CurPos, 0, 1, Height - 1);
            }
        }
Ejemplo n.º 18
0
 /// <summary>
 /// 绘画标尺指示线:百分比的标尺先用刷新来实现,不过用的是局部刷新
 /// </summary>
 /// <param name="g"></param>
 private void DrawRulerPercentLine(Graphics g)
 {
     CommonFuns.Invalidate(this, 0, (int)StartPos + CurPos, 0, 1, Height - 1);
 }