Ejemplo n.º 1
0
        public void PopulateTreeNode(TreeNodeCollection treeNodeCollection,
                                     DirectoryNode directoryNode)
        {
            TreeNode treeNode = new MyTreeNode(directoryNode.NameSize, directoryNode);

            treeNode.ImageIndex         = FractionToIndex(directoryNode);
            treeNode.SelectedImageIndex = treeNode.ImageIndex;

            // Adding an item to the list has to be done on the
            // main thread of the control. We can get to it by
            // setting up a delegate that we want to call,
            // and then calling Invoke() on the treeview control.
            AddDelegate addDelegate = new AddDelegate(treeNodeCollection.Add);

            // Bug: Invoke should be declared with params.
            treeView1.Invoke(addDelegate, new object[] { treeNode });

            if (directoryNode.SizeTree != 0)
            {
                // Add a fake entry to this node so that there will be
                // a + sign in front of it.
                // Use invoke to delegate this call to the control.
                addDelegate = new AddDelegate(treeNode.Nodes.Add);
                treeView1.Invoke(addDelegate, new Object[] { new MyTreeNode("", null) });
            }
        }
Ejemplo n.º 2
0
        private void AddProjectNode(ProjectInfo pi)
        {
            TreeNode tn = ( TreeNode )_tvProjects.Invoke(new TreeNodeAdd(OnTreeNodeAdd), new object[] { _tvProjects.Nodes, pi.Name, 0, pi });

            tn.ImageIndex = 0;

            pi.Runs.RunAdded   += new RunCollection.RunEventHandler(OnRunAdded);
            pi.Runs.RunRemoved += new RunCollection.RunEventHandler(OnRunRemoved);

            foreach (Run run in pi.Runs)
            {
                AddRunNode(tn, run);
            }
        }
