private void FindAndClickExistingTab() { var found = false; if (this.TabContainer.Items.Count > 1) { var indexForNewItem = 0; foreach (var item in this.TabContainer.Items) { if (item is ToolStripButton) { var castedItem = (ToolStripButton)item; if (castedItem.Name.StartsWith("Tab")) { castedItem.PerformClick(); found = true; break; } } indexForNewItem++; } } if (!found) { ExitToolStripMenuItem.PerformClick(); } }
/// <summary> /// 初始化Toolbar /// </summary> private void InitToolBar() { ExpandAllConnectionToolStripButton = ExpandAllConnectionToolStripMenuItem.CloneFromMenuItem(); CollapseAllConnectionToolStripButton = CollapseAllConnectionToolStripMenuItem.CloneFromMenuItem(); RefreshToolStripButton = RefreshToolStripMenuItem.CloneFromMenuItem(); ExitToolStripButton = ExitToolStripMenuItem.CloneFromMenuItem(); OptionToolStripButton = OptionsToolStripMenuItem.CloneFromMenuItem(); UserGuideToolStripButton = UserGuideToolStripMenuItem.CloneFromMenuItem(); if (SystemManager.MonoMode) { ExpandAllConnectionToolStripButton.Click += ExpandAllToolStripMenuItem_Click; CollapseAllConnectionToolStripButton.Click += CollapseAllToolStripMenuItem_Click; RefreshToolStripButton.Click += RefreshToolStripMenuItem_Click; ExitToolStripButton.Click += ExitToolStripMenuItem_Click; OptionToolStripButton.Click += OptionToolStripMenuItem_Click; UserGuideToolStripButton.Click += userGuideToolStripMenuItem_Click; } //Main ToolTip toolStripMain.Items.Add(ExpandAllConnectionToolStripButton); toolStripMain.Items.Add(CollapseAllConnectionToolStripButton); toolStripMain.Items.Add(RefreshToolStripButton); toolStripMain.Items.Add(ExitToolStripButton); toolStripMain.Items.Add(new ToolStripSeparator()); toolStripMain.Items.Add(OptionToolStripButton); toolStripMain.Items.Add(UserGuideToolStripButton); }
private void ExitNotifyIcon_Click(object sender, EventArgs e) { ExitToolStripMenuItem.PerformClick(); }