Beispiel #1
0
        public void BringToView(IEnumerable <INode> nodes)
        {
            var x = nodes.Min(n => n.Location.X - (n.Width / 4));
            var y = nodes.Min(n => n.Location.Y - (n.Height * 4));

            Offset = new GraphPoint(x, y);
            Zoom   = 0.9;
        }
Beispiel #2
0
        /// <summary>
        /// Updates the visuals.
        /// </summary>
        public void UpdateVisuals()
        {
            if (ParentGraph == null)
            {
                return;
            }

            if (StartPort != null)
            {
                var    startX = StartPort.Location.X;
                var    startY = StartPort.Location.Y;
                double endX;
                double endY;
                if (EndPort == null)
                {
                    endX = ParentGraph.MousePosition.X;
                    endY = ParentGraph.MousePosition.Y;
                }
                else
                {
                    endX = EndPort.Location.X;
                    endY = EndPort.Location.Y;
                }

                double bend = 0;

                if (startX > endX)
                {
                    bend = Math.Abs(startX - endX);
                }

                double startBezX;
                double startBezY;
                double endBezX;
                double endBezY;

                if (StartPort.PortType == PortType.Out)
                {
                    startBezX = endX + bend - (int)((endX - startX) / 2);
                    startBezY = startY;
                    endBezX   = startX - bend + (int)((endX - startX) / 2);
                    endBezY   = endY;
                }
                else
                {
                    startBezX = startX - bend + (int)((startX - endX) / 2);
                    startBezY = startY;
                    endBezX   = endX + bend - (int)((startX - endX) / 2);
                    endBezY   = endY;
                }

                StartPoint = new GraphPoint(startX, startY);
                Point1     = new GraphPoint(startBezX, startBezY);
                Point2     = new GraphPoint(endBezX, endBezY);
                Point3     = new GraphPoint(endX, endY);
            }
        }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Link"/> class.
 /// </summary>
 public Link()
 {
     _guid          = Guid.NewGuid();
     _zIndex        = Constants.LINK_ZINDEX;
     _overlayZIndex = Constants.LINK_OVERLAY_ZINDEX;
     Color          = Constants.COLOR_LINK;
     _location      = new GraphPoint();
     _lastLocation  = new GraphPoint();
 }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Node"/> class.
 /// </summary>
 public Node()
 {
     _ports                    = new PortCollection(this);
     _zIndex                   = Constants.NODE_ZINDEX;
     _location                 = new GraphPoint();
     _lastLocation             = new GraphPoint();
     _ports.CollectionChanged += _ports_CollectionChanged;
     _ports.PortChanged       += _ports_PortChanged;
     _ports.PortConnected     += _ports_PortConnected;
     _ports.PortDisconnected  += _ports_PortDisconnected;
 }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Port"/> class.
 /// </summary>
 public Port()
 {
     _connectedPorts = new ObservableCollection <IPort>();
     _connectedPorts.CollectionChanged += _connectedPorts_CollectionChanged;
     _location = new GraphPoint();
 }
Beispiel #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Comment"/> class.
 /// </summary>
 public Comment()
 {
     LastLocation = new GraphPoint();
 }