Ejemplo n.º 3
0
        public void Load(PoData poData, System.Windows.Forms.TreeView tv)
        {
            ParallelLoopResult result =
                Parallel.ForEach(poData.data.Values, new ParallelOptions {
                MaxDegreeOfParallelism = 1
            }, (pdContainer, pLoopState, inc) =>
            {
                var id       = pdContainer.id;
                var nodeName = pdContainer.msgctxt;

                nodeName = nodeName.Replace("\"", "");

                if (nodeName.Contains("."))
                {
                    var n = nodeName.Split('.');
                    tv.Nodes.Add(id.ToString(), n[0]);
                    for (int i = 1; i < n.Length; i++)
                    {
                        TreeNode lastNode = getLastNode(tv.Nodes[tv.Nodes.Count - 1]);
                        lastNode.Nodes.Add(id.ToString(), n[i]);
                    }
                }
                else
                {
                    tv.Invoke((MethodInvoker)(() =>
                                              tv.Nodes.Add(id.ToString(), nodeName)
                                              ));
                }
            });

            tv.ExpandAll();
            tv.SelectedNode = null;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Invoke方式添加TreeView的Node
 /// </summary>
 public static void InvokeAddNode(TreeView treeView, TreeNode node)
 {
     if (treeView.InvokeRequired)
     {
         treeView.Invoke(new MethodInvoker(() => { InvokeAddNode(treeView, node); }));
     }
     else
     {
         treeView.Nodes.Add(node);
     }
 }
Ejemplo n.º 5
0
        public void Synchronize()
        {
            //tree.Synchronize(txtPath.Text.Trim(), txtPattern.Text.Trim(), true);

            /*
             * lstDirectory.Items.Clear();
             * ArrayList list = tree.PrintTree();
             * lstDirectory.Items.AddRange(list.ToArray());
             */

            treeView1.Invoke(new FillTree_Dele(FillTree));
        }
Ejemplo n.º 6
0
        public static void ExpandAll(TreeView treeview)
        {
            MethodInvoker mi = delegate
            {
                treeview.ExpandAll();
            };

            if (treeview.InvokeRequired)
            {
                treeview.Invoke(mi);
            }
            else
            {
                mi();
            }
        }
Ejemplo n.º 7
0
        public static void ClearNodes(TreeView treeview)
        {
            MethodInvoker mi = delegate
            {
                treeview.Nodes.Clear();
            };

            if (treeview.InvokeRequired)
            {
                treeview.Invoke(mi);
            }
            else
            {
                mi();
            }
        }
Ejemplo n.º 8
0
        public static void AddNode(TreeView treeview, TreeNode node)
        {
            MethodInvoker mi = delegate
            {
                treeview.Nodes.Add(node);
            };

            if (treeview.InvokeRequired)
            {
                treeview.Invoke(mi);
            }
            else
            {
                mi();
            }
        }
Ejemplo n.º 9
0
        private void tree_UpdateLogicalExplorer(AIONode node)
        {
            TreeNode treenode = new TreeNode();

            tree.CopyNodeInfo(treenode, node);
            //Make container
            node.container = treenode;

            AIONode  parent     = tree.GetParent(node);
            TreeNode parentnode = (TreeNode)parent.container;

            tree.FillOneLevelNode(treenode, node);
            //Insert to treeView
            //InsertNode(parentnode, treenode);
            //Marshall to STA thread
            treeView1.Invoke(new InsertNodeDele(InsertNode), new object[] { parentnode, treenode });
        }
Ejemplo n.º 10
0
        public static TreeNodeCollection GetNodes(TreeView treeview)
        {
            TreeNodeCollection collection = null;

            MethodInvoker mi = delegate
            {
                collection = treeview.Nodes;
            };

            if (treeview.InvokeRequired)
            {
                treeview.Invoke(mi);
            }
            else
            {
                mi();
            }

            return collection;
        }
Ejemplo n.º 11
0
        public static void Sort(TreeView treeview, IComparer nodeSorter)
        {
            MethodInvoker mi = delegate
            {
                treeview.TreeViewNodeSorter = nodeSorter;
                treeview.Sort();
            };

            if (treeview.InvokeRequired)
            {
                treeview.Invoke(mi);
            }
            else
            {
                mi();
            }
        }
Ejemplo n.º 12
0
        public static void loadTreeViewWithDirectoriesAndFiles(TreeView tvTargetTreeView, String sDirectoryToProcess,
                                                               String sFileFilter, TextBox tbCurrentLoadedDirectory,
                                                               bool bShowFileSize, bool hideFiles)
        {
            try
            {
                if (tvTargetTreeView.InvokeRequired)
                    tvTargetTreeView.Invoke(
                        new EventHandler(
                            delegate
                                {
                                    loadTreeViewWithDirectoriesAndFiles(tvTargetTreeView, sDirectoryToProcess,
                                                                        sFileFilter, tbCurrentLoadedDirectory,
                                                                        bShowFileSize, hideFiles);
                                }));
                else
                {
                    if (sDirectoryToProcess != "")
                    {
                        tvTargetTreeView.Visible = false;
                        tvTargetTreeView.Nodes.Clear();
                        String sPreviousDirectory = Path.GetFullPath(Path.Combine(sDirectoryToProcess, ".."));
                        if (Directory.Exists(sPreviousDirectory))
                            tvTargetTreeView.Nodes.Add(newTreeNode("..", sPreviousDirectory, 2, sPreviousDirectory));

                        foreach (String sDirectory in Directory.GetDirectories(sDirectoryToProcess))
                        {
                            tvTargetTreeView.Nodes.Add(newTreeNode(Path.GetFileName(sDirectory), sDirectory, 0,
                                                                   sDirectory));
                        }

                        foreach (String sFile in Directory.GetFiles(sDirectoryToProcess, sFileFilter))
                        {
                            if (hideFiles)
                            {
                                var newNode = newTreeNode(Path.GetFileName(sFile), null, 1, null);
                                newNode.ForeColor = Color.Gray;
                                tvTargetTreeView.Nodes.Add(newNode);
                            }
                            else
                            {
                                if (bShowFileSize)
                                    tvTargetTreeView.Nodes.Add(
                                        newTreeNode(
                                            String.Format("{0}     :     {1}k", Path.GetFileName(sFile),
                                                          Files.getFileSize(Path.Combine(sDirectoryToProcess, sFile)) / 1024),
                                            sFile, 1, sFile));
                                else
                                    tvTargetTreeView.Nodes.Add(newTreeNode(Path.GetFileName(sFile), sFile, 1, sFile));
                            }
                        }
                        tvTargetTreeView.Visible = true;

                        //   if (null != lCurrentLoadedDirectory)
                        //       lCurrentLoadedDirectory.Text = Path.GetFileName(sDirectoryToProcess);
                    }
                    else
                        PublicDI.log.error(
                            "in loadTreeViewWithDirectoriesAndFiles, sDirectoryToProcess != \"\", this value must be provided");
                }               
            }
            catch (Exception ex)
            {
                PublicDI.log.error("in loadTreeViewWithDirectoriesAndFiles: {0}", ex.Message);
            }
        }
Ejemplo n.º 13
0
 private void DeleteTreeRootNode(TreeView treeView, TreeNode tNode)
 {
     if (this.InvokeRequired)
     {
         DeleteTreeRootNodeDelegate d = new DeleteTreeRootNodeDelegate(DeleteTreeRootNode);
         treeView.Invoke(d, treeView, tNode);
     }
     else
     {
         treeView.Nodes.Remove(tNode);
     }
 }
Ejemplo n.º 14
0
 TreeNode opmlRetriever_AddNodeToNodeWithText(TreeNode treeNode, string strNode)
 {
     return((TreeNode)OPMLTreeView.Invoke(new AddTreeNodeWithText(treeNode.Nodes.Add), new object[] { strNode }));
 }
Ejemplo n.º 15
0
        static void ConnectCompleted(SSBIServer serv, Server srv, TreeView tv, TreeNode tn, bool success, string msg)
        {
            if (tv.InvokeRequired) {
            tv.Invoke(new ConnectCompletedDelegate(ConnectCompleted), new object[] { serv, srv, tv, tn, success, msg });
              }
              else {

            try {
              if (success) {
            serv.HasLoggedIn = true;
            serv.SMOServer = srv;
            serv.IsTryingToConnect = false;
            tn.Tag = serv;
            if (tn == tv.SelectedNode) {
              tn.Expand();
            }
              }
              else {
            MessageBox.Show(msg);
              }

            }

            catch (FailedOperationException fe) {
              smo.ShowException(fe);

            }

            catch (Exception e) {
              smo.ShowException(e);

            }

            finally {
              //connNode = null;
              tn.ForeColor = Color.Black;
              //toolStripStatusLabel1.Text = "Ready!";
              serv.IsTryingToConnect = false;
              tn.Tag = serv;
              tn.Text = serv.Name;
            }

              }
        }
Ejemplo n.º 16
0
 // Dont call this one!!
 private void _GetNodesFromFuncAndPostToTreeView(List<string> exts, TreeView tv)
 {
     TreeNode tr = null;
     ParameterizedThreadStart starter = new ParameterizedThreadStart(obj => PopulateRootTreeFiles(exts, ref tr));
     Thread process = new Thread(starter);
     process.Start();
     process.Join();
     tv.Invoke(new Action<TreeNode, TreeView>(InsertNodeIntoTree), new object[] {tr, tv});
 }
Ejemplo n.º 17
0
 public void ClearTreeViewNodes(TreeView tv)
 {
     if (tv.InvokeRequired)
     {
         tv.Invoke(new Action<TreeView>(ClearTreeViewNodes), new object[] {tv});
     }
     else
     {
         tv.Nodes.Clear();
     }
 }
Ejemplo n.º 18
0
 private void AddTreeRootNode(TreeView treeView, TreeNode tNode)
 {
     if (this.InvokeRequired)
     {
         AddTreeRootNodeDelegate d = new AddTreeRootNodeDelegate(AddTreeRootNode);
         treeView.Invoke(d, treeView, tNode);
     }
     else
     {
         treeView.Nodes.Add(tNode);
     }
 }
 public void PopulateChildTree(TreeView tree,TestTreeNodeFacade facade)
 {
     foreach(TreeTestDomain td in this.list)
     {
         UnitTreeNode node = this.factory.CreateUnitTreeNode(
             td.TestTree.ParentNode.Name,
             TestNodeType.Populator,
             td.Identifier,
             td.TestTree.ParentNode.Identifier
             );
         tree.Invoke(new AddNodeDelegate(tree.Nodes.Add),new Object[]{node});
         td.PopulateChildTree(node,facade);
     }
 }
Ejemplo n.º 20
0
        public static TreeNode GetSelectedNode(TreeView treeview)
        {
            TreeNode node = null;

            MethodInvoker mi = delegate
            {
                node = treeview.SelectedNode;
            };

            if (treeview.InvokeRequired)
                treeview.Invoke(mi);
            else
                mi();

            return node;
        }
Ejemplo n.º 21
0
        private void ImportDataCard(string datacardPath, string initializeString, TreeView treeView)
        {
            _treeView = treeView;

            Task.Run(() =>
            {
                _updateStatusAction(CurrentState, "Starting Import");

                ApplicationDataModels = _dataProvider.Import(datacardPath, initializeString);
                if (ApplicationDataModels == null || ApplicationDataModels.Count == 0)
                {
                    MessageBox.Show(@"Not supported data format.");
                    CurrentState = State.StateIdle;
                    _updateStatusAction(CurrentState, "Done");
                    return;
                }

                _admIndex = 0;
                for (; _admIndex < ApplicationDataModels.Count; _admIndex++)
                {
                    var applicationDataModel = ApplicationDataModels[_admIndex];

                    applicationDataModel.Documents.LoggedData.SelectMany(x => x.OperationData.ToList()).ToList();
                    
                    var parentNode = (TreeNode)_treeView.Invoke(new Func<TreeNode>(() => treeView.Nodes.Add("ApplicationDataModel")));

                    AddNode(applicationDataModel, parentNode);
                }
                
                CurrentState = State.StateIdle;
                _updateStatusAction(CurrentState, "Done");
                
            });

            
        }
Ejemplo n.º 22
0
 public static void SelectTreeNode(TreeView tree, TreeNode node)
 {
     if (tree.InvokeRequired)
     {
         var d = new SelectTreeNodeCallback(SelectTreeNode);
         tree.Invoke(d, new object[] { tree, node });
     }
     else
     {
         tree.SelectedNode = node;
     }
 }
Ejemplo n.º 23
0
 private void ClearTreeNodes(TreeView treeView)
 {
     if (this.InvokeRequired)
     {
         ClearTreeNodesDelegate d = new ClearTreeNodesDelegate(ClearTreeNodes);
         treeView.Invoke(d, treeView);
     }
     else
     {
         treeView.Nodes.Clear();
     }
 }