Пример #1
0
        private void AssemblyTreeView_BeforeCollapse(object sender, TreeViewCancelEventArgs e)
        {
            AssemblyTreeFolder folder = e.Node as AssemblyTreeFolder;

            if (folder != null)
            {
                folder.Nodes.Clear();
                if (folder.HasChildren)
                {
                    folder.Nodes.Add("FakeNode");
                }

                return;
            }

            AssemblyTreeFile file = e.Node as AssemblyTreeFile;

            if (file != null)
            {
                file.Nodes.Clear();
                if (file.HasChildren)
                {
                    file.Nodes.Add("FakeNode");
                }

                return;
            }
        }
Пример #2
0
        public void Add(AssemblyTreeFolder folder)
        {
            _folders.Add(folder);

            folder.ParentFolder = this;

            anyUpdate = true;
        }
Пример #3
0
        private void AssemblyTreeView_BeforeExpand(object sender, TreeViewCancelEventArgs e)
        {
            AssemblyTreeFolder folder = e.Node as AssemblyTreeFolder;

            if (folder != null)
            {
                folder.Refresh();
                return;
            }

            AssemblyTreeFile file = e.Node as AssemblyTreeFile;

            if (file != null)
            {
                file.Refresh();
                return;
            }
        }
Пример #4
0
        public void Add(AssemblyTreeFile file)
        {
            AssemblyTreeFolder curFolder = rootFolder;

            if (!String.IsNullOrEmpty(file.Path))
            {
                AssemblyTreeFolder parentFolder = rootFolder;

                string[] folders = file.Path.Split('\\');
                foreach (string folderName in folders)
                {
                    curFolder = parentFolder.FindFolder(folderName);
                    if (curFolder == null)
                    {
                        curFolder = new AssemblyTreeFolder(folderName);
                        parentFolder.Add(curFolder);
                    }

                    parentFolder = curFolder;
                }
            }

            curFolder.Add(file);
        }
Пример #5
0
        private void UpdateClassicTree()
        {
            try
            {
                // update complete tree
                if (assemblyTreeView.LastType != AssemblyTreeType.Classic)
                {
                    this.assemblyTreeView.ClearNodes();
                    AssemblyTreeFile curFile = null;

                    foreach (ScriptFile sf in this.fileManager.ScriptManager.GetAllSFs())
                    {
                        AssemblyTreeFile file = new AssemblyTreeFile(sf);

                        if (sf == this.fileManager.CurrentFile)
                        {
                            curFile = file;
                        }

                        if (sf.SecondSI != null)
                        {
                            foreach (UsingInfo u in sf.SecondSI.Usings)
                            {
                                file.Add(new AssemblyTreeMember(u));
                            }

                            foreach (ConstInfo c in sf.SecondSI.Constants)
                            {
                                file.Add(new AssemblyTreeMember(c));
                            }

                            foreach (FuncInfo f in sf.SecondSI.Functions)
                            {
                                file.Add(new AssemblyTreeMember(f));
                            }
                        }

                        this.assemblyTreeView.Add(file);
                    }

                    this.assemblyTreeView.CurrentNode = curFile;
                    this.assemblyTreeView.RefreshNodes();
                }
                else // update only changed sfs
                {
                    // TODO: update informácií v strome po aktualizácii

                    //this.assemblyTreeView.ClearNodes();
                    AssemblyTreeFile  curFile      = null;
                    List <ScriptFile> updatedFiles = this.fileManager.ThreadedSM.CurrentUpdatedFiles.Clear();

                    foreach (ScriptFile sf in updatedFiles)
                    {
                        Main.Trace.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 0, "TREE - Updating file " + sf.ToString());

                        AssemblyTreeFile file = this.assemblyTreeView.FindFile(sf);
                        if (file != null)
                        {
                            AssemblyTreeFolder folder = file.ParentFolder;
                            folder.Remove(file);
                            file = new AssemblyTreeFile(sf);
                            folder.Add(file);
                        }
                        else
                        {
                            file = new AssemblyTreeFile(sf);
                            this.assemblyTreeView.Add(file);
                        }

                        if (sf == this.fileManager.CurrentFile)
                        {
                            curFile = file;
                        }

                        if (sf.SecondSI != null)
                        {
                            foreach (UsingInfo u in sf.SecondSI.Usings)
                            {
                                file.Add(new AssemblyTreeMember(u));
                            }

                            foreach (ConstInfo c in sf.SecondSI.Constants)
                            {
                                file.Add(new AssemblyTreeMember(c));
                            }

                            foreach (FuncInfo f in sf.SecondSI.Functions)
                            {
                                file.Add(new AssemblyTreeMember(f));
                            }
                        }
                    }

                    this.assemblyTreeView.CurrentNode = curFile;
                    this.assemblyTreeView.RefreshNodes();
                }
            }
            catch (Exception e)
            {
                Main.NotifyError(e);
            }
        }
