internal static void UnRegisterWindow(DockWindow wnd) { if (wnd == null) { throw new ArgumentNullException("The window must not be null."); } if (!listPanel.Contains(wnd.ControlContainer)) { return; } contList.Remove(wnd.ControlContainer); if (wnd.DockType == DockContainerType.Document) { listDocument.Remove(wnd.ControlContainer); } else if (wnd.DockType == DockContainerType.ToolWindow) { listTool.Remove(wnd.ControlContainer); } }
internal static void RegisterWindow(DockWindow wnd) { if (wnd == null) { throw new ArgumentNullException("The window must not be null."); } if (listPanel.Contains(wnd.ControlContainer)) { return; } wnd.Disposed += new EventHandler(ObjectDisposed); listPanel.Add(wnd.ControlContainer); if (wnd.DockType == DockContainerType.Document) { listDocument.Add(wnd.ControlContainer); } else if (wnd.DockType == DockContainerType.ToolWindow) { listTool.Add(wnd.ControlContainer); } }
/// <summary> /// Reads the panel data from the window save list. /// </summary> /// <param name="reader">The <see cref="XmlReader"/> object that reads from the source stream.</param> internal void ReadXml(XmlReader reader) { try { string s; switch (reader.GetAttribute("dock")) { case "Fill": this.Dock = DockStyle.Fill; break; case "Top": this.Dock = DockStyle.Top; break; case "Bottom": this.Dock = DockStyle.Bottom; break; case "Left": this.Dock = DockStyle.Left; break; case "Right": this.Dock = DockStyle.Right; break; default: return; } s = reader.GetAttribute("width"); if (s != null) this.Width = int.Parse(s); s = reader.GetAttribute("height"); if (s != null) this.Height = int.Parse(s); s = reader.GetAttribute("type"); if (s == null) return; Type type = Type.GetType(s, true); if (type == null) return; ConstructorInfo info = type.GetConstructor(Type.EmptyTypes); if (info == null) return; DockWindow wnd = info.Invoke(new object[0]) as DockWindow; wnd.ControlContainer = this; this.form = wnd; wnd.CreateContainer(); wnd.ReadXml(reader); } catch (Exception ex) { Console.WriteLine("DockPanel.ReadXml: " + ex.Message); } }
/// <summary> /// Reads the panel data from the window save list. /// </summary> /// <param name="reader">The <see cref="XmlReader"/> object that reads from the source stream.</param> internal void ReadXml(XmlReader reader) { try { string s; switch (reader.GetAttribute("dock")) { case "Fill": this.Dock = DockStyle.Fill; break; case "Top": this.Dock = DockStyle.Top; break; case "Bottom": this.Dock = DockStyle.Bottom; break; case "Left": this.Dock = DockStyle.Left; break; case "Right": this.Dock = DockStyle.Right; break; default: return; } s = reader.GetAttribute("width"); if (s != null) { this.Width = int.Parse(s); } s = reader.GetAttribute("height"); if (s != null) { this.Height = int.Parse(s); } s = reader.GetAttribute("type"); if (s == null) { return; } Type type = Type.GetType(s, true); if (type == null) { return; } ConstructorInfo info = type.GetConstructor(Type.EmptyTypes); if (info == null) { return; } DockWindow wnd = info.Invoke(new object[0]) as DockWindow; wnd.ControlContainer = this; this.form = wnd; wnd.CreateContainer(); wnd.ReadXml(reader); } catch (Exception ex) { Console.WriteLine("DockPanel.ReadXml: " + ex.Message); } }
/// <summary> /// The direct version of the <see cref="DragWindow"/> event handler to dock a window into the container. /// Can be used for every container. /// </summary> /// <param name="wnd">The <see cref="DockForm"/> that is to be docked.</param> /// <param name="style">The preferred dock style. Use <see cref="DockStyle.Fill"/> to dock directly into the container.</param> /// <returns>The success of the operation.</returns> public bool DockWindow(DockWindow wnd, DockStyle style) { try { Point pt = Point.Empty; // Check hierarchy. if (conList.Count > 0) return (conList[0] as DockContainer).DockWindow(wnd, style); // Check Visibility. if (!wnd.IsVisible) { wnd.ShowFormAtOnLoad = false; wnd.Show(); wnd.ShowFormAtOnLoad = true; } // Release panel from any DockContainer. if (wnd.HostContainer != null) wnd.Release(); // Prepare target point. if (style == DockStyle.None) return false; pt = GetVirtualDragDest(style); DockManager.NoGuidePlease = true; DragWindow(wnd, new DockEventArgs(pt, wnd.DockType, true)); DockManager.NoGuidePlease = false; return wnd.IsDocked; } catch (Exception ex) { Console.WriteLine("DockContainer.DockWindow: " + ex.Message); } return false; }
/// <summary> /// Releases a <see cref="DockWindow"/> from the container. /// The container may destroy itself at the end of this procedure if it is empty and removeable. /// </summary> /// <param name="form">The <see cref="DockWindow"/> that is to be released.</param> /// <returns>The success of the operation.</returns> internal bool ReleaseWindow(DockWindow form) { bool ret = false; if (this.Controls.Contains(form.ControlContainer)) { this.Controls.Remove(form.ControlContainer); ret = true; } if ((panList.Count == 0) & (conList.Count == 0) & removeable) { if (this.Parent is DockContainer) (this.Parent as DockContainer).RemoveContainer(this); else if (this.Parent is DockForm) (this.Parent as DockForm).Close(); } return ret; }
internal static void UnRegisterWindow(DockWindow wnd) { if (wnd == null) throw new ArgumentNullException("The window must not be null."); if (!listPanel.Contains(wnd.ControlContainer)) return; contList.Remove(wnd.ControlContainer); if (wnd.DockType == DockContainerType.Document) listDocument.Remove(wnd.ControlContainer); else if (wnd.DockType == DockContainerType.ToolWindow) listTool.Remove(wnd.ControlContainer); }
internal static void RegisterWindow(DockWindow wnd) { if (wnd == null) throw new ArgumentNullException("The window must not be null."); if (listPanel.Contains(wnd.ControlContainer)) return; wnd.Disposed += new EventHandler(ObjectDisposed); listPanel.Add(wnd.ControlContainer); if (wnd.DockType == DockContainerType.Document) listDocument.Add(wnd.ControlContainer); else if (wnd.DockType == DockContainerType.ToolWindow) listTool.Add(wnd.ControlContainer); }