Example #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);
 }
Example #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;
            }
        }
Example #3
0
 public override void Deactivate(QuadDocument document, QuadCanvas canvas)
 {
     base.Deactivate(document, canvas);
     if (quadrilateral != null)
     {
         document.Quads.Remove(quadrilateral);
     }
 }
Example #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);
        }
Example #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;
         }
     }
 }
Example #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;
                }
            }
        }
Example #7
0
 public virtual void MouseLeave(QuadDocument document, QuadCanvas canvas, MouseEventArgs e)
 {
     canvas.Cursor = Cursors.Arrow;
 }
Example #8
0
 public abstract void MouseMove(QuadDocument document, QuadCanvas canvas, MouseEventArgs e);
Example #9
0
 public virtual void MouseLeftButtonDown(QuadDocument document, QuadCanvas quadCanvas, MouseButtonEventArgs e)
 {
 }
Example #10
0
 public abstract void MouseLeftButtonUp(QuadDocument document, QuadCanvas canvas, MouseButtonEventArgs e);
Example #11
0
 public virtual void Deactivate(QuadDocument document, QuadCanvas canvas)
 {
 }
Example #12
0
 public override void MouseLeftButtonUp(QuadDocument document, QuadCanvas canvas, MouseButtonEventArgs e)
 {
     inMove = false;
 }
Example #13
0
 protected virtual void SecondPoint(QuadDocument document, QuadCanvas canvas, Point point)
 {
     quadrilateral.Points.Add(point);
 }
Example #14
0
 public override void MouseMove(QuadDocument document, QuadCanvas canvas, MouseEventArgs e)
 {
     if (inMove)
     {
     }
 }
Example #15
0
 public virtual void MouseEnter(QuadDocument document, QuadCanvas canvas, MouseEventArgs e)
 {
     canvas.Cursor = GetCursor();
 }
 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]));
 }
Example #17
0
 protected virtual void FourthPoint(QuadDocument document, QuadCanvas canvas, Point point)
 {
     quadrilateral.Points.Add(point);
     quadrilateral = null;
 }