ComponentFactory.Krypton.Docking.DockingElement.GetParentType C# (CSharp) Метод

GetParentType() публичный Метод

Search up the parent chain looking for the specified type of object.
public GetParentType ( Type findType ) : IDockingElement
findType System.Type Type of the instance we are searching for.
Результат IDockingElement
        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;
        }

Usage Example

Пример #1
0
        private void RemoveControlStorePages(DockingElement element, string[] uniqueNames, bool autoHidden, bool docked)
        {
            // Find the control element from the provided starting point
            KryptonDockingControl control = element as KryptonDockingControl;
            if (control == null)
                control = element.GetParentType(typeof(KryptonDockingControl)) as KryptonDockingControl;

            // If we managed to find a docking control element to work with
            if (control != null)
            {
                // Enumerate all the child elements
                foreach (IDockingElement child in control)
                {
                    // We are only interested in the edge elements
                    KryptonDockingEdge edge = child as KryptonDockingEdge;
                    if (edge != null)
                    {
                        // Do we need to clear auto hidden elements?
                        if (autoHidden)
                        {
                            KryptonDockingEdgeAutoHidden autoHiddenEdge = edge["AutoHidden"] as KryptonDockingEdgeAutoHidden;
                            if (autoHiddenEdge != null)
                                autoHiddenEdge.PropogateAction(DockingPropogateAction.ClearStoredPages, uniqueNames);
                        }

                        // Do we need to clear docked elements?
                        if (docked)
                        {
                            KryptonDockingEdgeDocked dockedEdge = edge["Docked"] as KryptonDockingEdgeDocked;
                            if (dockedEdge != null)
                                dockedEdge.PropogateAction(DockingPropogateAction.ClearStoredPages, uniqueNames);
                        }
                    }
                }
            }
        }