示例#1
0
 protected virtual void FirstPoint(QuadDocument document, QuadCanvas canvas, Point point)
 {
     quadrilateral = CreateQuadrilateral();
     quadrilateral.Points.Add(point);
     quadrilateral.Points.Add(point);
     document.Quads.Add(quadrilateral);
 }
示例#2
0
        public override void MouseLeftButtonDown(QuadDocument document, QuadCanvas canvas, System.Windows.Input.MouseButtonEventArgs e)
        {
            startPoint = e.GetPosition(canvas);
            QuadCanvasItem item            = canvas.GetItemHit(startPoint);
            bool           shifyKeyPressed = Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift);

            if (item != null)
            {
                if (shifyKeyPressed)
                {
                    canvas.SelectedItems.Add(item.Quadrilateral);
                }
                else
                {
                    canvas.SelectedItem = item.Quadrilateral;
                }
            }
            else
            {
                if (!shifyKeyPressed)
                {
                    canvas.SelectedItem = null;
                }
                inMove = false;
            }
        }
示例#3
0
 public override void Deactivate(QuadDocument document, QuadCanvas canvas)
 {
     base.Deactivate(document, canvas);
     if (quadrilateral != null)
     {
         document.Quads.Remove(quadrilateral);
     }
 }
示例#4
0
        protected virtual void ThirdPoint(QuadDocument document, QuadCanvas canvas, Point point)
        {
            Point thirdPoint = ConstrainThirdPoint(
                quadrilateral.Points[0],
                quadrilateral.Points[1],
                point);

            quadrilateral.Points.Add(thirdPoint);
        }
示例#5
0
 public override void MouseMove(QuadDocument document, QuadCanvas canvas, MouseEventArgs e)
 {
     if (quadrilateral != null)
     {
         Point currentPoint = e.GetPosition(canvas);
         if (quadrilateral.Points.Count == 3)
         {
             currentPoint = ConstrainThirdPoint(quadrilateral.Points[0],
                                                quadrilateral.Points[1],
                                                currentPoint);
         }
         if (quadrilateral.Points[quadrilateral.Points.Count - 1] != currentPoint)
         {
             quadrilateral.Points[quadrilateral.Points.Count - 1] = currentPoint;
         }
     }
 }
示例#6
0
        public override void MouseLeftButtonUp(QuadDocument document, QuadCanvas canvas, MouseButtonEventArgs e)
        {
            if (quadrilateral == null)
            {
                FirstPoint(document, canvas, e.GetPosition(canvas));
            }
            else
            {
                switch (quadrilateral.Points.Count - 1)
                {
                case 1:
                    SecondPoint(document, canvas, e.GetPosition(canvas));
                    break;

                case 2:
                    ThirdPoint(document, canvas, e.GetPosition(canvas));
                    break;

                case 3:
                    FourthPoint(document, canvas, e.GetPosition(canvas));
                    break;
                }
            }
        }
示例#7
0
 public virtual void MouseLeave(QuadDocument document, QuadCanvas canvas, MouseEventArgs e)
 {
     canvas.Cursor = Cursors.Arrow;
 }
示例#8
0
 public abstract void MouseMove(QuadDocument document, QuadCanvas canvas, MouseEventArgs e);
示例#9
0
 public virtual void MouseLeftButtonDown(QuadDocument document, QuadCanvas quadCanvas, MouseButtonEventArgs e)
 {
 }
示例#10
0
 public abstract void MouseLeftButtonUp(QuadDocument document, QuadCanvas canvas, MouseButtonEventArgs e);
示例#11
0
 public virtual void Deactivate(QuadDocument document, QuadCanvas canvas)
 {
 }
示例#12
0
 public override void MouseLeftButtonUp(QuadDocument document, QuadCanvas canvas, MouseButtonEventArgs e)
 {
     inMove = false;
 }
示例#13
0
 protected virtual void SecondPoint(QuadDocument document, QuadCanvas canvas, Point point)
 {
     quadrilateral.Points.Add(point);
 }
示例#14
0
 public override void MouseMove(QuadDocument document, QuadCanvas canvas, MouseEventArgs e)
 {
     if (inMove)
     {
     }
 }
示例#15
0
 public virtual void MouseEnter(QuadDocument document, QuadCanvas canvas, MouseEventArgs e)
 {
     canvas.Cursor = GetCursor();
 }
示例#16
0
 protected override void ThirdPoint(QuadDocument document, QuadCanvas canvas, Point point)
 {
     base.ThirdPoint(document, canvas, point);
     FourthPoint(document, canvas, Parallelogram.CalculateFourthPoint(quadrilateral.Points[0], quadrilateral.Points[1], quadrilateral.Points[2]));
 }
示例#17
0
 protected virtual void FourthPoint(QuadDocument document, QuadCanvas canvas, Point point)
 {
     quadrilateral.Points.Add(point);
     quadrilateral = null;
 }