Пример #6
0
 public void ClearNodes()
 {
     rootFolder = new AssemblyTreeFolder(true);
 }
Пример #7
0
        /// <summary>
        /// Expand node and all his parents and collapse lastNode and all his parents
        /// </summary>
        /// <param name="node">TreeNode to expand</param>
        /// <param name="lastNode">TreeNode to collapse</param>
        private void ExpandNodeRecursive(TreeNode curNode, TreeNode lastNode)
        {
            // DO THE MAGIC :)

            AssemblyTreeMember curMember  = curNode as AssemblyTreeMember;
            AssemblyTreeMember lastMember = lastNode as AssemblyTreeMember;

            if (curMember != null && lastMember != null)
            {
                if (curMember != lastMember)
                {
                    ExpandNodeRecursive(curMember.ParentFile, lastMember.ParentFile);
                }

                return;
            }
            else if (curMember != null)
            {
                ExpandNodeRecursive(curMember.ParentFile, lastNode);
                return;
            }
            else if (lastMember != null)
            {
                ExpandNodeRecursive(curNode, lastMember.ParentFile);
                return;
            }

            AssemblyTreeFile curFile  = curNode as AssemblyTreeFile;
            AssemblyTreeFile lastFile = lastNode as AssemblyTreeFile;

            if (curFile != null && lastFile != null)
            {
                if (curFile != lastFile)
                {
                    Main.Trace.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 0, "Collapsing " + lastFile.Text);
                    lastFile.Collapse();

                    ExpandNodeRecursive(curFile.ParentFolder, lastFile.ParentFolder);

                    Main.Trace.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 0, "Expanding " + curFile.Text);
                    curFile.Expand();
                }
                else
                {
                    if (!curFile.IsExpanded)
                    {
                        Main.Trace.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 0, "Expanding " + curFile.Text);
                        curFile.Expand();
                    }
                }
                return;
            }
            else if (curFile != null)
            {
                ExpandNodeRecursive(curFile.ParentFolder, lastNode);

                Main.Trace.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 0, "Expanding " + curFile.Text);
                curFile.Expand();
                return;
            }
            else if (lastFile != null)
            {
                Main.Trace.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 0, "Collapsing " + lastFile.Text);
                lastFile.Collapse();

                ExpandNodeRecursive(curNode, lastFile.ParentFolder);
                return;
            }

            AssemblyTreeFolder curFolder  = curNode as AssemblyTreeFolder;
            AssemblyTreeFolder lastFolder = lastNode as AssemblyTreeFolder;

            if (curFolder != null && !curFolder.IsRootFolder &&
                lastFolder != null && !lastFolder.IsRootFolder)    // collapse last, expand current
            {
                //if (curFolder != lastFolder) // has not expanded yet
                //{
                if (curFolder.Level > lastFolder.Level)
                {
                    ExpandNodeRecursive(curFolder.ParentFolder, lastFolder);

                    if (!curFolder.IsExpanded)
                    {
                        Main.Trace.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 0, "Expanding " + curFolder.Text);
                        curFolder.Expand();
                    }
                }
                else if (curFolder.Level < lastFolder.Level)
                {
                    Main.Trace.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 0, "Collapsing " + lastFolder.Text);
                    lastFolder.Collapse();

                    ExpandNodeRecursive(curFolder, lastFolder.ParentFolder);
                }
                else
                {
                    if (curFolder != lastFolder)
                    {
                        Main.Trace.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 0, "Collapsing " + lastFolder.Text);
                        lastFolder.Collapse();
                    }

                    ExpandNodeRecursive(curFolder.ParentFolder, lastFolder.ParentFolder);

                    if (!curFolder.IsExpanded)
                    {
                        Main.Trace.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 0, "Expanding " + curFolder.Text);
                        curFolder.Expand();
                    }
                }
                //}
                return;
            }
            else if (curFolder != null && !curFolder.IsRootFolder) // expand current
            {
                ExpandNodeRecursive(curFolder.ParentFolder, lastNode);

                Main.Trace.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 0, "Expanding " + curFolder.Text);
                curFolder.Expand();
                return;
            }
            else if (lastFolder != null && !lastFolder.IsRootFolder) // collapse last
            {
                Main.Trace.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 0, "Collapsing " + lastFolder.Text);
                lastFolder.Collapse();

                ExpandNodeRecursive(curNode, lastFolder.ParentFolder);
                return;
            }
        }