private DiagramShape _OverlayShape;           // What is it that we're using to show where the shape will end up?

        public SimpleShapeDragger(DiagramSurface surface, MainWindow window, Point startPoint, DiagramShape originalShape)
            : base(surface, window, startPoint)
        {
            _OriginalShape = originalShape;

            SetupMouse();
        }
Ejemplo n.º 2
0
        private DiagramShape _OverlayShape; // What is it that we're using to show where the shape will end up?

        #endregion Fields

        #region Constructors

        public SimpleShapeDragger(DiagramSurface surface, MainWindow window, Point startPoint, DiagramShape originalShape)
            : base(surface, window, startPoint)
        {
            _OriginalShape = originalShape;

            SetupMouse();
        }
Ejemplo n.º 3
0
        public void AddToSurface(DiagramSurface surface)
        {
            Surface = surface;
            Surface.Children.Add(this);

            SourceEndPoint = new ConnectorEndPoint(this);
            TargetEndPoint = new ConnectorEndPoint(this);

            // Setup ConnectorEndPoints
            if (DrawingStrategy != null && DrawingStrategy.OverrideConnectorEndPointSetup)
            {
                DrawingStrategy.CustomSetupConnectorEndPoint(this);
            }

            SetupSourceConnectorEndPoint();
            SetupTargetConnectorEndPoint();

            SourceEndPoint.AddToSurface(surface);
            TargetEndPoint.AddToSurface(surface);

            // Setup Adorners
            AdornerLayer layer = AdornerLayer.GetAdornerLayer(this);

            if (layer == null)
            {
                return;
            }

            SetupRelationshipNameAdorner(layer);

            //SetupSourceCardinalityAdorner(layer);
            //SetupTargetCardinalityAdorner(layer);
        }
Ejemplo n.º 4
0
        public NewConnectionDragger(DiagramSurface surface, MainWindow window, Point startPoint, ConnectionPoint startConnectionPoint) : base(surface, window, startPoint, new Connection(startConnectionPoint), false)
        {
            _OriginalConnection.AddToSurface(surface);
            _OriginalConnection.Source = startConnectionPoint.ParentShape;
            Connection.SetConnectionStartPointBinding(_OriginalConnection, startConnectionPoint);

            _OriginalConnection.EndPoint = Mouse.GetPosition(_Surface);
        }
Ejemplo n.º 5
0
        public void RemoveFromSurface(DiagramSurface surface)
        {
            surface.Children.Remove(this);
            surface.Children.Remove(SourceEndPoint);
            surface.Children.Remove(TargetEndPoint);

            Surface = null;
        }
Ejemplo n.º 6
0
        public void AddToSurface(DiagramSurface surface)
        {
            if (surface == null)
            {
                return;
            }

            surface.Children.Add(this);
            Surface = surface;
        }
Ejemplo n.º 7
0
        public void RemoveFromSurface(DiagramSurface surface)
        {
            if (surface == null)
            {
                return;
            }

            surface.Children.Remove(this);
            Surface = null;
        }
Ejemplo n.º 8
0
        public ConnectionDragger(DiagramSurface surface, MainWindow window, Point startPoint, Connection originalConnection, bool isStartOfConnection) : base(surface, window, startPoint)
        {
            _OriginalConnection      = originalConnection;
            _IsStartOfConnection     = isStartOfConnection;
            _OriginalConnectionPoint = isStartOfConnection
                                                        ? originalConnection.SourceConnectionPoint
                                                        : originalConnection.TargetConnectionPoint;
            _OriginalConnectionBrush = _OriginalConnection.Stroke;

            SetupMouse();
        }
