Exemplo n.º 1
0
        public void removeProcessTab(ProcessTab pt)
        {
            // loop through the tab pages and find the one with the given ProcessTab;
            // then remove it
            for (int i = 1; i < tabControl1.TabCount; i++)
            {
                if (tabControl1.TabPages[i].Controls.Contains(pt))
                {
                    tabControl1.TabPages.RemoveAt(i);
                    openTabs.Remove(pt);
                }
            }

            if (!ProcessWatcher.getInstance().isWatching(pt.procName))
            {
                for (int i = 0; i < procListView.Items.Count; i++)
                {
                    if (procListView.Items[i].SubItems[1].Text == pt.procName)
                    {
                        procListView.Items[i].SubItems[3].Text = "No";
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void addProcessTab(string procName, string userProcName, bool goToNewTab)
        {
            try
            {
                if (!isTabOpen(procName))
                {
                    this.BeginInvoke((Action)(() =>
                    {
                        ProcessTab newTab = new ProcessTab(procName, userProcName, this);
                        TabPage newPage = new TabPage(userProcName);
                        newTab.Dock = DockStyle.Fill;
                        newPage.Controls.Add(newTab);
                        tabControl1.Controls.Add(newPage);

                        openTabs.Add(newTab);

                        for (int i = 0; i < procListView.Items.Count; i++)
                        {
                            if (procListView.Items[i].SubItems[1].Text == procName)
                            {
                                procListView.Items[i].SubItems[3].Text = "Yes";
                            }
                        }

                        if (goToNewTab)
                        {
                            tabControl1.SelectedIndex = tabControl1.TabPages.IndexOf(newPage);
                        }
                    }));
                }
            }
            catch (Exception e)
            {
                //MessageBox.Show(e.Message + "\n" + e.StackTrace);
            }
        }