Exemple #1
0
 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);
 }
Exemple #2
0
 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;
 }
Exemple #3
0
 // 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);
 }
Exemple #4
0
 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;
 }
Exemple #5
0
 private static void RaiseOnShapeAdded(Connectable shape)
 {
     if (OnShapeAdded != null)
         OnShapeAdded(null, new ShapeEventArgs(shape));
 }
Exemple #6
0
 private void PointsToShapes(Point b, Point e)
 {
     mFromShape = GetConnectable(b);
     mToShape   = GetConnectable(e);
 }
Exemple #7
0
 private void AddConnection(Core.Connectable first, Core.Connectable second)
 {
     mFromShape = first;
     mToShape   = second;
     AddConnection();
 }
Exemple #8
0
 ///<summary>
 ///Default constructor
 ///</summary>
 public ShapeEventArgs(Connectable shape)
 {
     this.mShape = shape;
 }
Exemple #9
0
 ///<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;
 }
 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();

            }
 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;
 }