Ejemplo n.º 9
0
        public static List <IDiagramEntity> GetImportantObjectsAt(this DiagramSurface surface, Point point)
        {
            var objects = new List <IDiagramEntity>();

            surface.GetShapesAt(point).ForEach(objects.Add);
            surface.GetConnectionsAt(point).ForEach(objects.Add);
            surface.GetConnectionPointsAt(point).ForEach(objects.Add);
            surface.GetConnectorEndPointsAt(point).ForEach(objects.Add);

            return(objects);
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.manipulationAdorner = this.GetTemplateChild("ManipulationAdorner") as CustomManipulationAdorner;
            this.horizontalDragVisual = this.GetTemplateChild("PART_horizontalDragOver") as FrameworkElement;
            this.verticalDragVisual = this.GetTemplateChild("PART_verticalDragOver") as FrameworkElement;
            this.itemHost = this.GetTemplateChild("ItemsHost") as DiagramSurface;

            this.SelectionChanged += OnSelectionChanged;
        }
Ejemplo n.º 11
0
        public void RemoveFromSurface(DiagramSurface surface)
        {
            surface.Children.Remove(this);

            foreach (var cp in ConnectionPoints)
            {
                cp.RemoveFromSurface(surface);
            }

            Surface = null;
        }
Ejemplo n.º 12
0
        public void AddToSurface(DiagramSurface surface)
        {
            surface.Children.Add(this);

            foreach (var cp in ConnectionPoints)
            {
                cp.AddToSurface(surface);
            }

            Surface = surface;
        }
Ejemplo n.º 13
0
        public ConnectionDragger(DiagramSurface surface, MainWindow window, Point startPoint, Connection originalConnection, bool isStartOfConnection)
            : base(surface, window, startPoint)
        {
            _OriginalConnection = originalConnection;
            _IsStartOfConnection = isStartOfConnection;
            _OriginalConnectionPoint = isStartOfConnection
                                       	? originalConnection.SourceConnectionPoint
                                       	: originalConnection.TargetConnectionPoint;
            _OriginalConnectionBrush = _OriginalConnection.Stroke;

            SetupMouse();
        }
Ejemplo n.º 14
0
        public static ConnectorEndPoint GetConnectorEndPointAt(this DiagramSurface surface, Point point)
        {
            var shapesHit = GetConnectorEndPointsAt(surface, point);

            shapesHit.Sort((s1, s2) =>
            {
                var distance1 = s1.StartPoint.AbsoluteDistanceTo(point);
                var distance2 = s2.StartPoint.AbsoluteDistanceTo(point);

                return(distance1.CompareTo(distance2));
            });

            return(shapesHit.Count > 0 ? shapesHit[0] : null);
        }
Ejemplo n.º 15
0
        public static Connection GetConnectionAt(this DiagramSurface surface, Point p)
        {
            var shapesHit = GetConnectionsAt(surface, p);

            shapesHit.Sort((s1, s2) =>
            {
                var distance1 = Math.Min(s1.StartPoint.AbsoluteDistanceTo(p), s1.EndPoint.AbsoluteDistanceTo(p));
                var distance2 = Math.Min(s2.StartPoint.AbsoluteDistanceTo(p), s2.EndPoint.AbsoluteDistanceTo(p));

                return(distance1.CompareTo(distance2));
            });

            return(shapesHit.Count > 0 ? shapesHit[0] : null);
        }
Ejemplo n.º 16
0
        public static DiagramShape GetShapeAt(this DiagramSurface surface, Point p)
        {
            var shapesHit = GetShapesAt(surface, p);

            shapesHit.Sort((s1, s2) =>
            {
                var distance1 = s1.Location.AbsoluteDistanceTo(p);
                var distance2 = s2.Location.AbsoluteDistanceTo(p);

                return(distance1.CompareTo(distance2));
            });

            return(shapesHit.Count > 0 ? shapesHit[0] : null);
        }
Ejemplo n.º 17
0
        protected Point _StartPoint; // Where the mouse started off from

        #endregion Fields

        #region Constructors

        protected DraggerBase(DiagramSurface surface, MainWindow window, Point startPoint)
        {
            _Surface = surface;
            _Window = window;
            _StartPoint = startPoint;
        }
Ejemplo n.º 18
0
 public void RemoveFromSurface(DiagramSurface surface)
 {
     surface.Children.Remove(this);
     Surface = null;
 }
