コード例 #1
0
ファイル: DecisionTree.xaml.cs プロジェクト: ChrDald/Jab.NET1
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            if (button == null)
            {
                return;
            }
            Node node = Part.FindAncestor <Node>(button);

            if (node == null)
            {
                return;
            }
            myDiagram.StartTransaction("ExpandCollapse");
            // Hide/show children of this node via the particular Button which also acts as the "port"
            String pid = Node.GetPortId(button);

            if (node.FindLinksOutOfPort(pid).Any(l => l.Visibility == Visibility.Collapsed))
            {
                ExpandTree(node, pid);
            }
            else
            {
                CollapseTree(node, pid);
            }
            myDiagram.CommitTransaction("ExpandCollapse");
        }
コード例 #2
0
ファイル: DecisionTree.xaml.cs プロジェクト: ChrDald/Jab.NET1
 public void CollapseTree(Node node, String portid)
 {
     foreach (Link l in node.FindLinksOutOfPort(portid))
     {
         Node n = l.GetOtherNode(node);
         if (n != null && n != node)
         {
             // Hide both the link and the node
             l.Visible = false;
             n.Visible = false;
             // Recursively collapse all children
             CollapseTree(n, null);
         }
     }
 }
コード例 #3
0
ファイル: DecisionTree.xaml.cs プロジェクト: ChrDald/Jab.NET1
 public void ExpandTree(Node node, String portid)
 {
     foreach (Link l in node.FindLinksOutOfPort(portid))
     {
         Node n = l.GetOtherNode(node);
         if (n != null && n != node)
         {
             // Calculate a reasonable initial location for the layout animation;
             // LayoutDiagram (called due to CommitTransaction) will move it to its proper location
             n.Location = Spot.TopRight.PointInRect(node.Bounds);
             // Show both the link and the node
             l.Visible = true;
             n.Visible = true;
         }
     }
 }