Inheritance: GalaSoft.MvvmLight.ObservableObject
示例#1
0
 private void ConnectorLinked(NodeConnection from,NodeConnection to)
 {
     NodeLinked(from,to);
 }
        private void NodeLinked(NodeConnection from, NodeConnection to)
        {
            Debug.WriteLine("Linked {0} -> {1}", from.ConnectedNodeId, to.ConnectedNodeId);
            NodeBase nodeFrom = null;
            NodeBase nodeTo = null;

            foreach (var child in this.canvasDiagram.Children)
            {
                if (child is NodeBase)
                {
                    var node = child as NodeBase;
                    if (node.NodeId == from.ConnectedNodeId)
                    {
                        nodeFrom = node;
                    }
                    if (node.NodeId == to.ConnectedNodeId)
                    {
                        nodeTo = node;
                    }
                }
            }

            var fromPoint = nodeFrom.GetPosition();
            var toPoint = nodeTo.GetPosition();
            Point distance = new Point(toPoint.X - fromPoint.X, toPoint.Y - fromPoint.Y);

            BezierSegment segment = new BezierSegment();
            segment.Point1 = new Point(fromPoint.X + distance.X / 3, fromPoint.Y - 100);
            segment.Point2 = new Point(fromPoint.X + distance.X * 2 / 3, toPoint.Y + 100);
            segment.Point3 = nodeTo.GetPosition();

            PathFigure figure = new PathFigure();
            figure.StartPoint = nodeFrom.GetPosition();
            figure.Segments.Add(segment);

            PathGeometry geo = new PathGeometry();
            geo.Figures.Add(figure);

            Windows.UI.Xaml.Shapes.Path path = new Windows.UI.Xaml.Shapes.Path();
            path.StrokeThickness = 2;
            path.Stroke = new SolidColorBrush(Colors.Black);

            path.Data = geo;

            this.canvasDiagram.Children.Add(path);
        }
示例#3
0
 public void NodeOutConnected(int connectorId,NodeConnection connectedInfo)
 {
     OutConnectorList.First(q => q.ConnectorId == connectorId).ConnectionList.Add(connectedInfo);
 }