Ejemplo n.º 19
0
 public void AddToSurface(DiagramSurface surface)
 {
     surface.Children.Add(this);
     Surface = surface;
 }
Ejemplo n.º 20
0
 protected DraggerBase(DiagramSurface surface, MainWindow window, Point startPoint)
 {
     _Surface    = surface;
     _Window     = window;
     _StartPoint = startPoint;
 }
Ejemplo n.º 21
0
        public void RemoveFromSurface(DiagramSurface surface)
        {
            if (surface == null) return;

            surface.Children.Remove(this);
            Surface = null;
        }
Ejemplo n.º 22
0
        public void AddToSurface(DiagramSurface surface)
        {
            if (surface == null) return;

            surface.Children.Add(this);
            Surface = surface;
        }
Ejemplo n.º 23
0
        public void AddToSurface(DiagramSurface surface)
        {
            Surface = surface;
            Surface.Children.Add(this);

            SourceEndPoint = new ConnectorEndPoint(this);
            TargetEndPoint = new ConnectorEndPoint(this);

            // Setup ConnectorEndPoints
            if (DrawingStrategy != null && DrawingStrategy.OverrideConnectorEndPointSetup)
            {
                DrawingStrategy.CustomSetupConnectorEndPoint(this);
            }

            SetupSourceConnectorEndPoint();
            SetupTargetConnectorEndPoint();

            SourceEndPoint.AddToSurface(surface);
            TargetEndPoint.AddToSurface(surface);

            // Setup Adorners
            AdornerLayer layer = AdornerLayer.GetAdornerLayer(this);
            if (layer == null) return;

            SetupRelationshipNameAdorner(layer);

            //SetupSourceCardinalityAdorner(layer);
            //SetupTargetCardinalityAdorner(layer);
        }
Ejemplo n.º 24
0
        public NewConnectionDragger(DiagramSurface surface, MainWindow window, Point startPoint, ConnectionPoint startConnectionPoint)
            : base(surface, window, startPoint, new Connection(startConnectionPoint), false)
        {
            _OriginalConnection.AddToSurface(surface);
            _OriginalConnection.Source = startConnectionPoint.ParentShape;
            Connection.SetConnectionStartPointBinding(_OriginalConnection, startConnectionPoint);

            _OriginalConnection.EndPoint = Mouse.GetPosition(_Surface);
        }
Ejemplo n.º 25
0
        public void AddToSurface(DiagramSurface surface)
        {
            surface.Children.Add(this);

            foreach (var cp in ConnectionPoints)
                cp.AddToSurface(surface);

            Surface = surface;
        }
Ejemplo n.º 26
0
 public static List <Connection> GetConnectionsAt(this DiagramSurface surface, Point p)
 {
     return(GetShapesHit(surface, p, ConnectionLambda));
 }
Ejemplo n.º 27
0
 public static List <ConnectorEndPoint> GetConnectorEndPointsAt(this DiagramSurface surface, Point point)
 {
     return(GetShapesHit(surface, point, ConnectorEndPointLambda));
 }
Ejemplo n.º 28
0
        public void RemoveFromSurface(DiagramSurface surface)
        {
            surface.Children.Remove(this);

            foreach(var cp in ConnectionPoints)
                cp.RemoveFromSurface(surface);

            Surface = null;
        }
Ejemplo n.º 29
0
 public void RemoveFromSurface(DiagramSurface surface)
 {
     surface.Children.Remove(this);
     Surface = null;
 }
Ejemplo n.º 30
0
 public void AddToSurface(DiagramSurface surface)
 {
     surface.Children.Add(this);
     Surface = surface;
 }
Ejemplo n.º 31
0
        public void RemoveFromSurface(DiagramSurface surface)
        {
            surface.Children.Remove(this);
            surface.Children.Remove(SourceEndPoint);
            surface.Children.Remove(TargetEndPoint);

            Surface = null;
        }
Ejemplo n.º 32
0
 public static List <DiagramShape> GetShapesAt(this DiagramSurface surface, Point p)
 {
     return(GetShapesHit(surface, p, SimpleShapeLambda));
 }