public Window AddContentToZone(Content c, Zone z, int index) { // Validate the incoming Content instance is a valid reference // and is a current instance within our internal collection if ((c == null) || !_contents.Contains(c)) return null; // Validate the incoming Zone instance is a valid reference if (z == null) return null; // Do not generate hiding/hidden/shown events _surpressVisibleEvents++; // Manageing Zones should remove display AutoHide windows RemoveShowingAutoHideWindows(); // Is the window already part of a WindowContent? if (c.ParentWindowContent != null) { // Is there a change in docking state? if (c.ParentWindowContent.ParentZone.State != z.State) { // If it used to be in a floating mode, then record state change if (c.ParentWindowContent.ParentZone.State == State.Floating) c.ContentLeavesFloating(); else c.ContentBecomesFloating(); } // Remove the Content from its current WindowContent c.ParentWindowContent.Contents.Remove(c); } else { // If target zone is floating window then we are no longer docked if (z.State == State.Floating) c.Docked = false; } // Create a new WindowContent instance according to our style Window w = CreateWindowForContent(c); // Add the Window to the Zone at given position z.Windows.Insert(index, w); // Enable generation hiding/hidden/shown events _surpressVisibleEvents--; // Generate event to indicate content is now visible OnContentShown(c); return w; }
public WindowContent AddContentWithState(Content c, State newState) { // Validate the incoming Content instance is a valid reference // and is a current instance within our internal collection if ((c == null) || !_contents.Contains(c)) return null; // Do not generate hiding/hidden/shown events _surpressVisibleEvents++; // Manageing Zones should remove display AutoHide windows RemoveShowingAutoHideWindows(); // Is the window already part of a WindowContent? if (c.ParentWindowContent != null) { // If it used to be in a floating mode, then record state change if (c.ParentWindowContent.ParentZone.State == State.Floating) c.ContentLeavesFloating(); // Remove the Content from its current WindowContent c.ParentWindowContent.Contents.Remove(c); } // Create a new Window instance appropriate for hosting a Content object Window w = CreateWindowForContent(c); ContainerControl destination = null; if (newState != State.Floating) { destination = _container; destination.SuspendLayout(); } // Create a new Zone capable of hosting a WindowContent Zone z = CreateZoneForContent(newState, destination); if (newState == State.Floating) { // Content is not in the docked state c.Docked = false; // destination a new floating form destination = new FloatingForm(this, z);//, new ContextHandler(OnShowContextMenu)); // Define its location destination.Location = c.DisplayLocation; // ...and its size, add the height of the caption bar to the requested content size destination.Size = new Size(c.FloatingSize.Width, c.FloatingSize.Height + SystemInformation.ToolWindowCaptionHeight); } // Add the Window to the Zone z.Windows.Add(w); if (newState != State.Floating) { // Set the Zone to be the least important of our Zones ReorderZoneToInnerMost(z); UpdateInsideFill(); destination.ResumeLayout(); } else destination.Show(); // Enable generation hiding/hidden/shown events _surpressVisibleEvents--; // Generate event to indicate content is now visible OnContentShown(c); return w as WindowContent; }
public WindowContent AddContentToWindowContent(Content c, WindowContent wc) { // Validate the incoming Content instance is a valid reference // and is a current instance within our internal collection if ((c == null) || !_contents.Contains(c)) return null; // Validate the incoming WindowContent instance is a valid reference if (wc == null) return null; // Is Content already part of given Window then nothing to do if (c.ParentWindowContent == wc) return wc; else { // Do not generate hiding/hidden/shown events _surpressVisibleEvents++; // Manageing Zones should remove display AutoHide windows RemoveShowingAutoHideWindows(); if (c.ParentWindowContent != null) { // Is there a change in docking state? if (c.ParentWindowContent.ParentZone.State != wc.ParentZone.State) { // If it used to be in a floating mode, then record state change if (c.ParentWindowContent.ParentZone.State == State.Floating) c.ContentLeavesFloating(); else c.ContentBecomesFloating(); } // Remove the Content from its current WindowContent c.ParentWindowContent.Contents.Remove(c); } else { // If adding to a floating window then it is not docked if (wc.ParentZone.State == State.Floating) c.Docked = false; } // Add the existing Content to this instance wc.Contents.Add(c); // Enable generation hiding/hidden/shown events _surpressVisibleEvents--; // Generate event to indicate content is now visible OnContentShown(c); return wc; } }