public static void AddShape(Connectable shape, ShapeTypes type) { if (shape == null) throw new ArgumentNullException("A null cannot be added to the shape collection."); //the undo trick AddShapeCommand cmd = new AddShapeCommand(shape, type, Canvas); UndoManager.Execute(cmd); RaiseOnShapeAdded(shape); }
public CreateConnectionCommand(Core.Connectable first, Core.Connectable second, Canvas canvas) { if (canvas == null) { throw new ArgumentNullException("The canvas cannot be null"); } mFromShape = first; mToShape = second; mCanvas = canvas; }
// Filter the hit test values for each object in the enumeration. public HitTestFilterBehavior ShapesFilter(DependencyObject o) { // Test for the object value you want to filter. if (o is Core.IConnectable) { // Visual object and descendants are NOT part of hit test results enumeration. //return HitTestFilterBehavior.ContinueSkipSelfAndChildren; found = o as Core.Connectable; return(HitTestFilterBehavior.Stop); } return(HitTestFilterBehavior.ContinueSkipSelf); }
public bool MouseDown(MouseEventArgs e) { if (IsSuspended) return false; Connectable elem = null; HitTestResult result = VisualTreeHelper.HitTest(Canvas, e.GetPosition(Canvas)); if (result.VisualHit != null) { elem = GetConnectable(result.VisualHit as Visual); if (ShapeFactory.Exists(elem)) { SelectionManager.SelectShape(elem); movedShape = SelectionManager.SelectedShape as Connectable; moving = true; shift = e.GetPosition(movedShape); initialPoint = new Point(Canvas.GetLeft(movedShape), Canvas.GetTop(movedShape)); ActivateTool(); return true; } } return false; }
private static void RaiseOnShapeAdded(Connectable shape) { if (OnShapeAdded != null) OnShapeAdded(null, new ShapeEventArgs(shape)); }
private void PointsToShapes(Point b, Point e) { mFromShape = GetConnectable(b); mToShape = GetConnectable(e); }
private void AddConnection(Core.Connectable first, Core.Connectable second) { mFromShape = first; mToShape = second; AddConnection(); }
///<summary> ///Default constructor ///</summary> public ShapeEventArgs(Connectable shape) { this.mShape = shape; }
// Filter the hit test values for each object in the enumeration. public HitTestFilterBehavior ShapesFilter(DependencyObject o) { // Test for the object value you want to filter. if (o is Core.IConnectable) { // Visual object and descendants are NOT part of hit test results enumeration. //return HitTestFilterBehavior.ContinueSkipSelfAndChildren; found = o as Core.Connectable; return HitTestFilterBehavior.Stop; } return HitTestFilterBehavior.ContinueSkipSelf; }
public CreateConnectionCommand(Core.Connectable first, Core.Connectable second, Canvas canvas) { if (canvas == null) throw new ArgumentNullException("The canvas cannot be null"); mFromShape = first; mToShape = second; mCanvas = canvas; }