Example #1
0
 public virtual void Remove(PrimaryTab <T> entry)
 {
     if (this.List.Contains(entry))
     {
         this.List.Remove(entry);
     }
 }
Example #2
0
        }                                               // Blank constructor

        public virtual void Add(PrimaryTab <T> entry)
        {
            if (!this.List.Contains(entry))
            {
                // Handle addition to sorted tabs listing
                g.SortedTabList.Add(new SortedTab(entry.page, 37000));
                this.List.Add(entry);
            }
        }
Example #3
0
        public static void FocusEnvironmentTab(Control Tab)
        {
            PrimaryTab <Control> tab = g.OtherTabs.FindByControl(Tab);

            if (tab == null)
            {
                return;
            }

            tab.page.Selected = true;
        }
Example #4
0
        public static void UpdateEnvironmentTab(Control Tab, string SetTabTextTo, int SetTabIconTo)
        {
            PrimaryTab <Control> tab = g.OtherTabs.FindByControl(Tab);

            if (tab == null)
            {
                return;
            }

            tab.page.Title      = SetTabTextTo;
            tab.page.ImageIndex = SetTabIconTo;
        }
Example #5
0
        public static void DeregisterEnvironmentTab(Control Tab)
        {
            PrimaryTab <Control> tab = g.OtherTabs.FindByControl(Tab);

            if (tab == null)
            {
                return;
            }

            // Remove its thing from the tabs
            g.Main.CloseTab <Control>(tab);

            // Remove it from the registry
            g.OtherTabs.Remove(tab);
        }
Example #6
0
        private void lvWindows_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvWindows.SelectedItems.Count > 0)
            {
                lvWindows.SelectedItems[0].EnsureVisible();

                SortedTab tab = (SortedTab)g.SortedTabList[lvWindows.SelectedItems[0].Index];

                if (tab.Page.Control is UCEditor)
                {
                    lblWindowType.Text  = "TorqueScript Code Window";
                    lblWindowLine1.Text = (tab.Page.Control as UCEditor).g_curFile.SimpleName;
                    lblWindowLine2.Text = System.IO.Path.GetFullPath((tab.Page.Control as UCEditor).g_curFile.RelativePath);
                }
                else if (tab.Page.Control is UCBrowser)
                {
                    lblWindowType.Text  = "Browser Window";
                    lblWindowLine1.Text = (tab.Page.Control as UCBrowser).wb.DocumentTitle;
                    lblWindowLine2.Text = (tab.Page.Control as UCBrowser).wb.Document.Url.ToString();
                }
                else
                {
                    PrimaryTab <Control> plugin = g.OtherTabs.FindByControl(tab.Page.Control);

                    if (plugin == null)
                    {
                        lblWindowType.Text  = "Plugin Window";
                        lblWindowLine1.Text = "";
                        lblWindowLine2.Text = "";
                    }
                    else
                    {
                        lblWindowType.Text  = "Plugin Window";
                        lblWindowLine1.Text = plugin.plugin.CWPluginGuid.ToString();
                        lblWindowLine2.Text = "";
                    }
                }
            }
        }
