示例#1
0
文件: Shape.cs 项目: Dr1N/PaintNET
 public void Editing(MainForm.EDITMODE mode, Point BP, Point EP, Point CurrentPosition)
 {
     switch (mode)
     {
         case MainForm.EDITMODE.NONE:
             break;
         case MainForm.EDITMODE.NW:
             {
                 int deltaX = CurrentPosition.X - BP.X;
                 int deltaY = CurrentPosition.Y - BP.Y;
                 this.BeginPoint = new Point(BP.X + deltaX, BP.Y + deltaY);
             }
             break;
         case MainForm.EDITMODE.N:
             {
                 int deltaY = CurrentPosition.Y - BP.Y;
                 this.BeginPoint = new Point(BP.X, BP.Y + deltaY);
             }
             break;
         case MainForm.EDITMODE.NE:
             {
                 int deltaX = CurrentPosition.X - EP.X;
                 int deltaY = CurrentPosition.Y - BP.Y;
                 this.BeginPoint = new Point(BP.X, BP.Y + deltaY);
                 this.EndPoint = new Point(EP.X + deltaX, EP.Y);
             }
             break;
         case MainForm.EDITMODE.W:
             {
                 int deltaX = CurrentPosition.X - BP.X;
                 this.BeginPoint = new Point(BP.X + deltaX, BP.Y);
             }
             break;
         case MainForm.EDITMODE.MOVE:
             {
                 int deltaX = CurrentPosition.X - (EP.X + BP.X) / 2;
                 int deltaY = CurrentPosition.Y - (EP.Y + BP.Y) / 2;
                 this.BeginPoint = new Point(BP.X + deltaX, BP.Y + deltaY);
                 this.EndPoint = new Point(EP.X + deltaX, EP.Y + deltaY);
             }
             break;
         case MainForm.EDITMODE.E:
             {
                 int deltaX = CurrentPosition.X - EP.X;
                 this.EndPoint = new Point(EP.X + deltaX, EP.Y);
             }
             break;
         case MainForm.EDITMODE.SW:
             {
                 int deltaX = CurrentPosition.X - BP.X;
                 int deltaY = CurrentPosition.Y - EP.Y;
                 this.BeginPoint = new Point(BP.X + deltaX, BP.Y);
                 this.EndPoint = new Point(EP.X, EP.Y + deltaY);
             }
             break;
         case MainForm.EDITMODE.S:
             {
                 int deltaY = CurrentPosition.Y - EP.Y;
                 this.EndPoint = new Point(EP.X, EP.Y + deltaY);
             }
             break;
         case MainForm.EDITMODE.SE:
             {
                 int deltaX = CurrentPosition.X - EP.X;
                 int deltaY = CurrentPosition.Y - EP.Y;
                 this.EndPoint = new Point(EP.X + deltaX, EP.Y + deltaY);
             }
             break;
         default:
             break;
     }
 }
示例#2
0
文件: Shape.cs 项目: Dr1N/PaintNET
        public void Editing(MainForm.EDITMODE mode, Point CenterPoint, Point CurrentPosition)
        {
            switch (mode)
            {
                case MainForm.EDITMODE.MOVE:
                    int deltaX = CurrentPosition.X - CenterPoint.X;
                    int deltaY = CurrentPosition.Y - CenterPoint.Y;

                    //Пересчёт точек

                    for (int i = 0; i < this.points.Count; i++)
                    {
                        this.points[i] = new Point(this.points[i].X + deltaX, this.points[i].Y + deltaY);
                    }
                    break;
                default:
                    break;
            }
        }