Bevisuali.UX.Graph.GraphInspector.AddNode C# (CSharp) Метод

AddNode() приватный Метод

private AddNode ( GraphNode graphNode ) : void
graphNode GraphNode
Результат void
        private void AddNode(GraphNode graphNode)
        {
            // Add to visual tree.
            xRoot.Children.Add(graphNode);
            graphNode.SetValue(Canvas.ZIndexProperty, LayerUnimportantNodes);

            // Add to internal list.
            _nodes.Add(graphNode);

            RandomVariable variable = (RandomVariable)graphNode.Tag;
            variable.UserData = graphNode;

            // Ensure canvas is large enough.
            {
                const double padding = 100;
                double maxX = _nodes.Max(n => n.Position.X) + padding;
                double maxY = _nodes.Max(n => n.Position.Y) + padding;
                xRoot.Width = Math.Max(xRoot.Width, maxX);
                xRoot.Height = Math.Max(xRoot.Height, maxY);
            }

            // Events.
            graphNode.MouseUp += delegate(object sender, MouseButtonEventArgs e)
            {
                if (graphNode.State == GraphNode.StateEnum.Selecting)
                {
                    App.Current.MainWindow.RequestConfigureVariable(variable);
                }
                else
                {
                    App.Current.MainWindow.RequestSelectVariable(variable);
                }

                e.Handled = true;
            };
            graphNode.SliceChosen += delegate(int sliceIndex, int scenarioIndex)
            {
                Debug.Assert(scenarioIndex == 1 || scenarioIndex == 2);

                if (sliceIndex == -1)
                {
                    App.Current.MainWindow.RequestConfigureVariableWithEvidence(variable, scenarioIndex, null);
                }
                else
                {
                    float evidenceValue = variable.Space.Values.ElementAt(sliceIndex);
                    App.Current.MainWindow.RequestConfigureVariableWithEvidence(variable, scenarioIndex, evidenceValue);
                }
            };
        }