protected void OnPageDragStart(object sender, MouseEventArgs e) { if (this.RedockAllowed) { // There must be a selected page for this event to occur Magic.Controls.TabPage page = _tabControl.SelectedTab; // Event page must specify its Content object Content c = page.Tag as Content; // Remember the position of the tab before it is removed _dragPageIndex = _tabControl.TabPages.IndexOf(page); // Remove page from TabControl _tabControl.TabPages.Remove(page); // Force the entire window to redraw to ensure the Redocker does not start drawing // the XOR indicator before the window repaints itself. Otherwise the repainted // control will interfere with the XOR indicator. this.Refresh(); // Start redocking activity for the single Content of this WindowContent _redocker = new RedockerContent(_tabControl, c, this, new Point(e.X, e.Y)); } }
public void HideCurrentContent() { Magic.Controls.TabPage tp = _tabControl.SelectedTab; int count = _tabControl.TabPages.Count; // Find currently selected tab int index = _tabControl.SelectedIndex; // Decide which other tab to make selected instead if (count > 1) { // Move to the next control along int newSelect = index + 1; // Wrap around to first tab if at end if (newSelect == count) { newSelect = 0; } // Change selection _tabControl.SelectedIndex = newSelect; } else { // Hide myself as am about to die this.Hide(); // Ensure the focus goes somewhere else _manager.Container.Focus(); } if (tp != null) { Content c = tp.Tag as Content; // Have the manager perform the Hide operation for us _manager.HideContent(c); // Do we also remove the content? if (c.CloseOnHide) { // Remove the content from the collection _manager.Contents.Remove(c); // Dispose of the contained control/form if (c.Control != null) { c.Control.Dispose(); } } } }
protected void OnDoubleClickTab(Magic.Controls.TabControl tc, Magic.Controls.TabPage page) { Content c = (Content)page.Tag; // Make Content record its current position and remember it for the future c.RecordRestore(); // Invert docked status c.Docked = (c.Docked == false); // Remove from current WindowContent and restore its position _manager.HideContent(c, false, true); _manager.ShowContent(c); }
protected override void OnContentInserted(int index, object value) { base.OnContentInserted(index, value); Content content = value as Content; // Create TabPage to represent the Content Magic.Controls.TabPage newPage = new Magic.Controls.TabPage(); // Reflect the Content properties int the TabPage newPage.Title = content.Title; newPage.ImageList = content.ImageList; newPage.ImageIndex = content.ImageIndex; newPage.Icon = content.Icon; newPage.Control = content.Control; newPage.Tag = content; // Reflect same order in TabPages collection as Content collection _tabControl.TabPages.Insert(index, newPage); }
protected void RestoreDraggingPage() { // Create TabPage to represent the Content Magic.Controls.TabPage newPage = new Magic.Controls.TabPage(); Content content = _redocker.Content; // Reflect the Content properties int the TabPage newPage.Title = content.Title; newPage.ImageList = content.ImageList; newPage.ImageIndex = content.ImageIndex; newPage.Icon = content.Icon; newPage.Control = content.Control; newPage.Tag = content; newPage.Selected = true; // Put it back where it came from _tabControl.TabPages.Insert(_dragPageIndex, newPage); // Update the title displayed NotifyFullTitleText(content.FullTitle); }