/// <summary> /// Perform docking element specific actions for loading a child xml. /// </summary> /// <param name="xmlReader">Xml reader object.</param> /// <param name="pages">Collection of available pages.</param> /// <param name="child">Optional reference to existing child docking element.</param> protected virtual void LoadChildDockingElement(XmlReader xmlReader, KryptonPageCollection pages, IDockingElement child) { if (child != null) { child.LoadElementFromXml(xmlReader, pages); } else { string nodeName = xmlReader.Name; do { // Read past this element if (!xmlReader.Read()) { throw new ArgumentException("An element was expected but could not be read in."); } // Finished when we hit the end element matching the incoming one if ((xmlReader.NodeType == XmlNodeType.EndElement) && (xmlReader.Name == nodeName)) { break; } } while (true); } }
/// <summary> /// Insert a docking element to the collection. /// </summary> /// <param name="index">Insertion index.</param> /// <param name="item">IDockingElement reference.</param> protected virtual void InternalInsert(int index, IDockingElement item) { // Hook up the parent relationship, it is the responsability of the 'item' // to check that its name does not already exist in our collection. item.Parent = this; _elements.Insert(index, item); }
/// <summary> /// Initialize a new instance of the DockingMultiUpdate class. /// </summary> /// <param name="dockingElement">Reference to root element of docking hierarchy.</param> public DockingMultiUpdate(IDockingElement dockingElement) { // Must provide a valid docking element reference if (dockingElement == null) throw new ArgumentNullException("dockingElement"); // Inform docking elements that a multi-part update is starting _dockingElement = dockingElement; _dockingElement.PropogateAction(DockingPropogateAction.StartUpdate, (string[])null); }
/// <summary> /// Initialize a new instance of the DockingMultiUpdate class. /// </summary> /// <param name="dockingElement">Reference to root element of docking hierarchy.</param> public DockingMultiUpdate(IDockingElement dockingElement) { // Must provide a valid docking element reference if (dockingElement == null) { throw new ArgumentNullException("dockingElement"); } // Inform docking elements that a multi-part update is starting _dockingElement = dockingElement; _dockingElement.PropogateAction(DockingPropogateAction.StartUpdate, (string[])null); }
/// <summary> /// Removes first occurance of specified docking element. /// </summary> /// <param name="item">IDockingElement reference.</param> /// <returns>True if removed; otherwise false.</returns> protected virtual bool InternalRemove(IDockingElement item) { // Try and remove before removing the parent relationship, so if the // remove fails the parent relationship will still be correctly in place. if (_elements.Remove(item)) { item.Parent = null; return(true); } else { return(false); } }
/// <summary> /// Perform docking element specific actions for loading a child xml. /// </summary> /// <param name="xmlReader">Xml reader object.</param> /// <param name="pages">Collection of available pages.</param> /// <param name="child">Optional reference to existing child docking element.</param> protected override void LoadChildDockingElement(XmlReader xmlReader, KryptonPageCollection pages, IDockingElement child) { if (child != null) { child.LoadElementFromXml(xmlReader, pages); } else { // Create a new auto hidden group and then reload it KryptonDockingAutoHiddenGroup autoHiddenGroup = AppendAutoHiddenGroup(xmlReader.GetAttribute(@"N")); autoHiddenGroup.LoadElementFromXml(xmlReader, pages); } }
/// <summary> /// Perform docking element specific actions for loading a child xml. /// </summary> /// <param name="xmlReader">Xml reader object.</param> /// <param name="pages">Collection of available pages.</param> /// <param name="child">Optional reference to existing child docking element.</param> protected override void LoadChildDockingElement(XmlReader xmlReader, KryptonPageCollection pages, IDockingElement child) { if (child != null) { child.LoadElementFromXml(xmlReader, pages); } else { // Create a new floating window and then reload it KryptonDockingFloatingWindow floatingWindow = AddFloatingWindow(xmlReader.GetAttribute("N")); floatingWindow.LoadElementFromXml(xmlReader, pages); } }
/// <summary> /// Loads docking configuration information using a provider xml reader. /// </summary> /// <param name="xmlReader">Xml reader object.</param> /// <param name="pages">Collection of available pages for adding.</param> public virtual void LoadElementFromXml(XmlReader xmlReader, KryptonPageCollection pages) { // Is it the expected xml element name? if (xmlReader.Name != XmlElementName) { throw new ArgumentException("Element name '" + XmlElementName + "' was expected but found '" + xmlReader.Name + "' instead."); } // Grab the element attributes string elementName = xmlReader.GetAttribute("N"); string elementCount = xmlReader.GetAttribute("C"); // Check the name matches up if (elementName != Name) { throw new ArgumentException("Attribute 'N' value '" + Name + "' was expected but found '" + elementName + "' instead."); } // Let derived class perform element specific persistence LoadDockingElement(xmlReader, pages); // If there are children then move over them int count = int.Parse(elementCount); if (count > 0) { for (int i = 0; i < count; i++) { // Read to the next element if (!xmlReader.Read()) { throw new ArgumentException("An element was expected but could not be read in."); } // Find a child docking element with the matching name IDockingElement child = this[xmlReader.GetAttribute("N")]; // Let derived class perform child element specific processing LoadChildDockingElement(xmlReader, pages, child); } } // Read past this element to the end element if (!xmlReader.Read()) { throw new ArgumentException("An element was expected but could not be read in."); } }
/// <summary> /// Find the docking element that contains the location specific store page for the named page. /// </summary> /// <param name="location">Location to be searched.</param> /// <param name="uniqueName">Unique name of the page to be found.</param> /// <returns>IDockingElement reference if store page is found; otherwise null.</returns> public virtual IDockingElement FindStorePageElement(DockingLocation location, string uniqueName) { // Default to not finding the element IDockingElement dockingElement = null; // Search all child docking elements for (int i = 0; i < Count; i++) { dockingElement = this[i].FindStorePageElement(location, uniqueName); if (dockingElement != null) { break; } } return(dockingElement); }
/// <summary> /// Resolve the provided path. /// </summary> /// <param name="path">Comma separated list of names to resolve.</param> /// <returns>IDockingElement reference if path was resolved with success; otherwise null.</returns> public virtual IDockingElement ResolvePath(string path) { // Cannot resolve a null reference if (path == null) { throw new ArgumentNullException(nameof(path)); } // Path names cannot be zero length if (path.Length == 0) { throw new ArgumentException("path"); } // Extract the first name in the path int comma = path.IndexOf(','); string firstName = (comma == -1 ? path : path.Substring(0, comma)); // If the first name matches ourself... if (firstName == Name) { // If there are no other names then we are the target if (firstName.Length == path.Length) { return(this); } else { // Extract the remainder of the path string remainder = path.Substring(comma, path.Length - comma); // Give each child a chance to resolve the remainder of the path foreach (IDockingElement child in this) { IDockingElement ret = child.ResolvePath(remainder); if (ret != null) { return(ret); } } } } return(null); }
/// <summary> /// Search up the parent chain looking for the specified type of object. /// </summary> /// <param name="findType">Type of the instance we are searching for.</param> /// <returns>Object reference if found and it implements IDockingElemnet; othrtwise null.</returns> public IDockingElement GetParentType(Type findType) { // Searching from this element upwards IDockingElement parent = this; while (parent != null) { // If we find a match then we are done if (parent.GetType() == findType) { return(parent as IDockingElement); } // Keep going up the parent chain parent = parent.Parent; } // No match found return(null); }
private void Construct(Control control, IDockingElement innerElement) { _innerElement = innerElement; _innerMinimum = INNER_MINIMUM; // Hook into events on the target control _control = control; _control.SizeChanged += new EventHandler(OnControlSizeChanged); _control.Disposed += new EventHandler(OnControlDisposed); // Create and add a control we use to obscure the client area during multi-part operations _obscure = new ObscureControl(); _obscure.Anchor = (AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom); _obscure.Visible = false; _control.Controls.Add(_obscure); // Create docking elements for managing each of the four control edges Add(new KryptonDockingEdge("Top", control, DockingEdge.Top)); Add(new KryptonDockingEdge("Bottom", control, DockingEdge.Bottom)); Add(new KryptonDockingEdge("Left", control, DockingEdge.Left)); Add(new KryptonDockingEdge("Right", control, DockingEdge.Right)); }
/// <summary> /// Perform docking element specific actions for loading a child xml. /// </summary> /// <param name="xmlReader">Xml reader object.</param> /// <param name="pages">Collection of available pages.</param> /// <param name="child">Optional reference to existing child docking element.</param> protected override void LoadChildDockingElement(XmlReader xmlReader, KryptonPageCollection pages, IDockingElement child) { if (child != null) { child.LoadElementFromXml(xmlReader, pages); } else { Size dockspaceSize = _defaultDockspaceSize; string elementSize = xmlReader.GetAttribute("S"); // Cache the loading size if (!string.IsNullOrEmpty(elementSize)) { dockspaceSize = CommonHelper.StringToSize(elementSize); } // Create a new dockspace and then reload it KryptonDockingDockspace dockspace = AppendDockspace(xmlReader.GetAttribute("N"), dockspaceSize); dockspace.LoadElementFromXml(xmlReader, pages); } }
/// <summary> /// Initialize a new instance of the DockingMultiUpdate class. /// </summary> /// <param name="dockingElement">Reference to root element of docking hierarchy.</param> public DockingMultiUpdate(IDockingElement dockingElement) { // Inform docking elements that a multi-part update is starting _dockingElement = dockingElement ?? throw new ArgumentNullException(nameof(dockingElement)); _dockingElement.PropogateAction(DockingPropogateAction.StartUpdate, (string[])null); }
/// <summary> /// Perform docking element specific actions for loading a child xml. /// </summary> /// <param name="xmlReader">Xml reader object.</param> /// <param name="pages">Collection of available pages.</param> /// <param name="child">Optional reference to existing child docking element.</param> protected override void LoadChildDockingElement(XmlReader xmlReader, KryptonPageCollection pages, IDockingElement child) { if (child != null) child.LoadElementFromXml(xmlReader, pages); else { // Create a new floating window and then reload it KryptonDockingFloatingWindow floatingWindow = AddFloatingWindow(xmlReader.GetAttribute("N")); floatingWindow.LoadElementFromXml(xmlReader, pages); } }
protected virtual void OnDockingContentDetached(IDockingElement item) { }
/// <summary> /// Insert a docking element to the collection. /// </summary> /// <param name="index">Insertion index.</param> /// <param name="item">IDockingElement reference.</param> protected virtual void InternalInsert(int index, IDockingElement item) { // Hook up the parent relationship, it is the responsability of the 'item' // to check that its name does not already exist in our collection. item.Parent = this; _elements.Insert(index, item); }
/// <summary> /// Determines whether the collection contains the docking element. /// </summary> /// <param name="item">IDockingElement reference.</param> /// <returns>True if view found; otherwise false.</returns> public virtual bool Contains(IDockingElement item) { return(_elements.Contains(item)); }
/// <summary> /// Append a docking element to the collection. /// </summary> /// <param name="index">Insert index.</param> /// <param name="item">IDockingElement reference.</param> public virtual void Insert(int index, IDockingElement item) { InternalInsert(index, item); }
/// <summary> /// Removes first occurance of specified docking element. /// </summary> /// <param name="item">IDockingElement reference.</param> /// <returns>True if removed; otherwise false.</returns> protected virtual bool InternalRemove(IDockingElement item) { // Try and remove before removing the parent relationship, so if the // remove fails the parent relationship will still be correctly in place. if (_elements.Remove(item)) { item.Parent = null; return true; } else return false; }
/// <summary> /// Perform docking element specific actions for loading a child xml. /// </summary> /// <param name="xmlReader">Xml reader object.</param> /// <param name="pages">Collection of available pages.</param> /// <param name="child">Optional reference to existing child docking element.</param> protected override void LoadChildDockingElement(XmlReader xmlReader, KryptonPageCollection pages, IDockingElement child) { KryptonDockingManager manager = DockingManager; // Is it the expected xml element name? if (xmlReader.Name != "KP") throw new ArgumentException("Element name 'KP' was expected but found '" + xmlReader.Name + "' instead."); // Get the unique name of the page string uniqueName = xmlReader.GetAttribute("UN"); string boolStore = xmlReader.GetAttribute("S"); string boolVisible = xmlReader.GetAttribute("V"); KryptonPage page = null; // If the entry is for just a placeholder... if (CommonHelper.StringToBool(boolStore)) { // Recreate the requested store page and append page = new KryptonStorePage(uniqueName, "AutoHiddenGroup"); AutoHiddenGroupControl.Pages.Add(page); } else { // Can we find a provided page to match the incoming layout? page = pages[uniqueName]; if (page == null) { // Generate event so developer can create and supply the page now RecreateLoadingPageEventArgs args = new RecreateLoadingPageEventArgs(uniqueName); manager.RaiseRecreateLoadingPage(args); if (!args.Cancel) { page = args.Page; // Add recreated page to the looking dictionary if ((page != null) && (pages[page.UniqueName] == null)) pages.Add(page); } } if (page != null) { // Use the loaded visible state page.Visible = CommonHelper.StringToBool(boolVisible); // Create a proxy around the page and append it KryptonAutoHiddenProxyPage proxyPage = new KryptonAutoHiddenProxyPage(page); AutoHiddenGroupControl.Pages.Add(proxyPage); } } if (!xmlReader.Read()) throw new ArgumentException("An element was expected but could not be read in."); if (xmlReader.Name != "CPD") throw new ArgumentException("Expected 'CPD' element was not found"); bool finished = xmlReader.IsEmptyElement; // Generate event so custom data can be loaded and/or the page to be added can be modified DockPageLoadingEventArgs pageLoading = new DockPageLoadingEventArgs(manager, xmlReader, page); manager.RaisePageLoading(pageLoading); // Read everything until we get the end of custom data marker while (!finished) { // Check it has the expected name if (xmlReader.NodeType == XmlNodeType.EndElement) finished = (xmlReader.Name == "CPD"); if (!finished) { if (!xmlReader.Read()) throw new ArgumentException("An element was expected but could not be read in."); } } if (!xmlReader.Read()) throw new ArgumentException("An element was expected but could not be read in."); }
/// <summary> /// Append a docking element to the collection. /// </summary> /// <param name="index">Insert index.</param> /// <param name="item">IDockingElement reference.</param> public virtual void Insert(int index, IDockingElement item) { InternalInsert(index, item); }
/// <summary> /// Removes first occurance of specified docking element. /// </summary> /// <param name="item">IDockingElement reference.</param> /// <returns>True if removed; otherwise false.</returns> public virtual bool Remove(IDockingElement item) { return InternalRemove(item); }
/// <summary> /// Removes first occurrence of specified docking element. /// </summary> /// <param name="item">IDockingElement reference.</param> /// <returns>True if removed; otherwise false.</returns> public virtual bool Remove(IDockingElement item) => InternalRemove(item);
/// <summary> /// Append a docking element to the collection. /// </summary> /// <param name="item">IDockingElement reference.</param> public virtual void Add(IDockingElement item) { InternalAdd(item); }
/// <summary> /// Determines whether the collection contains the docking element. /// </summary> /// <param name="item">IDockingElement reference.</param> /// <returns>True if view found; otherwise false.</returns> public virtual bool Contains(IDockingElement item) { return _elements.Contains(item); }
/// <summary> /// Append a docking element to the collection. /// </summary> /// <param name="item">IDockingElement reference.</param> public virtual void Add(IDockingElement item) { InternalAdd(item); }
/// <summary> /// Perform docking element specific actions for loading a child xml. /// </summary> /// <param name="xmlReader">Xml reader object.</param> /// <param name="pages">Collection of available pages.</param> /// <param name="child">Optional reference to existing child docking element.</param> protected virtual void LoadChildDockingElement(XmlReader xmlReader, KryptonPageCollection pages, IDockingElement child) { if (child != null) child.LoadElementFromXml(xmlReader, pages); else { string nodeName = xmlReader.Name; do { // Read past this element if (!xmlReader.Read()) throw new ArgumentException("An element was expected but could not be read in."); // Finished when we hit the end element matching the incoming one if ((xmlReader.NodeType == XmlNodeType.EndElement) && (xmlReader.Name == nodeName)) break; } while (true); } }
/// <summary> /// Removes first occurance of specified docking element. /// </summary> /// <param name="item">IDockingElement reference.</param> /// <returns>True if removed; otherwise false.</returns> public virtual bool Remove(IDockingElement item) { return(InternalRemove(item)); }
/// <summary> /// Perform docking element specific actions for loading a child xml. /// </summary> /// <param name="xmlReader">Xml reader object.</param> /// <param name="pages">Collection of available pages.</param> /// <param name="child">Optional reference to existing child docking element.</param> protected override void LoadChildDockingElement(XmlReader xmlReader, KryptonPageCollection pages, IDockingElement child) { if (child != null) child.LoadElementFromXml(xmlReader, pages); else { // Create a new auto hidden group and then reload it KryptonDockingAutoHiddenGroup autoHiddenGroup = AppendAutoHiddenGroup(xmlReader.GetAttribute("N")); autoHiddenGroup.LoadElementFromXml(xmlReader, pages); } }
/// <summary> /// Perform docking element specific actions for loading a child xml. /// </summary> /// <param name="xmlReader">Xml reader object.</param> /// <param name="pages">Collection of available pages.</param> /// <param name="child">Optional reference to existing child docking element.</param> protected override void LoadChildDockingElement(XmlReader xmlReader, KryptonPageCollection pages, IDockingElement child) { KryptonDockingManager manager = DockingManager; // Is it the expected xml element name? if (xmlReader.Name != "KP") { throw new ArgumentException("Element name 'KP' was expected but found '" + xmlReader.Name + "' instead."); } // Get the unique name of the page string uniqueName = xmlReader.GetAttribute("UN"); string boolStore = xmlReader.GetAttribute("S"); string boolVisible = xmlReader.GetAttribute("V"); KryptonPage page; // If the entry is for just a placeholder... if (CommonHelper.StringToBool(boolStore)) { // Recreate the requested store page and append page = new KryptonStorePage(uniqueName, "AutoHiddenGroup"); AutoHiddenGroupControl.Pages.Add(page); } else { // Can we find a provided page to match the incoming layout? page = pages[uniqueName]; if (page == null) { // Generate event so developer can create and supply the page now RecreateLoadingPageEventArgs args = new RecreateLoadingPageEventArgs(uniqueName); manager.RaiseRecreateLoadingPage(args); if (!args.Cancel) { page = args.Page; // Add recreated page to the looking dictionary if ((page != null) && (pages[page.UniqueName] == null)) { pages.Add(page); } } } if (page != null) { // Use the loaded visible state page.Visible = CommonHelper.StringToBool(boolVisible); // Create a proxy around the page and append it KryptonAutoHiddenProxyPage proxyPage = new KryptonAutoHiddenProxyPage(page); AutoHiddenGroupControl.Pages.Add(proxyPage); } } if (!xmlReader.Read()) { throw new ArgumentException("An element was expected but could not be read in."); } if (xmlReader.Name != "CPD") { throw new ArgumentException("Expected 'CPD' element was not found"); } bool finished = xmlReader.IsEmptyElement; // Generate event so custom data can be loaded and/or the page to be added can be modified DockPageLoadingEventArgs pageLoading = new DockPageLoadingEventArgs(manager, xmlReader, page); manager.RaisePageLoading(pageLoading); // Read everything until we get the end of custom data marker while (!finished) { // Check it has the expected name if (xmlReader.NodeType == XmlNodeType.EndElement) { finished = (xmlReader.Name == "CPD"); } if (!finished) { if (!xmlReader.Read()) { throw new ArgumentException("An element was expected but could not be read in."); } } } if (!xmlReader.Read()) { throw new ArgumentException("An element was expected but could not be read in."); } }
private void Construct(Control control, IDockingElement innerElement) { _innerElement = innerElement; _innerMinimum = INNER_MINIMUM; // Hook into events on the target control _control = control; _control.SizeChanged += new EventHandler(OnControlSizeChanged); _control.Disposed += new EventHandler(OnControlDisposed); // Create and add a control we use to obscure the client area during multi-part operations _obscure = new ObscureControl(); _obscure.Anchor = (AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom); _obscure.Visible = false; _control.Controls.Add(_obscure); // Create docking elements for managing each of the four control edges Add(new KryptonDockingEdge("Top", control, DockingEdge.Top)); Add(new KryptonDockingEdge("Bottom", control, DockingEdge.Bottom)); Add(new KryptonDockingEdge("Left", control, DockingEdge.Left)); Add(new KryptonDockingEdge("Right", control, DockingEdge.Right)); }