private void AddPkgTab() { if (!VarGlobal.LessVerbose) { Console.WriteLine("AddPkgTab()"); } List <TabPage> TbgColl = new List <TabPage>(); foreach (ListViewItem item in listViewPckg.Items) { bool AlwaysHere = false; foreach (TabPage TbgPage in tabControl1.TabPages) { if (TbgPage.Name == item.Text) { //TbgPage.Dispose(); AlwaysHere = true; break; } } if (AlwaysHere == false) { TabPage NewTbg = new TabPage(item.Text); NewTbg.Name = item.Text; Ctrl.BuildPkg TheCtrl = new Ctrl.BuildPkg(item.Text, AllRepository); TheCtrl.Dock = DockStyle.Fill; NewTbg.Controls.Add(TheCtrl); TbgColl.Add(NewTbg); } } if (TbgColl.Count > 0) { tabControl1.TabPages.AddRange(ListToTabPage(TbgColl)); } }
private void AddAPkgTab(string PkgName) { bool AlwaysHere = false; foreach (TabPage TbgPage in tabControl1.TabPages) { if (TbgPage.Name == PkgName) { //TbgPage.Dispose(); AlwaysHere = true; break; } } if (AlwaysHere == false) { TabPage NewTbg = new TabPage(PkgName); NewTbg.Name = PkgName; NewTbg.ToolTipText = PkgName; //NewTbg.Paint += new PaintEventHandler(NewTbg_Paint); Ctrl.BuildPkg TheCtrl = new Ctrl.BuildPkg(PkgName, AllRepository); TheCtrl.Dock = DockStyle.Fill; NewTbg.Font = new Font("Microsoft Sans Serif", 9F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(0))); NewTbg.Controls.Add(TheCtrl); tabControl1.TabPages.Add(NewTbg); /*Button CloseBtn = new Button(); * CloseBtn.Text = "Close"; * this.Controls.Add(CloseBtn); * CloseBtn.Left = NewTbg.Left; * CloseBtn.Top = NewTbg.Top;*/ } tabControl1.SelectedTab = tabControl1.TabPages[PkgName]; }
private void CloseCurTab() { try { if (tabControl1.SelectedTab.Name != "TabPgMain") { VarGlobal.NetEvManager.DoSomething("Closing and cancelling trafic of : " + tabControl1.SelectedTab.Name); TabPage MemTabPge = tabControl1.SelectedTab; //FIXME : mono have a bug to remove a selected tabpage, they fix that in Rev r130931 tabControl1.SelectedIndex = 0; Ctrl.BuildPkg MemWorking = null; CloseTabToolStripMenuItem.Enabled = false; BtnCloseTab.Enabled = false; //((Ctrl.BuildPkg)MemTabPge.Controls[0]).CancelTrafic(); for (int ix = MemTabPge.Controls.Count - 1; ix >= 0; --ix) { Control ctl = MemTabPge.Controls[ix]; if (ctl is Ctrl.BuildPkg || ctl is Ctrl.BuildPkg) { MemWorking = (Ctrl.BuildPkg)MemTabPge.Controls[ix]; MemWorking.CancelTrafic(); } } if (MemTabPge != null) { if (tabControl1.TabPages.Contains(MemTabPge)) { tabControl1.TabPages.Remove(MemTabPge); } MemTabPge.Dispose(); } CloseTabToolStripMenuItem.Enabled = true; BtnCloseTab.Enabled = true; } } catch (Exception Ex) { if (!VarGlobal.LessVerbose) { Console.WriteLine("{0}{1}{2}", Ex.Message, Environment.NewLine, Ex.StackTrace); } } }