Esempio n. 1
0
        public AssemblyTreeFile FindFile(ScriptFile sf)
        {
            AssemblyTreeFile file = null;

            foreach (AssemblyTreeFile f in _globalFiles)
            {
                if (f.SF == sf)
                {
                    return(f);
                }
            }

            foreach (AssemblyTreeFile f in _files)
            {
                if (f.SF == sf)
                {
                    return(f);
                }
            }

            foreach (AssemblyTreeFolder f in _folders)
            {
                file = f.FindFile(sf);
                if (file != null)
                {
                    return(file);
                }
            }

            return(null);
        }
Esempio n. 2
0
        public void UpdateAssemblyTree(List <IReferenceInfo> references, IMemberInfo definition)
        {
            this.assemblyTreeView.Type = AssemblyTreeType.References;
            this.searchTextBox.Text    = referencesText;

            this.assemblyTreeView.ClearNodes();

            #region Add definition to tree
            AssemblyTreeFile file = this.assemblyTreeView.FindFile(definition.SF);
            if (file == null)
            {
                file = new AssemblyTreeFile(definition.SF);
                this.assemblyTreeView.Add(file);
            }
            file.Add(new AssemblyTreeMember(definition));
            #endregion

            #region Add references to tree
            foreach (IReferenceInfo refI in references)
            {
                file = this.assemblyTreeView.FindFile(refI.SF);
                if (file == null)
                {
                    file = new AssemblyTreeFile(refI.SF);
                    this.assemblyTreeView.Add(file);
                }

                file.Add(new AssemblyTreeMember(refI));
            }
            #endregion

            this.assemblyTreeView.CurrentNode = null;
            this.assemblyTreeView.RefreshNodes();
        }
Esempio n. 3
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;
            }
        }
Esempio n. 4
0
        private void UpdateSearchResults(bool changedControlText)
        {
            string searchText = searchTextBox.Text.ToUpper();

            if (!changedControlText && this.assemblyTreeView.Type == assemblyTreeView.LastType)
            {
                return;
            }

            this.assemblyTreeView.ClearNodes();

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

                if (sf.SecondSI != null)
                {
                    foreach (UsingInfo u in sf.SecondSI.Usings)
                    {
                        if (u.Name.ToUpper().Contains(searchText))
                        {
                            file.Add(new AssemblyTreeMember(u));
                            isEmpty = false;
                        }
                    }

                    foreach (ConstInfo c in sf.SecondSI.Constants)
                    {
                        if (c.Name.ToUpper().Contains(searchText))
                        {
                            file.Add(new AssemblyTreeMember(c));
                            isEmpty = false;
                        }
                    }

                    foreach (FuncInfo f in sf.SecondSI.Functions)
                    {
                        if (f.Name.ToUpper().Contains(searchText))
                        {
                            file.Add(new AssemblyTreeMember(f));
                            isEmpty = false;
                        }
                    }
                }

                if (!isEmpty)
                {
                    this.assemblyTreeView.Add(file);
                }
            }

            this.assemblyTreeView.CurrentNode = null;
            this.assemblyTreeView.RefreshNodes();
        }
Esempio n. 5
0
        public void SelectMemberInTree(IReferenceInfo refInfo)
        {
            AssemblyTreeFile file = this.assemblyTreeView.FindFile(refInfo.SF);

            if (file != null)
            {
                AssemblyTreeMember m = file.Find(refInfo);

                this.assemblyTreeView.CurrentNode = m;
                this.assemblyTreeView.RefreshSelectedNode(false);
            }
        }
Esempio n. 6
0
        public void SelectMemberInTree(IMemberInfo member)
        {
            AssemblyTreeFile file = this.assemblyTreeView.FindFile(member.SF);

            if (file != null)
            {
                AssemblyTreeMember m = file.Find(member);

                this.assemblyTreeView.CurrentNode = m;
                this.assemblyTreeView.RefreshSelectedNode(false);
            }
        }
Esempio n. 7
0
 public void OpenFile(AssemblyTreeFile fileNode)
 {
     if (!String.IsNullOrEmpty(fileNode.SF.SFFullPath))
     {
         Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_DOOPEN, 0, fileNode.SF.SFFullPath);
         Win32.SendMessage(PluginBase.GetCurrentScintilla(), SciMsg.SCI_GRABFOCUS, 0, 0);
     }
     else
     {
         MessageBox.Show("Cannot open file '" + fileNode.SF.SFPath + "'");
     }
 }
Esempio n. 8
0
        public FileContextMenuStrip(AssemblyTreeFile file, ScriptFile sf)
        {
            _file = file;
            _sf   = sf;

            ToolStripMenuItem fileOpen = new ToolStripMenuItem("Open File");

            fileOpen.Click += new EventHandler(fileOpen_Click);

            ToolStripMenuItem fileCopy = new ToolStripMenuItem("Copy");

            fileCopy.Click += new EventHandler(fileCopy_Click);

            this.Items.AddRange(new ToolStripMenuItem[] { fileOpen, fileCopy });
        }
Esempio n. 9
0
        public void Add(AssemblyTreeFile file)
        {
            if (file.SF.SI != null && file.SF.SI.IsGlobal)
            {
                _globalFiles.Add(file);
            }
            else
            {
                _files.Add(file);
            }

            file.ParentFolder = this;

            anyUpdate = true;
        }
Esempio n. 10
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;
            }
        }
Esempio n. 11
0
        public void Remove(AssemblyTreeFile file)
        {
            int i = _files.IndexOf(file);

            if (i != -1)
            {
                _files.RemoveAt(i);
            }
            else
            {
                i = _globalFiles.IndexOf(file);
                if (i != -1)
                {
                    _globalFiles.RemoveAt(i);
                }
            }

            anyUpdate = true;
        }
Esempio n. 12
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);
        }
Esempio n. 13
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);
            }
        }
Esempio n. 14
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;
            }
        }