예제 #1
0
 private void MoveRefAnchorPoint(double preX, double preY, double x, double y, AnchorPoint movedAnchorPoint)
 {
     foreach (AnchorPoint anchorPoint in anchorPoints)
     {
         if (anchorPoint.RefPoint.Length == 2)
         {
             Point[] refPoints = anchorPoint.RefPoint;
             if (refPoints[0].X == preX && refPoints[0].Y == preY &&
                 refPoints[1].X == curAnchorPoint.X && refPoints[1].Y == curAnchorPoint.Y)
             {
                 anchorPoint.RefPoint[0].X = movedAnchorPoint.X;
                 anchorPoint.RefPoint[0].Y = movedAnchorPoint.Y;
                 anchorPoint.RefPoint[1].X = x;
                 anchorPoint.RefPoint[1].Y = y;
             }
             if (refPoints[1].X == preX && refPoints[1].Y == preY &&
                 refPoints[0].X == curAnchorPoint.X && refPoints[0].Y == curAnchorPoint.Y)
             {
                 anchorPoint.RefPoint[1].X = movedAnchorPoint.X;
                 anchorPoint.RefPoint[1].Y = movedAnchorPoint.Y;
                 anchorPoint.RefPoint[0].X = x;
                 anchorPoint.RefPoint[0].Y = y;
             }
             anchorPoint.X = (anchorPoint.RefPoint[0].X + anchorPoint.RefPoint[1].X) / 2;
             anchorPoint.Y = (anchorPoint.RefPoint[0].Y + anchorPoint.RefPoint[1].Y) / 2;
             anchorPoint.Move();
         }
     }
 }
예제 #2
0
        /// <summary>
        /// 移动单个点
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="anchorPoint"></param>
        private void MoveAnchorPoint(double x, double y, AnchorPoint anchorPoint)
        {
            double preX = anchorPoint.X;
            double preY = anchorPoint.Y;

            if (curAnchorPoint.AnchorPointType == AnchorPointType.NS)
            {
                anchorPoint.Move(anchorPoint.X, y);
                MoveRefAnchorPoint(preX, preY, anchorPoint);
            }
            else if (curAnchorPoint.AnchorPointType == AnchorPointType.WE)
            {
                anchorPoint.Move(x, anchorPoint.Y);
                MoveRefAnchorPoint(preX, preY, anchorPoint);
            }
            else
            {
                if (anchorPoint.AnchorPointType == AnchorPointType.NS)
                {
                    anchorPoint.Move(anchorPoint.X, y);
                    MoveRefAnchorPoint(preX, preY, anchorPoint);
                }
                else if (anchorPoint.AnchorPointType == AnchorPointType.WE)
                {
                    anchorPoint.Move(x, anchorPoint.Y);
                    MoveRefAnchorPoint(preX, preY, anchorPoint);
                }
                else if (curAnchorPoint.AnchorPointType == AnchorPointType.NE)
                {
                    if (anchorPoint.AnchorPointType == AnchorPointType.SE)
                    {
                        anchorPoint.Move(anchorPoint.X, y);
                    }
                    else if (anchorPoint.AnchorPointType == AnchorPointType.NW)
                    {
                        anchorPoint.Move(x, anchorPoint.Y);
                    }

                    MoveRefAnchorPoint(preX, preY, x, y, anchorPoint);
                    MoveRefAnchorPoint(preX, preY, anchorPoint);
                }
                else if (curAnchorPoint.AnchorPointType == AnchorPointType.SW)
                {
                    if (anchorPoint.AnchorPointType == AnchorPointType.SE)
                    {
                        anchorPoint.Move(x, anchorPoint.Y);
                    }
                    else if (anchorPoint.AnchorPointType == AnchorPointType.NW)
                    {
                        anchorPoint.Move(anchorPoint.X, y);
                    }

                    MoveRefAnchorPoint(preX, preY, x, y, anchorPoint);
                    MoveRefAnchorPoint(preX, preY, anchorPoint);
                }
                else if (curAnchorPoint.AnchorPointType == AnchorPointType.SE)
                {
                    if (anchorPoint.AnchorPointType == AnchorPointType.SW)
                    {
                        anchorPoint.Move(x, anchorPoint.Y);
                    }
                    else if (anchorPoint.AnchorPointType == AnchorPointType.NE)
                    {
                        anchorPoint.Move(anchorPoint.X, y);
                    }

                    MoveRefAnchorPoint(preX, preY, x, y, anchorPoint);
                    MoveRefAnchorPoint(preX, preY, anchorPoint);
                }
                else if (curAnchorPoint.AnchorPointType == AnchorPointType.NW)
                {
                    if (anchorPoint.AnchorPointType == AnchorPointType.SW)
                    {
                        anchorPoint.Move(anchorPoint.X, y);
                    }
                    else if (anchorPoint.AnchorPointType == AnchorPointType.NE)
                    {
                        anchorPoint.Move(x, anchorPoint.Y);
                    }

                    MoveRefAnchorPoint(preX, preY, x, y, anchorPoint);
                    MoveRefAnchorPoint(preX, preY, anchorPoint);
                }
            }
        }
