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); } }
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.RawContent: { // Create a new Window to host Content Window w = dockingManager.CreateWindowForContent(redock.Content); // Add into Zone zone.Windows.Add(w); } break; 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; Direction 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; }
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)); }
public virtual bool ApplyChange(Point screenPos, Redocker parent) { return false; }
public virtual void UpdateForMousePosition(Point screenPos, Redocker parent) { }
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.RawContent: { // Perform State specific Restore actions redock.Content.ContentBecomesFloating(); // 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.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.Location = new Point(_drawRect.Left, _drawRect.Top); floating.Size = new Size(_drawRect.Width, _drawRect.Height); // Show it! floating.Show(); return true; }
public override void UpdateForMousePosition(Point screenPos, Redocker parent) { // Remember the current mouse pos Point newPos = screenPos; // Calculate the new drawing rectangle Rectangle newRect = new Rectangle(newPos.X, newPos.Y, _newSize.Width, _newSize.Height); // Adjust for mouse starting position relative to source control newRect.X -= _offset.X; newRect.Y -= _offset.Y; // Draw both the old rectangle and the new one, that will remove flicker as the // draw method will only actually draw areas that differ between the two rectangles DrawHelper.DrawDragRectangles(new Rectangle[]{_drawRect,newRect}, _dragWidth); // Remember new values _drawPos = newPos; _drawRect = newRect; }
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.RawContent: { // Perform State specific Restore actions if (becomeFloating) redock.Content.ContentBecomesFloating(); _wct.Contents.Add(redock.Content); } break; 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); } } 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); } 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); } } } } break; } dockingManager.UpdateInsideFill(); // Reduce flicker during transition dockingManager.Container.ResumeLayout(); return true; }
public void AddHotZones(Redocker redock, HotZoneCollection collection) { RedockerContent redocker = redock as RedockerContent; // Allow all the Window objects a chance to add HotZones foreach(Window w in _windows) { IHotZoneSource ag = w as IHotZoneSource; // Does this control expose an interface for its own HotZones? if (ag != null) ag.AddHotZones(redock, collection); } // 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 (_windows.Count == 1) { if (redockWC != null) if (redockWC == _windows[0]) if ((redocker.Content == null) || (redockWC.Contents.Count == 1)) return; } else { if (_windows.Contains(redockWC)) { if ((redocker.Content == null) || (redockWC.Contents.Count == 1)) indexAdjustTest = true; } } // Find the Zone client area in screen coordinates Rectangle zoneArea = this.RectangleToScreen(this.ClientRectangle); int length; // Give a rough idea of the new window size if (_direction == Direction.Vertical) length = zoneArea.Height / (_windows.Count + 1); else length = zoneArea.Width / (_windows.Count + 1); AddHotZoneWithIndex(collection, zoneArea, length, 0); int addative = 0; int count = _windows.Count; for(int index=1; index<count; index++) { // Grab the Window for this index WindowContent wc = _windows[index] as WindowContent; if (indexAdjustTest) { if (wc == redockWC) --addative; } AddHotZoneWithIndex(collection, wc.RectangleToScreen(wc.ClientRectangle), length, index + addative); } if (_windows.Count > 0) { // Find hot area and new size for last docking position Rectangle lastArea = zoneArea; Rectangle lastSize = zoneArea; if (_direction == Direction.Vertical) { lastArea.Y = lastArea.Bottom - _hotVectorBeforeControl; lastArea.Height = _hotVectorBeforeControl; lastSize.Y = lastSize.Bottom - length; lastSize.Height = length; } else { lastArea.X = lastArea.Right - _hotVectorBeforeControl; lastArea.Width = _hotVectorBeforeControl; lastSize.X = lastSize.Right - length; lastSize.Width = length; } collection.Add(new HotZoneSequence(lastArea, lastSize, this, _windows.Count + addative)); } }
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.RawContent: { // Perform State specific Restore actions if (becomeFloating) redock.Content.ContentBecomesFloating(); // 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.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; }