protected override void OnMouseDown(MouseButtonEventArgs e) { DesignerCanvas.DeselectAll(); if (e.LeftButton == MouseButtonState.Pressed) { DesignerCanvas.DeselectAll(); StartPoint = e.GetPosition(this); _gridLineShape = new GridLineShape(new GridLine(Orientation, StartPoint.Value), _thickness); _gridLineShape.DataContext = this; switch (Orientation) { case Orientation.Horizontal: AdornerCanvas.Cursor = Cursors.SizeNS; break; case Orientation.Vertical: AdornerCanvas.Cursor = Cursors.SizeWE; break; } AdornerCanvas.Children.Add(_gridLineShape); if (!AdornerCanvas.IsMouseCaptured) AdornerCanvas.CaptureMouse(); } }
private void Cleanup() { _gridLineShape = null; AdornerCanvas.ReleaseMouseCapture(); AdornerCanvas.Cursor = Cursors.Pen; }
public void Remove(GridLineShape gridLineShape) { DesignerCanvas.GridLineController.GridLines.Remove(gridLineShape.GridLine); AdornerCanvas.Children.Remove(gridLineShape); }