protected virtual void FirstPoint(QuadDocument document, QuadCanvas canvas, Point point) { quadrilateral = CreateQuadrilateral(); quadrilateral.Points.Add(point); quadrilateral.Points.Add(point); document.Quads.Add(quadrilateral); }
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; } }
public override void Deactivate(QuadDocument document, QuadCanvas canvas) { base.Deactivate(document, canvas); if (quadrilateral != null) { document.Quads.Remove(quadrilateral); } }
protected virtual void ThirdPoint(QuadDocument document, QuadCanvas canvas, Point point) { Point thirdPoint = ConstrainThirdPoint( quadrilateral.Points[0], quadrilateral.Points[1], point); quadrilateral.Points.Add(thirdPoint); }
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; } } }
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; } } }
public virtual void MouseLeave(QuadDocument document, QuadCanvas canvas, MouseEventArgs e) { canvas.Cursor = Cursors.Arrow; }
public abstract void MouseMove(QuadDocument document, QuadCanvas canvas, MouseEventArgs e);
public virtual void MouseLeftButtonDown(QuadDocument document, QuadCanvas quadCanvas, MouseButtonEventArgs e) { }
public abstract void MouseLeftButtonUp(QuadDocument document, QuadCanvas canvas, MouseButtonEventArgs e);
public virtual void Deactivate(QuadDocument document, QuadCanvas canvas) { }
public override void MouseLeftButtonUp(QuadDocument document, QuadCanvas canvas, MouseButtonEventArgs e) { inMove = false; }
protected virtual void SecondPoint(QuadDocument document, QuadCanvas canvas, Point point) { quadrilateral.Points.Add(point); }
public override void MouseMove(QuadDocument document, QuadCanvas canvas, MouseEventArgs e) { if (inMove) { } }
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])); }
protected virtual void FourthPoint(QuadDocument document, QuadCanvas canvas, Point point) { quadrilateral.Points.Add(point); quadrilateral = null; }