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); }
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 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); }