private void ButtonMaker(DiabloTab tab, GroupBox box) { // close, activate, abuse for (int i = 0; i < 4; i++) { Button b = new Button(); switch (i) { case 0: b.Text = "Activate Diablo"; b.Location = new Point(10, 20); break; case 1: b.Text = "Close Diablo"; b.Location = new Point(10, 50); break; case 2: b.Text = "Abuse Diablo"; b.Location = new Point(10, 80); break; case 3: b.Text = "Load Diablo"; b.Location = new Point(10, 110); break; } b.Tag = tab; box.Controls.Add(b); b.Click += B_Click; } }
private void B_Click(object sender, EventArgs e) { DiabloTab tab = (DiabloTab)((Button)sender).Tag; switch (((Button)sender).Text) { case "Activate Diablo": if (dhpActiveMain.DiabloWindow != null) { foreach (var item in tabControl1.TabPages) { if (item is DiabloTab && ((DiabloTab)item).Text == dhpActiveMain.DiabloWindow.Text) { dhpActiveMain.DiabloWindow.Deactivate(); ((DiabloHostPanel)((DiabloTab)item).Controls[0]).BindDiabloWindow(dhpActiveMain.DiabloWindow); ((DiabloHostPanel)((DiabloTab)item).Controls[0]).DiabloWindow.SetHostPanel(((DiabloHostPanel)((DiabloTab)item).Controls[0])); ((DiabloHostPanel)((DiabloTab)item).Controls[0]).DiabloWindow.Activate(); ((DiabloHostPanel)((DiabloTab)item).Controls[0]).RegisterEvents(); UpdateFlows(); break; } } } tab.DiabloWindow.Deactivate(); dhpActiveMain.BindDiabloWindow(tab.DiabloWindow); dhpActiveMain.DiabloWindow.SetHostPanel(dhpActiveMain); dhpActiveMain.DiabloWindow.Activate(); dhpActiveMain.RegisterEvents(); break; case "Close Diablo": UpdateFlows(); break; case "Abuse Diablo": // checkbox? break; case "Load Diablo": tab.LoadDiablo2(); UpdateFlows(); break; } }