// protected void OnPopupMenuDisplay(object sender, CancelEventArgs e) // { // // Remove all existing menu items // tabControl.ContextPopupMenu.MenuCommands.Clear(); // // // Add our standard set of menus // _tabControl.ContextPopupMenu.MenuCommands.AddRange(new MenuCommand[]{_mcClose, _mcSep1, // _mcProm, _mcReba, // _mcSep2, _mcHorz, // _mcVert, _mcNext, // _mcPrev}); // // // Are any pages selected // bool valid = (_tabControl.SelectedIndex != -1); // // // Define the latest text string // _mcClose.Text = _tabbedGroups.CloseMenuText; // _mcProm.Text = _tabbedGroups.ProminentMenuText; // _mcReba.Text = _tabbedGroups.RebalanceMenuText; // _mcPrev.Text = _tabbedGroups.MovePreviousMenuText; // _mcNext.Text = _tabbedGroups.MoveNextMenuText; // _mcVert.Text = _tabbedGroups.NewVerticalMenuText; // _mcHorz.Text = _tabbedGroups.NewHorizontalMenuText; // // // Only need to close option if the tab has close defined // _mcClose.Visible = _tabControl.ShowClose && valid; // _mcSep1.Visible = _tabControl.ShowClose && valid; // // // Update the radio button for prominent // _mcProm.Checked = (_tabbedGroups.ProminentLeaf == this); // // // Can only create new group if at least two pages exist // bool split = valid && (_tabControl.TabPages.Count > 1); // // bool vertSplit = split; // bool horzSplit = split; // // TabGroupSequence tgs = _parent as TabGroupSequence; // // // If we are not the only leaf, then can only split in // // the same direction as the group we are in // if (tgs.Count > 1) // { // if (tgs.Direction == Direction.Vertical) // vertSplit = false; // else // horzSplit = false; // } // // _mcVert.Visible = vertSplit; // _mcHorz.Visible = horzSplit; // // // Can only how movement if group exists in that direction // _mcNext.Visible = valid && (_tabbedGroups.NextLeaf(this) != null); // _mcPrev.Visible = valid && (_tabbedGroups.PreviousLeaf(this) != null); // // TGContextMenuEventArgs tge = new TGContextMenuEventArgs(this, // _tabControl, // _tabControl.SelectedTab, // _tabControl.ContextPopupMenu); // // // Generate event so handlers can add/remove/cancel menu // _tabbedGroups.OnPageContextMenu(tge); // // // Pass back cancel value // e.Cancel = tge.Cancel; // } // internal void OnClose(object sender, EventArgs e) { if(_tabControl.SelectedTab==null) { System.Diagnostics.Process.GetCurrentProcess().CloseMainWindow(); return; } TGCloseRequestEventArgs tge = new TGCloseRequestEventArgs(this, _tabControl, _tabControl.SelectedTab); // Generate event so handlers can perform appropriate action _tabbedGroups.OnPageCloseRequested(tge); // Still want to close the page? if (!tge.Cancel) _tabControl.TabPages.Remove(_tabControl.SelectedTab); }
public virtual void OnPageCloseRequested(TGCloseRequestEventArgs e) { // Has anyone registered for the event? if (PageCloseRequest != null) PageCloseRequest(this, e); }