protected void OnPageDragStart(object sender, MouseEventArgs e) { if (this.RedockAllowed) { // There must be a selected page for this event to occur ARMSim.GUI.DockingWindows.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() { ARMSim.GUI.DockingWindows.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 OnRemovedPage(int index, object value) { // Cast to correct type ARMSim.GUI.DockingWindows.Controls.TabPage page = value as ARMSim.GUI.DockingWindows.Controls.TabPage; // Grab the content instance of the page Content c = page.Tag as Content; // Unhook from change in its properties c.PropertyChanged -= new Content.PropChangeHandler(OnContentChanged); ResizeControl(); Recalculate(); Invalidate(); }
protected override void OnContentInserted(int index, object value) { base.OnContentInserted(index, value); Content content = value as Content; // Create TabPage to represent the Content ARMSim.GUI.DockingWindows.Controls.TabPage newPage = new ARMSim.GUI.DockingWindows.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 OnInsertedPage(int index, object value) { // If no page is currently selected if (_selectedIndex == -1) { // Then make the inserted page selected _selectedIndex = index; } // Cast to correct type ARMSim.GUI.DockingWindows.Controls.TabPage page = value as ARMSim.GUI.DockingWindows.Controls.TabPage; // Grab the content instance of the page Content c = page.Tag as Content; // Hook into change in its properties c.PropertyChanged += new Content.PropChangeHandler(OnContentChanged); ResizeControl(); Recalculate(); Invalidate(); }
protected void RestoreDraggingPage() { // Create TabPage to represent the Content ARMSim.GUI.DockingWindows.Controls.TabPage newPage = new ARMSim.GUI.DockingWindows.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); }
protected override void OnPaint(PaintEventArgs e) { // Fill background in required color if (_style == VisualStyle.IDE) { using (SolidBrush fillBrush = new SolidBrush(_backIDE)) e.Graphics.FillRectangle(fillBrush, this.ClientRectangle); } else { using (SolidBrush fillBrush = new SolidBrush(this.BackColor)) e.Graphics.FillRectangle(fillBrush, this.ClientRectangle); } // Style specific outline drawing DrawOutline(e.Graphics, true); // Draw border around area using (Pen borderPen = new Pen(ControlPaint.LightLight(this.ForeColor))) { // Draw each of the draw objects foreach (DrawTab dt in _drawTabs) { Rectangle drawRect = dt.DrawRect; AdjustRectForEdge(ref drawRect); // Style specific cell outline drawing DrawOutlineForCell(e.Graphics, borderPen, drawRect); // Draw the image in the left/top of the cell ARMSim.GUI.DockingWindows.Controls.TabPage page = dt.TabPage; int xDraw; int yDraw; switch (_edge) { case Edge.Left: case Edge.Right: xDraw = drawRect.Left + (drawRect.Width - _imageVector) / 2; yDraw = drawRect.Top + _imageGap; break; case Edge.Top: case Edge.Bottom: case Edge.None: default: xDraw = drawRect.Left + _imageGap; yDraw = drawRect.Top + (drawRect.Height - _imageVector) / 2; break; } if ((page.Icon != null) || ((page.ImageIndex != -1) && (page.ImageList != null))) { if (page.Icon != null) { // Draw the actual icon e.Graphics.DrawIcon(page.Icon, new Rectangle(xDraw, yDraw, _imageVector, _imageVector)); } else { // Draw the actual image e.Graphics.DrawImage(page.ImageList.Images[page.ImageIndex], new Rectangle(xDraw, yDraw, _imageVector, _imageVector)); } } // Is anything currently selected if (_selectedIndex != -1) { // Is this page selected? if (page == _tabPages[_selectedIndex]) { Rectangle textRect; StringFormat drawFormat = new StringFormat(); drawFormat.FormatFlags = StringFormatFlags.NoClip | StringFormatFlags.NoWrap; drawFormat.Alignment = StringAlignment.Center; drawFormat.LineAlignment = StringAlignment.Center; // Create text drawing rectangle switch (_edge) { case Edge.Left: case Edge.Right: textRect = new Rectangle(drawRect.Left, yDraw + _imageVector + _imageGap, drawRect.Width, drawRect.Height - _imageVector - _imageGap * 2); drawFormat.FormatFlags |= StringFormatFlags.DirectionVertical; break; case Edge.Top: case Edge.Bottom: case Edge.None: default: textRect = new Rectangle(xDraw + _imageVector + _imageGap, drawRect.Top, drawRect.Width - _imageVector - _imageGap * 2, drawRect.Height); break; } Color brushColor = this.ForeColor; if (_style == VisualStyle.IDE) { brushColor = ControlPaint.Light(brushColor); } using (SolidBrush drawBrush = new SolidBrush(brushColor)) e.Graphics.DrawString(page.Title, this.Font, drawBrush, textRect, drawFormat); } } } } // Style specific outline drawing DrawOutline(e.Graphics, false); base.OnPaint(e); }
public DrawTab(ARMSim.GUI.DockingWindows.Controls.TabPage tabPage, Rectangle drawRect, int index) { _index = index; _tabPage = tabPage; _drawRect = drawRect; }
protected void OnDoubleClickTab(ARMSim.GUI.DockingWindows.Controls.TabControl tc, ARMSim.GUI.DockingWindows.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); }