private void OnPageDragStart(Crownwood.DotNetMagic.Controls.TabControl sender, Crownwood.DotNetMagic.Controls.TabPage movePage, MouseEventArgs e) { // Is the user allowed to redock? if (DockingManager.AllowRedocking) { // Use allow to redock this particular content? if (this.RedockAllowed) { // Event page must specify its Content object Content c = movePage.Tag as Content; // Remember the position of the tab before it is removed _dragPageIndex = _tabControl.TabPages.IndexOf(movePage); // 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 = Redocker.CreateRedocker(DockingManager.FeedbackStyle, _tabControl, c, this, new Point(e.X, e.Y)); } } }
/// <summary> /// Initializes a new instance of the HotZoneFloating class. /// </summary> /// <param name="hotArea">Screen area that is hot.</param> /// <param name="newSize">Screen area to display with rectangle.</param> /// <param name="offset">Cursor offset when dragging started.</param> /// <param name="redocker">Parent redocker instance.</param> public HotZoneFloating(Rectangle hotArea, Rectangle newSize, Point offset, RedockerContent redocker) : base(hotArea, newSize) { // Store initial state _offset = offset; _redocker = redocker; if (redocker.DockingSource != RedockerContent.Source.FloatingForm) { Size floatSize = CalculateFloatingSize(); float widthPercentage = (float)floatSize.Width / (float)NewSize.Width; float heightPercentage = (float)floatSize.Height / (float)NewSize.Height; NewSize = new Rectangle(NewSize.Left, NewSize.Top, floatSize.Width, floatSize.Height + SystemInformation.ToolWindowCaptionHeight); _offset.X = (int)((float)_offset.X * widthPercentage); _offset.Y = (int)((float)_offset.Y * heightPercentage); } // We do not want the indicator to be too far away from the cursor, so limit check the offset if (_offset.X > newSize.Width) { _offset.X = newSize.Width; } if (_offset.Y > newSize.Height) { _offset.Y = newSize.Height; } }
/// <summary> /// Initialize a new instance of the HotAreaInside class. /// </summary> /// <param name="redocker">Redocking implementation class.</param> /// <param name="manager">Reference to docking manager.</param> public HotAreaFloating(RedockerContent redocker, DockingManager manager) : base(manager) { _floatingZone = new HotZoneFloating(Rectangle.Empty, new Rectangle(Point.Empty, redocker.SizeDependsOnSource()), redocker.Offset, redocker); }
private void OnPageDragQuit(Crownwood.DotNetMagic.Controls.TabControl sender, MouseEventArgs e) { // Are we currently in a redocking state? if (_redocker != null) { // Get redocker to quit _redocker.QuitTrackingMode(e); // No longer need the object _redocker = null; } }
/// <summary> /// Add our collection of hotzones into redocker. /// </summary> /// <param name="redock">Redocker target.</param> /// <param name="collection">Collection of hotzones.</param> public void AddHotZones(Redocker redock, HotZoneCollection collection) { RedockerContent redocker = redock as RedockerContent; // Allow the contained Zone a chance to expose HotZones foreach (Control c in this.Controls) { IHotZoneSource ag = c as IHotZoneSource; // Does this control expose an interface for its own HotZones? if (ag != null) { ag.AddHotZones(redock, collection); } } }
private Size CalculateFloatingSize() { Size floatingSize = new Size(0, 0); // Get specific redocker type RedockerContent redock = _redocker as RedockerContent; switch (redock.DockingSource) { case RedockerContent.Source.WindowContent: // Find the largest requested floating size foreach (Content c in redock.WindowContent.Contents) { if (c.FloatingSize.Width > floatingSize.Width) { floatingSize.Width = c.FloatingSize.Width; } if (c.FloatingSize.Height > floatingSize.Height) { floatingSize.Height = c.FloatingSize.Height; } } // Apply same size to all Content objects foreach (Content c in redock.WindowContent.Contents) { c.FloatingSize = floatingSize; } break; case RedockerContent.Source.ContentInsideWindow: // Whole Form is size requested by single Content floatingSize = redock.Content.FloatingSize; break; case RedockerContent.Source.FloatingForm: // Use the requested size floatingSize.Width = NewSize.Width; floatingSize.Height = NewSize.Height; break; } return(floatingSize); }
/// <summary> /// Add the collection of hot zones. /// </summary> /// <param name="redock">Reference to a redocker instance.</param> /// <param name="collection">Collection of hot zones.</param> public void AddHotZones(Redocker redock, HotZoneCollection collection) { RedockerContent redocker = redock as RedockerContent; bool itself = false; bool nullZone = false; // We process differently for WindowContent to redock into itself! if ((redocker.WindowContent != null) && (redocker.WindowContent == this)) { itself = true; } // We do not allow a Content to redock into its existing container if (itself && !Contents.Contains(redocker.Content)) { nullZone = true; } Rectangle newSize = this.RectangleToScreen(this.ClientRectangle); Rectangle hotArea = _tabControl.RectangleToScreen(_tabControl.ClientRectangle);; // Find any caption detail and use that area as the hot area foreach (WindowDetail wd in WindowDetails) { WindowDetailCaption wdc = wd as WindowDetailCaption; if (wdc != null) { hotArea = wdc.RectangleToScreen(wdc.ClientRectangle); hotArea.Inflate(_hotAreaInflate, _hotAreaInflate); break; } } if (nullZone) { collection.Add(new HotZoneNull(hotArea)); } else { collection.Add(new HotZoneTabbed(hotArea, newSize, this, itself)); } }
private void OnPageDragEnd(Crownwood.DotNetMagic.Controls.TabControl sender, MouseEventArgs e) { // Are we currently in a redocking state? if (_redocker != null) { // Remove the page from the source Crownwood.DotNetMagic.Controls.TabPage removedPage = _tabControl.TabPages[_dragPageIndex]; _tabControl.TabPages.RemoveAt(_dragPageIndex); // Let the redocker finish off bool moved = _redocker.OnMouseUp(e); // If the tab was not positioned somewhere else if (!moved) { // Put back the page that was removed when dragging started _tabControl.TabPages.Insert(_dragPageIndex, removedPage); } // No longer need the object _redocker = null; } }
/// <summary> /// Filters out a message before it is dispatched. /// </summary> /// <param name="m">The message to be dispatched. You cannot modify this message. </param> /// <returns>true to filter out; false otherwise.</returns> public bool PreFilterMessage(ref Message m) { // Has a key been pressed? if (m.Msg == (int)Win32.Msgs.WM_KEYDOWN) { // Is it the ESCAPE key? if ((int)m.WParam == (int)Win32.VirtualKeys.VK_ESCAPE) { // Are we in redocking mode? if (_redocker != null) { // Cancel the redocking activity _redocker.QuitTrackingMode(null); // No longer need the object _redocker = null; return(true); } } } return(false); }
/// <summary> /// Processes Windows messages. /// </summary> /// <param name="m">The Windows Message to process. </param> protected override void WndProc(ref Message m) { // Want to notice when the window is maximized if (m.Msg == (int)Win32.Msgs.WM_NCLBUTTONDBLCLK) { // Is the user allowed to redock? if (_dockingManager.AllowRedocking) { // Redock and kill ourself Restore(); // Raise event to indicate a double click occured _dockingManager.OnDoubleClickDock(); } // We do not want to let the base process the message as the // restore might fail due to lack of permission to restore to // old state. In that case we do not want to maximize the window return; } else if (m.Msg == (int)Win32.Msgs.WM_NCLBUTTONDOWN) { if (!_intercept) { // Perform a hit test against our own window to determine // which area the mouse press is over at the moment. uint result = User32.SendMessage(this.Handle, (int)Win32.Msgs.WM_NCHITTEST, 0, (uint)m.LParam); // Only want to override the behaviour of moving the window via the caption box if (result == HITTEST_CAPTION) { // Is the user allowed to redock? if (_dockingManager.AllowRedocking) { // Remember new state _intercept = true; // Capture the mouse until the mouse us is received this.Capture = true; // Ensure that we gain focus and look active this.Activate(); // Raise event to indicate a floating form has become active _dockingManager.OnFloatingFormActivated(this); // Get mouse position to inscreen coordinates Win32.POINT mousePos; mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU); mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16); // Begin a redocking activity _redocker = Redocker.CreateRedocker(DockingManager.FeedbackStyle, this, new Point(mousePos.x - DesktopBounds.X, mousePos.y - DesktopBounds.Y)); return; } } } } else if (m.Msg == (int)Win32.Msgs.WM_MOUSEMOVE) { if (_intercept) { Win32.POINT mousePos; mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU); mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16); _redocker.OnMouseMove(new MouseEventArgs(MouseButtons.Left, 0, mousePos.x, mousePos.y, 0)); return; } } else if ((m.Msg == (int)Win32.Msgs.WM_RBUTTONDOWN) || (m.Msg == (int)Win32.Msgs.WM_MBUTTONDOWN)) { if (_intercept) { Win32.POINT mousePos; mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU); mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16); _redocker.QuitTrackingMode(new MouseEventArgs(MouseButtons.Left, 0, mousePos.x, mousePos.y, 0)); // Release capture this.Capture = false; // Reset state _intercept = false; return; } } else if (m.Msg == (int)Win32.Msgs.WM_LBUTTONUP) { if (_intercept) { Win32.POINT mousePos; mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU); mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16); _redocker.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, mousePos.x, mousePos.y, 0)); // Release capture this.Capture = false; // Reset state _intercept = false; return; } } else if ((m.Msg == (int)Win32.Msgs.WM_NCRBUTTONUP) || (m.Msg == (int)Win32.Msgs.WM_NCMBUTTONDOWN) || (m.Msg == (int)Win32.Msgs.WM_NCMBUTTONUP) || (m.Msg == (int)Win32.Msgs.WM_RBUTTONDOWN) || (m.Msg == (int)Win32.Msgs.WM_RBUTTONUP) || (m.Msg == (int)Win32.Msgs.WM_MBUTTONDOWN) || (m.Msg == (int)Win32.Msgs.WM_MBUTTONUP)) { // Prevent middle and right mouse buttons from interrupting // the correct operation of left mouse dragging return; } else if (m.Msg == (int)Win32.Msgs.WM_NCRBUTTONDOWN) { if (!_intercept) { // Get screen coordinates of the mouse Win32.POINT mousePos; mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU); mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16); // Box to transfer as parameter OnContext(new Point(mousePos.x, mousePos.y)); return; } } base.WndProc(ref m); }
/// <summary> /// Initializes a new instance of the FloatingForm class. /// </summary> /// <param name="dockingManager">Parent docking manager instance.</param> /// <param name="zone">Zone to be hosted.</param> /// <param name="contextHandler">Delegate for handling context menus.</param> public FloatingForm(DockingManager dockingManager, Zone zone, ContextHandler contextHandler) { // The caller is responsible for setting our initial screen location this.StartPosition = FormStartPosition.Manual; // Ask the docking manager if we should have an icon in the taskbar showing this.ShowInTaskbar = dockingManager.FloatingInTaskBar; // If the docking manager has a specific icon to be used, then use it if (dockingManager.FloatingTaskBarIcon != null) { this.Icon = dockingManager.FloatingTaskBarIcon; } // Make sure the main Form owns us this.Owner = dockingManager.Container.FindForm(); // Try and hook into the owners visible change event if (this.Owner != null) { // Monitor change in the owning Form visibility this.Owner.VisibleChanged += new EventHandler(OnOwnerVisibleChanged); } // Never show by default this.Visible = false; // Need to know when the Zone is removed this.ControlRemoved += new ControlEventHandler(OnZoneRemoved); // Add the Zone as the only content of the Form Controls.Add(zone); // Default state _redocker = null; _intercept = false; _zone = zone; _dockingManager = dockingManager; // Assign any event handler for context menu if (contextHandler != null) { this.Context += contextHandler; } // Default color this.BackColor = _dockingManager.BackColor; this.ForeColor = _dockingManager.InactiveTextColor; // Monitor changes in the Zone content _zone.Windows.Inserted += new CollectionChange(OnWindowInserted); _zone.Windows.Removing += new CollectionChange(OnWindowRemoving); _zone.Windows.Removed += new CollectionChange(OnWindowRemoved); _zone.Windows.Clearing += new CollectionClear(OnWindowClearing); if (_zone.Windows.Count == 1) { // The first Window to be added. Tell it to hide details _zone.Windows[0].HideDetails(); // Monitor change in window title _zone.Windows[0].FullTitleChanged += new EventHandler(OnFullTitleChanged); WindowContent wc = _zone.Windows[0] as WindowContent; // Hook into changes in window contents wc.Contents.Inserted += new CollectionChange(OnContentsInserted); wc.Contents.Removing += new CollectionChange(OnContentsRemoving); wc.Contents.Clearing += new CollectionClear(OnContentsClearing); // Notice changes to properties foreach (Content c in wc.Contents) { c.PropertyChanged += new Crownwood.DotNetMagic.Docking.Content.PropChangeHandler(OnContentPropertyChanged); } // Decide if the form close button is needed ProbeContentWithoutClose(); // Grab any existing title this.Text = _zone.Windows[0].FullTitle; } // Need to hook into message pump so that the ESCAPE key can be // intercepted when in redocking mode Application.AddMessageFilter(this); }
/// <summary> /// Initialize a new instance of the HotAreaTabbed class. /// </summary> /// <param name="squares">Squares or diamonds.</param> /// <param name="redocker">Reference to the redocker.</param> /// <param name="manager">Reference to docking manager.</param> /// <param name="zs">Sequence containing the tabbed content.</param> /// <param name="wct">Tabbed content instance.</param> /// <param name="disallowTabbed">Allow to drop in tabbed area.</param> /// <param name="suppress">Suppress indicators if match found.</param> public HotAreaTabbed(bool squares, RedockerContent redocker, DockingManager manager, ZoneSequence zs, WindowContentTabbed wct, bool disallowTabbed, bool suppress) : base(manager) { // Remember initial values _wct = wct; _zs = zs; _squares = squares; _suppress = suppress; _disallowTabbed = disallowTabbed; // Not currently inside the hot area _hotInside = false; _disallowInsert = false; // Calculate the tabbed rectangle in screen coordinates _tabbedRect = wct.RectangleToScreen(wct.ClientRectangle); // Check for situations that need extra attention... // // (1) Do not allow a WindowContent from a ZoneSequence to be redocked into the // same ZoneSequence. As removing it will cause the Zone to be destroyed and // so it cannot be added back again. Is not logical anyway. // // (2) If the source is in this ZoneSequence we might need to adjust the insertion // index because the item being removed will reduce the count for when the insert // takes place. bool indexAdjustTest = false; WindowContent redockWC = redocker.WindowContent; if (_zs.Windows.Count == 1) { if (redocker.WindowContent != null) { if (redocker.WindowContent == _zs.Windows[0]) { if ((redocker.Content == null) || (redocker.WindowContent.Contents.Count == 1)) { _disallowInsert = true; } } } } else { if (_zs.Windows.Contains(redockWC)) { if ((redocker.Content == null) || (redocker.WindowContent.Contents.Count == 1)) { indexAdjustTest = true; } } } // Create the left/top and right/bottom hot zones if (!_disallowInsert) { Rectangle zoneRectLT = zs.RectangleToScreen(zs.ClientRectangle); Rectangle tabbedRect = zs.Windows[0].RectangleToScreen(zs.Windows[0].ClientRectangle); // Adjust the rectangle to give rough idea of new size if (zs.Direction == LayoutDirection.Vertical) { zoneRectLT.X = tabbedRect.X; zoneRectLT.Width = tabbedRect.Width; zoneRectLT.Height = zoneRectLT.Height / (zs.Windows.Count + 1); } else { zoneRectLT.Y = tabbedRect.Y; zoneRectLT.Height = tabbedRect.Height; zoneRectLT.Width = zoneRectLT.Width / (zs.Windows.Count + 1); } // Store the rectangle for use with the RB as well Rectangle zoneRectRB = zoneRectLT; // Find our current index as starting point for insertion int indexLT = zs.Windows.IndexOf(wct); // The RB is inserted after the current position int indexRB = indexLT + 1; // If inserting after the first window if (indexLT > 0) { // Move the indicator position to overlap the previous position if (zs.Direction == LayoutDirection.Vertical) { zoneRectLT.Y += zs.Windows[indexLT].Top - (zoneRectLT.Height / 2); } else { zoneRectLT.X += zs.Windows[indexLT].Left - (zoneRectLT.Width / 2); } } // Do we need to check if the removed WC is before the insert point? if (indexAdjustTest) { // If the source window content is before the target then the // index needs decreasing to ensure its removal is accounted for if (zs.Windows.IndexOf(redocker.WindowContent) < indexLT) { indexLT--; } } // Create the actual hot zone _hotLT = new HotZoneSequence(zoneRectLT, zoneRectLT, zs, indexLT); // If inserting before the last window if (indexRB < zs.Windows.Count) { // Move the indicator position to overlap the next position if (zs.Direction == LayoutDirection.Vertical) { zoneRectRB.Y += zs.Windows[indexRB - 1].Bottom - (zoneRectRB.Height / 2); } else { zoneRectRB.X += zs.Windows[indexRB - 1].Right - (zoneRectRB.Width / 2); } } else { // Move the indicator position to the end of our position if (zs.Direction == LayoutDirection.Vertical) { zoneRectRB.Y += zs.Windows[indexRB - 1].Bottom - zoneRectRB.Height; } else { zoneRectRB.X += zs.Windows[indexRB - 1].Right - zoneRectRB.Width; } } // Do we need to check if the removed WC is before the insert point? if (indexAdjustTest) { // If the source window content is before the target then the // index needs decreasing to ensure its removal is accounted for if (zs.Windows.IndexOf(redocker.WindowContent) < indexRB) { indexRB--; } } // Create the actual hot zone _hotRB = new HotZoneSequence(zoneRectRB, zoneRectRB, zs, indexRB); } // Create the insert into middle hot zone if (!_disallowTabbed) { _hotMiddle = new HotZoneTabbed(_tabbedRect, _tabbedRect, wct, false); } }
/// <summary> /// Apply the hot zone change. /// </summary> /// <param name="screenPos">Screen position when change applied.</param> /// <param name="parent">Parent redocker instance.</param> /// <returns>true is successful; otherwise false.</returns> public override bool ApplyChange(Point screenPos, Redocker parent) { // If docking back to itself then refuse to apply the change, this will cause the // WindowContentTabbed object to put back the content which is the desired effect if (_itself) { return(false); } // We are only called from the RedockerContent class RedockerContent redock = parent as RedockerContent; DockingManager dockingManager = redock.DockingManager; bool becomeFloating = (_wct.ParentZone.State == State.Floating); // Reduce flicker during transition dockingManager.Container.SuspendLayout(); // Manageing Zones should remove display AutoHide windows dockingManager.RemoveShowingAutoHideWindows(); switch (redock.DockingSource) { case RedockerContent.Source.WindowContent: { // Perform State specific Restore actions if (becomeFloating) { foreach (Content c in redock.WindowContent.Contents) { c.ContentBecomesFloating(); } } else { // If the source is leaving the Floating state then need to record Restore positions if (redock.WindowContent.State == State.Floating) { foreach (Content c in redock.WindowContent.Contents) { c.ContentLeavesFloating(); } } } int count = redock.WindowContent.Contents.Count; for (int index = 0; index < count; index++) { Content c = redock.WindowContent.Contents[0]; // Remove Content from previous WindowContent redock.WindowContent.Contents.RemoveAt(0); // Add into new WindowContent _wct.Contents.Add(c); _wct.BringContentToFront(c); } } break; case RedockerContent.Source.ContentInsideWindow: { // Perform State specific Restore actions if (becomeFloating) { redock.Content.ContentBecomesFloating(); } else { // If the source is leaving the Floating state then need to record Restore position if (redock.Content.ParentWindowContent.State == State.Floating) { redock.Content.ContentLeavesFloating(); } } // Remove Content from existing WindowContent if (redock.Content.ParentWindowContent != null) { redock.Content.ParentWindowContent.Contents.Remove(redock.Content); } _wct.Contents.Add(redock.Content); _wct.BringContentToFront(redock.Content); } break; case RedockerContent.Source.FloatingForm: { // Perform State specific Restore actions if (!becomeFloating) { // Make every Content object in the Floating Zone // record its current state as the Floating state redock.FloatingForm.ExitFloating(); } int wCount = redock.FloatingForm.Zone.Windows.Count; for (int wIndex = 0; wIndex < wCount; wIndex++) { WindowContent wc = redock.FloatingForm.Zone.Windows[0] as WindowContent; if (wc != null) { int cCount = wc.Contents.Count; for (int cIndex = 0; cIndex < cCount; cIndex++) { // Get reference to first content in collection Content c = wc.Contents[0]; // Remove from old WindowContent wc.Contents.RemoveAt(0); // Add into new WindowContentTabbed _wct.Contents.Add(c); _wct.BringContentToFront(c); } } } } break; } dockingManager.UpdateInsideFill(); // Reduce flicker during transition dockingManager.Container.ResumeLayout(); return(true); }
/// <summary> /// Initializes a new instance of the WindowContent class. /// </summary> /// <param name="manager">Parent docking manager instance.</param> /// <param name="vs">Visual style for drawing.</param> public WindowContentTabbed(DockingManager manager, VisualStyle vs) : base(manager, vs) { _redocker = null; // Create the TabControl used for viewing the Content windows _tabControl = new DotNetMagic.Controls.TabControl(); _tabControl.ShowTabPageClose = false; _tabControl.Customize = manager.Customize; // It should always occupy the remaining space after all details _tabControl.Dock = DockStyle.Fill; // Show tabs only if two or more tab pages exist _tabControl.HideTabsMode = HideTabsModes.HideUsingLogic; // Hook into the TabControl notifications _tabControl.GotFocus += new EventHandler(OnTabControlGotFocus); _tabControl.LostFocus += new EventHandler(OnTabControlLostFocus); _tabControl.PageGotFocus += new EventHandler(OnTabControlGotFocus); _tabControl.PageLostFocus += new EventHandler(OnTabControlLostFocus); _tabControl.SelectionChanged += new SelectTabHandler(OnSelectionChanged); _tabControl.PageDragStart += new PageDragStartHandler(OnPageDragStart); _tabControl.PageDragMove += new MouseEventHandler(OnPageDragMove); _tabControl.PageDragEnd += new PageDragHandler(OnPageDragEnd); _tabControl.PageDragQuit += new PageDragHandler(OnPageDragQuit); _tabControl.PageMoved += new PageMovedHandler(OnPageMoved); _tabControl.DoubleClickTab += new DoubleClickTabHandler(OnDoubleClickTab); _tabControl.Font = manager.TabControlFont; _tabControl.BackColor = manager.BackColor; _tabControl.ForeColor = manager.InactiveTextColor; _tabControl.OfficePixelBorder = false; _tabControl.OfficeExtraTabInset = 5; _tabControl.OfficeDockSides = true; _tabControl.OfficeHeaderBorder = true; _tabControl.IDE2005PixelBorder = true; _tabControl.IDE2005HeaderBorder = false; _tabControl.IDE2005TabJoined = false; _tabControl.IDE2005ExtraTabInset = 0; _tabControl.DragOutside = true; // Define the visual style required _tabControl.Style = vs; // Allow developers a chance to override default settings manager.OnTabControlCreated(_tabControl); switch (vs) { case VisualStyle.IDE: case VisualStyle.IDE2005: case VisualStyle.Office2003: Controls.Add(_tabControl); break; case VisualStyle.Plain: // Only the border at the pages edge and not around the whole control _tabControl.InsetBorderPagesOnly = !DockingManager.PlainTabBorder; // We want a border around the TabControl so it is indented and looks consistent // with the Plain look and feel, so use the helper Control 'BorderForControl' BorderForControl bfc = new BorderForControl(_tabControl, _plainBorder); // It should always occupy the remaining space after all details bfc.Dock = DockStyle.Fill; // Define the default border border bfc.BackColor = DockingManager.BackColor; // When in 'VisualStyle.Plain' we need to Controls.Add(bfc); break; } // Need to hook into message pump so that the ESCAPE key can be // intercepted when in redocking mode Application.AddMessageFilter(this); }
/// <summary> /// Apply the hot zone change. /// </summary> /// <param name="screenPos">Screen position when change applied.</param> /// <param name="parent">Parent redocker instance.</param> /// <returns>true is successful; otherwise false.</returns> public override bool ApplyChange(Point screenPos, Redocker parent) { // We are only called from the RedockerContent class RedockerContent redock = parent as RedockerContent; DockingManager dockingManager = redock.DockingManager; bool becomeFloating = (_zs.State == State.Floating); // Reduce flicker during transition dockingManager.Container.SuspendLayout(); // Manageing Zones should remove display AutoHide windows dockingManager.RemoveShowingAutoHideWindows(); switch (redock.DockingSource) { case RedockerContent.Source.WindowContent: { // Is the destination Zone in the Floating state? if (becomeFloating) { foreach (Content c in redock.WindowContent.Contents) { c.ContentBecomesFloating(); } } else { if (redock.WindowContent.State == State.Floating) { foreach (Content c in redock.WindowContent.Contents) { c.ContentLeavesFloating(); } } } // Check if the WindowContent source is in same Zone if (redock.WindowContent.ParentZone == _zs) { // Find current position of source WindowContent int currPos = _zs.Windows.IndexOf(redock.WindowContent); // If current window is before the new position then the current // window will disappear before the new one is inserted,so need to // adjust down the new insertion point if (currPos < _index) { _index--; } } // Create a new Window to host Content WindowContent wc = dockingManager.CreateWindowForContent(null) as WindowContent; // Transfer content across int count = redock.WindowContent.Contents.Count; for (int index = 0; index < count; index++) { Content c = redock.WindowContent.Contents[0]; // Remove from existing location redock.WindowContent.Contents.RemoveAt(0); // Add into new WindowContent host wc.Contents.Add(c); } // Add into host into Zone _zs.Windows.Insert(_index, wc); } break; case RedockerContent.Source.ContentInsideWindow: { // Perform State specific Restore actions if (becomeFloating) { redock.Content.ContentBecomesFloating(); } else { if (redock.Content.ParentWindowContent.State == State.Floating) { redock.Content.ContentLeavesFloating(); } } // Remove Content from existing WindowContent if (redock.Content.ParentWindowContent != null) { // Will removing the Content cause the WindowContent to die? if (redock.Content.ParentWindowContent.Contents.Count == 1) { // Check if the WindowContent source is in same Zone if (redock.Content.ParentWindowContent.ParentZone == _zs) { // Find current position of source WindowContent int currPos = _zs.Windows.IndexOf(redock.Content.ParentWindowContent); // If current window is before the new position then the current // window will disappear before the new one is inserted,so need to // adjust down the new insertion point if (currPos < _index) { _index--; } } } redock.Content.ParentWindowContent.Contents.Remove(redock.Content); } // Create a new Window to host Content Window w = dockingManager.CreateWindowForContent(redock.Content); // Add into Zone _zs.Windows.Insert(_index, w); } break; case RedockerContent.Source.FloatingForm: { // Perform State specific Restore actions if (!becomeFloating) { // Make every Content object in the Floating Zone // record its current state as the Floating state redock.FloatingForm.ExitFloating(); } int count = redock.FloatingForm.Zone.Windows.Count; for (int index = count - 1; index >= 0; index--) { // Remember the Window reference Window w = redock.FloatingForm.Zone.Windows[index]; // Remove from floating collection redock.FloatingForm.Zone.Windows.RemoveAt(index); // Add into new ZoneSequence destination _zs.Windows.Insert(_index, w); } } break; } dockingManager.UpdateInsideFill(); // Reduce flicker during transition dockingManager.Container.ResumeLayout(); return(true); }
/// <summary> /// Apply the hot zone change. /// </summary> /// <param name="screenPos">Screen position when change applied.</param> /// <param name="parent">Parent redocker instance.</param> /// <returns>true is successful; otherwise false.</returns> public override bool ApplyChange(Point screenPos, Redocker parent) { // Should always be the appropriate type RedockerContent redock = parent as RedockerContent; DockingManager dockingManager = redock.DockingManager; Zone newZone = null; // Manageing Zones should remove display AutoHide windows dockingManager.RemoveShowingAutoHideWindows(); switch (redock.DockingSource) { case RedockerContent.Source.WindowContent: // Perform State specific Restore actions foreach (Content c in redock.WindowContent.Contents) { c.ContentBecomesFloating(); } // Remove WindowContent from old Zone if (redock.WindowContent.ParentZone != null) { redock.WindowContent.ParentZone.Windows.Remove(redock.WindowContent); } // We need to create a Zone for containing the transfered content newZone = dockingManager.CreateZoneForContent(State.Floating); // Add into new Zone newZone.Windows.Add(redock.WindowContent); break; case RedockerContent.Source.ContentInsideWindow: { // Perform State specific Restore actions redock.Content.ContentBecomesFloating(); // Remove Content from existing WindowContent if (redock.Content.ParentWindowContent != null) { redock.Content.ParentWindowContent.Contents.Remove(redock.Content); } // Create a new Window to host Content Window w = dockingManager.CreateWindowForContent(redock.Content); // We need to create a Zone for containing the transfered content newZone = dockingManager.CreateZoneForContent(State.Floating); // Add into Zone newZone.Windows.Add(w); } break; case RedockerContent.Source.FloatingForm: redock.FloatingForm.Location = new Point(screenPos.X - _offset.X, screenPos.Y - _offset.Y); return(false); } dockingManager.UpdateInsideFill(); // Create a new floating form FloatingForm floating = new FloatingForm(redock.DockingManager, newZone, new ContextHandler(dockingManager.OnShowContextMenu)); // Find screen location/size _drawRect = new Rectangle(screenPos.X, screenPos.Y, NewSize.Width, NewSize.Height); // Adjust for mouse starting position relative to source control _drawRect.X -= _offset.X; _drawRect.Y -= _offset.Y; // Define its location/size floating.SetBounds(_drawRect.Left, _drawRect.Top, _drawRect.Width, _drawRect.Height); // Show it! floating.RequestShow(); return(true); }
/// <summary> /// Apply the hot zone change. /// </summary> /// <param name="screenPos">Screen position when change applied.</param> /// <param name="parent">Parent redocker instance.</param> /// <returns>true is successful; otherwise false.</returns> public override bool ApplyChange(Point screenPos, Redocker parent) { // We are only called from the RedockerContent class RedockerContent redock = parent as RedockerContent; DockingManager dockingManager = redock.DockingManager; // Reduce flicker during transition dockingManager.Container.SuspendLayout(); // Need to create a new Zone Zone zone; if (redock.DockingSource == RedockerContent.Source.FloatingForm) { // Make every Content object in the Floating Zone // record its current state as the Floating state redock.FloatingForm.ExitFloating(); zone = redock.FloatingForm.Zone; } else { zone = dockingManager.CreateZoneForContent(_state); } // Insert Zone at end of Controls collection dockingManager.Container.Controls.Add(zone); // Adjust ordering switch (_position) { case Position.Inner: dockingManager.ReorderZoneToInnerMost(zone); break; case Position.Index: // Manageing Zones should remove display AutoHide windows dockingManager.RemoveShowingAutoHideWindows(); // Place new Zone AFTER the one given, so need to increase index by one dockingManager.Container.Controls.SetChildIndex(zone, _newIndex + 1); break; case Position.Outer: dockingManager.ReorderZoneToOuterMost(zone); break; } switch (redock.DockingSource) { case RedockerContent.Source.WindowContent: // Remove WindowContent from old Zone if (redock.WindowContent.ParentZone != null) { // If the source is leaving the Floating state then need to record Restore positions if (redock.WindowContent.State == State.Floating) { foreach (Content c in redock.WindowContent.Contents) { c.ContentLeavesFloating(); } } redock.WindowContent.ParentZone.Windows.Remove(redock.WindowContent); } // Add into new Zone zone.Windows.Add(redock.WindowContent); break; case RedockerContent.Source.ContentInsideWindow: { // Remove Content from existing WindowContent if (redock.Content.ParentWindowContent != null) { // If the source is leaving the Floating state then need to record Restore position if (redock.Content.ParentWindowContent.State == State.Floating) { redock.Content.ContentLeavesFloating(); } redock.Content.ParentWindowContent.Contents.Remove(redock.Content); } // Create a new WindowContent to host Content Window w = dockingManager.CreateWindowForContent(redock.Content); // Add into Zone zone.Windows.Add(w); } break; case RedockerContent.Source.FloatingForm: DockStyle ds; LayoutDirection direction; dockingManager.ValuesFromState(_state, out ds, out direction); // Define correct docking style to match state zone.Dock = ds; ZoneSequence zs = zone as ZoneSequence; // Define correct display direction to match state if (zs != null) { zs.Direction = direction; } // Ensure the Zone recalculates contents according to new state zone.State = _state; break; } // Define correct size of the new Zone switch (_state) { case State.DockLeft: case State.DockRight: zone.Width = NewSize.Width; break; case State.DockTop: case State.DockBottom: zone.Height = NewSize.Height; break; } dockingManager.UpdateInsideFill(); // Reduce flicker during transition dockingManager.Container.ResumeLayout(); return(true); }