protected void InternalConstruct(Control callingControl, Source source, Content c, WindowContent wc, FloatingForm ff, DockingManager dm, Point offset) { // Store the starting state _callingControl = callingControl; _source = source; _content = c; _windowContent = wc; _dockingManager = dm; _container = _dockingManager.Container; _floatingForm = ff; _hotZones = null; _currentHotZone = null; _insideRect = new Rectangle(); _outsideRect = new Rectangle(); _offset = offset; // Begin tracking straight away EnterTrackingMode(); }
public override void PerformRestore(DockingManager dm) { // Grab a list of all floating forms Form[] owned = dm.Container.FindForm().OwnedForms; FloatingForm target = null; // Find the match to one of our best friends foreach (Form f in owned) { FloatingForm ff = f as FloatingForm; if (ff != null) { if (ZoneHelper.ContentNames(ff.Zone).Contains(_best)) { target = ff; break; } } } // If no friends then try associates as second best option if (target == null) { // Find the match to one of our best friends foreach (Form f in owned) { FloatingForm ff = f as FloatingForm; if (ff != null) { if (ZoneHelper.ContentNames(ff.Zone).Contains(_associates)) { target = ff; break; } } } } // If we found a friend/associate, then restore to it if (target != null) { // We should have a child and be able to restore to its Zone _child.PerformRestore(target.Zone); } else { // Restore its location/size _content.DisplayLocation = _location; _content.DisplaySize = _size; // Use the docking manage method to create us a new Floating Window at correct size/location dm.AddContentWithState(_content, State.Floating); } }
public RedockerContent(FloatingForm ff, Point offset) { InternalConstruct(ff, Source.FloatingForm, null, null, ff, ff.DockingManager, offset); }
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); }