Exemplo n.º 1
0
        private void RefreshNodeControls()
        {
            int i = NodesCanvas.Children.Count - 1;

            while (i >= 0)
            {
                if (NodesCanvas.Children[i] is NodeBaseControl)
                {
                    if (!(_graph.Nodes.Contains((NodesCanvas.Children[i] as NodeBaseControl).BaseNode)))
                    {
                        NodesCanvas.Children.RemoveAt(i);
                    }
                    i--;
                }
            }
            foreach (var n in _graph.Nodes)
            {
                if (!HasNode(n))
                {
                    var nc = new NodeBaseControl(_manager, _manager.ActiveKernel.Get <ZoomBorder>(), n);

                    var al = AdornerLayer.GetAdornerLayer(this);
                    al.Add(new NodeAdorner(nc));
                    NodesCanvas.Children.Add(nc);
                }
            }

            for (int ind = ConnectionsCanvas.Children.Count - 1; ind >= 0; ind--)
            {
                if (ConnectionsCanvas.Children[i] is ConnectorCurve)
                {
                    var con = ConnectionsCanvas.Children[i] as ConnectorCurve;
                    if (!_graph.Connectors.Contains(con.con))
                    {
                        ConnectionsCanvas.Children.Remove(con);
                    }
                }
            }
            foreach (var c in _graph.Connectors)
            {
                if (!HasConnector(c))
                {
                    ConnectionsCanvas.Children.Add(new ConnectorCurve(_manager, c));
                }
            }
        }
Exemplo n.º 2
0
 private void NodedAddedHandler(INode n)
 {
     if (!HasNode(n))
     {
         NodeBaseControl nn;
         if (n is NumberInputNode)
         {
             nn = new NumberSlider(_manager, _manager.ActiveKernel.Get <ZoomBorder>(), n);
         }
         else
         {
             nn = new NodeBaseControl(_manager, _manager.ActiveKernel.Get <ZoomBorder>(), n);
         }
         NodesCanvas.Children.Add(nn);
         nn.OnSocketDragStart += SocketDragStarted;
     }
 }