示例#1
0
        /// <summary>
        /// Inits the treeview by calling MetaEdit+ and constructing the Graph tree.
        /// </summary>
        public void initializeTreeView()
        {
            GraphViewModel root = new GraphViewModel();

            root.IsNodeExpanded = true;
            Graph.ResetCaches();
            Graph[] gs = GraphHandler.Init();
            root.populate(gs, new List <Graph>());
            treeView1.ItemsSource = root.getChildren();
            treeView1.ContextMenu = this.Is50OrLater() ?
                                    treeView1.Resources["50Menu"] as System.Windows.Controls.ContextMenu:
                                    treeView1.Resources["45Menu"] as System.Windows.Controls.ContextMenu;
            bool _api = this.IsAPI();

            this.SetToolBarButtonsEnabled(_api);
            this.setView(_api);
        }
 public void populate(Graph[] graphs, List <Graph> stack)
 {
     if (!stack.Contains(this.getGraph()))
     {
         stack.Add(this.getGraph());
         foreach (Graph g in graphs)
         {
             GraphViewModel gvm = new GraphViewModel(g);
             this.addChild(gvm);
             Graph[] children = g.GetChildren();
             if (children != null && children.Count() > 0)
             {
                 Array.Sort(children);
                 gvm.populate(children, stack);
             }
         }
         stack.RemoveAt(stack.Count() - 1);
     }
 }