protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            // Draw lines between connectors
            if (ViewModel?.Nodes != null)
            {
                foreach (var node in ViewModel.Nodes)
                {
                    foreach (var prop in node.LinkableProperties)
                    {
                        // Check if the property has a reference to an expression, if so, find the connector points
                        if (prop.Value is INodeReference nr && nr.Id.HasValue)
                        {
                            var start       = DependencyObjectUtils.ChildOfType <VisualNodeConnector>(this, c => c.NodeID == node.ID && c.PropertyName == prop.Name && c.ConnectorFlow == ConnectorFlow.Destination);
                            var end         = DependencyObjectUtils.ChildOfType <VisualNodeConnector>(this, c => c.NodeID == nr.Id.Value && c.ConnectorFlow == ConnectorFlow.Source);
                            var isStatement = prop.PropertyType == VisualNodePropertyType.Statement;

                            if (start != null && end != null)
                            {
                                drawingContext.DrawConnectorLine(
                                    new Pen(new SolidColorBrush(isStatement ? Colors.Gray : this.ColorForDataType(prop.Type)), 2d),
                                    start.TransformToAncestor(this).Transform(start.MidPoint),
                                    end.TransformToAncestor(this).Transform(end.MidPoint),
                                    isStatement
                                    );
                            }
                        }
                    }
                }
            }

            // If there is a drag going on, run the behaviours custom render method
            ViewModel?.DragBehaviour?.OnRender(this, drawingContext);
        }
Exemple #2
0
 public void OnRender(VisualNodeCanvas canvas, DrawingContext drawingContext)
 {
     drawingContext.DrawConnectorLine(
         linePen,
         Connector.TransformToAncestor(canvas).Transform(Connector.MidPoint),
         lastPoint,
         isStatement
         );
 }