예제 #3
0
 void rec_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     Rectangle rec = (Rectangle)sender;
     AnchorPoint anchorPoint = anchorPoints.Where(o => o.Key == rec.DataContext.ToString()).Single();
     Mouse.SetCursor(anchorPoint.Cursor);
     curAnchorPoint = anchorPoint;
     isMouseDown = true;
 }
예제 #4
0
 private void MoveRefAnchorPoint(double x, double y,AnchorPoint movedAnchorPoint)
 {
     foreach (AnchorPoint anchorPoint in anchorPoints)
     {
         if (anchorPoint.RefPoint.Length == 2)
         {
             if (anchorPoint.RefPoint[0].X == x && anchorPoint.RefPoint[0].Y == y)
             {
                 anchorPoint.RefPoint[0].X = movedAnchorPoint.X;
                 anchorPoint.RefPoint[0].Y = movedAnchorPoint.Y;
             }
             else if (anchorPoint.RefPoint[1].X == x && anchorPoint.RefPoint[1].Y == y)
             {
                 anchorPoint.RefPoint[1].X = movedAnchorPoint.X;
                 anchorPoint.RefPoint[1].Y = movedAnchorPoint.Y;
             }
             anchorPoint.X = (anchorPoint.RefPoint[0].X + anchorPoint.RefPoint[1].X) / 2;
             anchorPoint.Y = (anchorPoint.RefPoint[0].Y + anchorPoint.RefPoint[1].Y) / 2;
             anchorPoint.Move();
         }
     }
 }
예제 #5
0
 private void MoveRefAnchorPoint(double preX, double preY, double x, double y, AnchorPoint movedAnchorPoint)
 {
     foreach (AnchorPoint anchorPoint in anchorPoints)
     {
         if (anchorPoint.RefPoint.Length == 2)
         {
             Point[] refPoints = anchorPoint.RefPoint;
             if (refPoints[0].X == preX && refPoints[0].Y == preY
                 && refPoints[1].X == curAnchorPoint.X && refPoints[1].Y == curAnchorPoint.Y)
             {
                 anchorPoint.RefPoint[0].X = movedAnchorPoint.X;
                 anchorPoint.RefPoint[0].Y = movedAnchorPoint.Y;
                 anchorPoint.RefPoint[1].X = x;
                 anchorPoint.RefPoint[1].Y = y;
             }
             if (refPoints[1].X == preX && refPoints[1].Y == preY
                 && refPoints[0].X == curAnchorPoint.X && refPoints[0].Y == curAnchorPoint.Y)
             {
                 anchorPoint.RefPoint[1].X = movedAnchorPoint.X;
                 anchorPoint.RefPoint[1].Y = movedAnchorPoint.Y;
                 anchorPoint.RefPoint[0].X = x;
                 anchorPoint.RefPoint[0].Y = y;
             }
             anchorPoint.X = (anchorPoint.RefPoint[0].X + anchorPoint.RefPoint[1].X) / 2;
             anchorPoint.Y = (anchorPoint.RefPoint[0].Y + anchorPoint.RefPoint[1].Y) / 2;
             anchorPoint.Move();
         }
     }
 }