Example #7
0
        /// <summary>
        /// Occurs when the button is clicked.
        /// </summary>
        /// <param name="sender">Sender of the event.</param>
        /// <param name="e">Event arguments.</param>
        private void findButton_Click(object sender, System.EventArgs e)
        {
            // Update find/replace options
            //if ((this.owner as UCEditor)._ParentTab.Selected != true)
            //	(this.owner as UCEditor)._ParentTab.Selected = true;

            this.UpdateFindReplaceOptions();

            if (editor == null && optEntireProject.Checked == false)
            {
                MessageBox.Show("No open windows.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            // Save this last search in the list
            if (!g.Project.Finds.Contains(findTextBox.Text))
            {
                // Remove old stuff
                if (g.Project.Finds.Count == 10)
                {
                    g.Project.Finds.RemoveAt(0);
                }

                g.Project.Finds.Add(findTextBox.Text);
                g.Main.cboRecentSearches.Text = findTextBox.Text;

                RehashRecent();
            }

            // Set the status
            //owner.SetStatusMessage("Find: \"" + options.FindText + "\"");
            if (this.optCurFile.Checked || this.optSelection.Checked)
            {
                // Perform find operation on currently open file
                FindReplaceResultSet resultSet = null;

                options.SearchInSelection = this.optSelection.Checked;

                try {
                    resultSet = editor.SelectedView.FindReplace.Find(options);
                } catch { return; }

                if (resultSet.PastEndOfDocument)
                {
                    MessageBox.Show(this, "Search past end of file; jumping to beginning.", "Find", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                if (resultSet.Count == 0)
                {
                    MessageBox.Show(this, "Cannot find search string.", "Find", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else if (this.optAllFiles.Checked)
            {
                // Perform search on all open files
                PrimaryTab <UCEditor> ed     = g.Editors[ActiveDocument];
                SyntaxEditor          actdoc = ed.Control.txtEditor;
                ed.page.Selected = true;

                FindReplaceResultSet resultSet = null;

                try {
                    resultSet = actdoc.SelectedView.FindReplace.Find(options);
                } catch { return; }

                if (resultSet.PastEndOfDocument || resultSet.Count == 0)
                {
                    if (g.Editors.Count == (ActiveDocument + 1))
                    {
                        MessageBox.Show(this, "All open files searched; jumping to beginning.", "Find", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        ActiveDocument = 0;
                        return;
                    }
                    else
                    {
                        ActiveDocument++;
                    }

                    if (resultSet.Count == 0)
                    {
                        findButton_Click(null, null);
                    }
                }
            }
            else if (this.optEntireProject.Checked)
            {
                // Perform search on all files
                UCFindResults fFindResults = new UCFindResults();
                fFindResults.lvFind.BeginUpdate();

                System.IO.Directory.SetCurrentDirectory(g.Project.ProjectPath);

                foreach (CProject.File file in g.Project.FileList)
                {
                    Document doc = new Document();
                    try {
                        doc.LoadFile(System.IO.Path.GetFullPath(file.RelativePath));
                    } catch { continue; }

                    FindReplaceResultSet results = doc.FindReplace.FindAll(options);

                    foreach (FindReplaceResult result in results)
                    {
                        ListViewItem item = new ListViewItem(file.RelativePath);
                        item.SubItems.Add(Convert.ToString(doc.OffsetToPosition(result.Offset).Line + 1));
                        item.SubItems.Add(doc.Lines[doc.OffsetToPosition(result.Offset).Line].Text);

                        item.Tag = file;
                        fFindResults.lvFind.Items.Add(item);
                    }

                    doc.Dispose();
                    doc = null;
                }

                fFindResults.lvFind.EndUpdate();

                g.Main.ShowFindResults(fFindResults);
                this.Close();
            }
        }
Example #8
0
        /// <summary>
        /// Occurs when the button is clicked.
        /// </summary>
        /// <param name="sender">Sender of the event.</param>
        /// <param name="e">Event arguments.</param>
        private void replaceButton_Click(object sender, System.EventArgs e)
        {
            //if ((owner as UCEditor)._ParentTab.Selected != true)
            //	(owner as UCEditor)._ParentTab.Selected = true;

            // Update find/replace options
            this.UpdateFindReplaceOptions();

            if (editor == null)
            {
                MessageBox.Show("No open windows.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (!g.Project.Finds.Contains(findTextBox.Text))
            {
                // Remove old stuff
                if (g.Project.Finds.Count == 10)
                {
                    g.Project.Finds.RemoveAt(0);
                }

                g.Project.Finds.Add(findTextBox.Text);
                g.Main.cboRecentSearches.Text = findTextBox.Text;

                RehashRecent();
            }

            if (!g.Project.Replaces.Contains(replaceTextBox.Text))
            {
                // Remove old replaces
                if (g.Project.Replaces.Count == 10)
                {
                    g.Project.Replaces.RemoveAt(0);
                }

                g.Project.Replaces.Add(replaceTextBox.Text);

                RehashRecent();
            }

            if (this.optCurFile.Checked || this.optSelection.Checked)
            {
                // Perform find operation on currently open file
                FindReplaceResultSet resultSet = null;

                options.SearchInSelection = this.optSelection.Checked;

                try {
                    resultSet = editor.SelectedView.FindReplace.Replace(options);
                } catch { return; }

                if (resultSet.PastEndOfDocument)
                {
                    MessageBox.Show(this, "Search past end of file; jumping to beginning.", "Find", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                if (resultSet.Count == 0)
                {
                    MessageBox.Show(this, "Cannot find search string.", "Find", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else if (this.optAllFiles.Checked)
            {
                // Perform search on all open files
                PrimaryTab <UCEditor> ed     = g.Editors[ActiveDocument];
                SyntaxEditor          actdoc = ed.Control.txtEditor;
                ed.page.Selected = true;

                FindReplaceResultSet resultSet = null;

                try {
                    resultSet = actdoc.SelectedView.FindReplace.Replace(options);
                } catch { return; }

                if (resultSet.PastEndOfDocument || resultSet.Count == 0)
                {
                    if (g.Editors.Count == (ActiveDocument + 1))
                    {
                        MessageBox.Show(this, "All open files searched; jumping to beginning.", "Find", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        ActiveDocument = 0;
                    }
                    else
                    {
                        ActiveDocument++;
                    }

                    if (resultSet.Count == 0)
                    {
                        replaceButton_Click(null, null);
                    }
                }
            }
        }