Exemplo n.º 1
0
        private void Page_Remove(TabPage _tab)
        {
            if (tabSet.TabPages.Count > 1)
            {
                UC_Page page = _tab.Tag as UC_Page;
                page.Stop();
                // page.Finallyze();
                page = null;

                int iCurPos  = tabSet.TabPages.IndexOf(_tab);
                int iLastPos = tabSet.TabPages.Count - 1;
                if (iCurPos == iLastPos)
                {
                    tabSet.SelectTab(iCurPos - 1);
                    tabSet.TabPages.RemoveAt(iCurPos);
                }
                else if (iCurPos < iLastPos)
                {
                    tabSet.TabPages.RemoveAt(iCurPos);
                    tabSet.SelectTab(iCurPos);
                }

                UpdateFormTitle(tabSet.SelectedTab.Text);
            }
        }
Exemplo n.º 2
0
        private void Page_AddNew()
        {
            TabPage tab  = new TabPage("(*)");
            UC_Page page = new UC_Page();

            page.OnFolderChanged += new UC_Page.OnFolderChangedDelegate(page_OnFolderChanged);
            page.Dock             = DockStyle.Fill;

            tab.Controls.Add(page);
            tab.Tag = page; // associate `tab.Tag` with hosted Page class, note that `page.Parent == tab`

            tabSet.Controls.Add(tab);
            tabSet.SelectedTab = tab;

            UpdateFormTitle(tab.Text);
        }
Exemplo n.º 3
0
        private void MainForm_KeyDown(object sender, KeyEventArgs e)
        {
            // My favorite feature implementation
            if (e.KeyCode == Keys.F11)
            {
                e.Handled = true;
                if (this.Opacity < 0.11d)
                {
                    return;
                }
                this.Opacity -= 0.1d;
            }
            else if (e.KeyCode == Keys.F12)
            {
                e.Handled     = true;
                this.Opacity += 0.1d;
            }
            // exit
            else if (e.KeyCode == Keys.Escape)
            {
                e.Handled = true;
        #if DEBUG
                Application.Exit();
        #endif
            }
            // about
            else if (e.KeyCode == Keys.F1)
            {
                e.Handled = true;
                string link = "http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx";

                DialogResult dlgResult = MessageBox.Show(
                    "More information available online at: \"" + link + "\"\nDo you want to Proceed?"
                    , Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (dlgResult == DialogResult.Yes)
                {
                    System.Diagnostics.Process proc = new System.Diagnostics.Process();
                    proc.StartInfo.FileName        = link;
                    proc.StartInfo.UseShellExecute = true;

                    proc.Start();
                }
            }
            else if (e.KeyCode == Keys.F5)
            {
                TabPage tab = tabSet.SelectedTab;
                if (null != tab && null != tab.Tag)
                {
                    UC_Page page = tab.Tag as UC_Page;
                    if (null != page)
                    {
                        page.btnLaunchSwitch_Click(sender, e);
                    }
                }
                e.Handled = true;
            }
            else if (e.Control && e.KeyCode == Keys.T)
            {
                e.Handled = true;
                Page_AddNew();
            }
            else if (e.Control && e.KeyCode == Keys.W)
            {
                e.Handled = true;
                Page_Remove(tabSet.SelectedTab);
            }
        }