예제 #6
0
        /// <summary>
        /// 移动单个点
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="anchorPoint"></param>
        private void MoveAnchorPoint(double x, double y, AnchorPoint anchorPoint)
        {
            double preX = anchorPoint.X;
            double preY = anchorPoint.Y;
            if (curAnchorPoint.AnchorPointType == AnchorPointType.NS)
            {
                anchorPoint.Move(anchorPoint.X, y);
                MoveRefAnchorPoint(preX, preY, anchorPoint);
            }
            else if (curAnchorPoint.AnchorPointType == AnchorPointType.WE)
            {
                anchorPoint.Move(x, anchorPoint.Y);
                MoveRefAnchorPoint(preX, preY, anchorPoint);
            }
            else
            {
                if (anchorPoint.AnchorPointType == AnchorPointType.NS)
                {
                    anchorPoint.Move(anchorPoint.X, y);
                    MoveRefAnchorPoint(preX, preY, anchorPoint);
                }
                else if (anchorPoint.AnchorPointType == AnchorPointType.WE)
                {
                    anchorPoint.Move(x, anchorPoint.Y);
                    MoveRefAnchorPoint(preX, preY, anchorPoint);
                }
                else if (curAnchorPoint.AnchorPointType == AnchorPointType.NE)
                {
                    if (anchorPoint.AnchorPointType == AnchorPointType.SE)
                    {
                        anchorPoint.Move(anchorPoint.X, y);
                    }
                    else if (anchorPoint.AnchorPointType == AnchorPointType.NW)
                    {
                        anchorPoint.Move(x, anchorPoint.Y);
                    }

                    MoveRefAnchorPoint(preX, preY, x, y, anchorPoint);
                    MoveRefAnchorPoint(preX, preY, anchorPoint);
                }
                else if (curAnchorPoint.AnchorPointType == AnchorPointType.SW)
                {
                    if (anchorPoint.AnchorPointType == AnchorPointType.SE)
                    {
                        anchorPoint.Move(x, anchorPoint.Y);
                    }
                    else if (anchorPoint.AnchorPointType == AnchorPointType.NW)
                    {
                        anchorPoint.Move(anchorPoint.X, y);
                    }

                    MoveRefAnchorPoint(preX, preY, x, y, anchorPoint);
                    MoveRefAnchorPoint(preX, preY, anchorPoint);
                }
                else if (curAnchorPoint.AnchorPointType == AnchorPointType.SE)
                {
                    if (anchorPoint.AnchorPointType == AnchorPointType.SW)
                    {
                        anchorPoint.Move(x, anchorPoint.Y);
                    }
                    else if (anchorPoint.AnchorPointType == AnchorPointType.NE)
                    {
                        anchorPoint.Move(anchorPoint.X, y);
                    }

                    MoveRefAnchorPoint(preX, preY, x, y, anchorPoint);
                    MoveRefAnchorPoint(preX, preY, anchorPoint);
                }
                else if (curAnchorPoint.AnchorPointType == AnchorPointType.NW)
                {
                    if (anchorPoint.AnchorPointType == AnchorPointType.SW)
                    {
                        anchorPoint.Move(anchorPoint.X, y);
                    }
                    else if (anchorPoint.AnchorPointType == AnchorPointType.NE)
                    {
                        anchorPoint.Move(x, anchorPoint.Y);
                    }

                    MoveRefAnchorPoint(preX, preY, x, y, anchorPoint);
                    MoveRefAnchorPoint(preX, preY, anchorPoint);
                }
            }
        }