Esempio n. 1
0
        private static void InsertStyleDefault(StyleTypeNode root, System.Type type, IGuiStyle style)
        {
            if (type.IsSubclassOf(root.RegisteredType))
            {
                // Construct the branch to this type
                StyleTypeNode newBranchRoot = root.Find(type);
                if (newBranchRoot == null)
                {
                    newBranchRoot = new StyleTypeNode(type, style);

                    // Create empty elements up a known point in the tree
                    StyleTypeNode ancestor = FindClosestAncestor(root, type);

                    while (newBranchRoot.RegisteredType.BaseType != ancestor.RegisteredType)
                    {
                        StyleTypeNode oldBranchRoot = new StyleTypeNode(newBranchRoot);
                        newBranchRoot        = new StyleTypeNode(oldBranchRoot.RegisteredType.BaseType, null);
                        oldBranchRoot.Parent = newBranchRoot;
                        newBranchRoot.Children.Add(oldBranchRoot);
                    }

                    newBranchRoot.Parent = ancestor;
                    ancestor.Children.Add(newBranchRoot);
                }
            }
            else
            {
                throw new ArgumentException("Argument type(" + type.Name + ") must be a subclass of root.RegisteredType(" + root.RegisteredType.Name + ")");
            }
        }