예제 #1
0
        private void TagCreate(GameDefinition game, string tagClass, Tag tagData)
        {
            gameDefinition = game;
            XmlDocument tagDefinitionDocument = game.GetTagDefinitionDocument(tagClass);

            this.tagData  = tagData;
            tagDefinition = tagDefinitionDocument;

            // Check to see if this is a derived type.
            XmlNode nameNode    = tagDefinitionDocument.SelectSingleNode("//name");
            string  parentClass = nameNode.Attributes["parenttype"].InnerText;

            if ((parentClass != "") && (parentClass != "????"))
            {
                XmlDocument tempDefinitionStorage = tagDefinition;

                TagCreate(game, parentClass, this.tagData);
                tagDefinition = tempDefinitionStorage;
            }

            // Query for the main node.
            mainStructName = nameNode.InnerText;
            XmlNode mainNode = tagDefinition.SelectSingleNode("//struct[@name='" + mainStructName + "']");

            // If it's not there, then this object doesn't match the supplied tag definition.
            if (mainNode == null)
            {
                throw new Exception("'" + mainStructName + "' node was not found in the tag definition.");
            }

            string tabName = mainNode.Attributes["name"].InnerText;

            if (mainNode.Attributes["caption"] != null)
            {
                tabName = mainNode.Attributes["caption"].InnerText;
            }
            CreateTab(tabName);

            TabArguments tabArgs = new TabArguments();

            tabArgs.Game          = game;
            tabArgs.Container     = containers.Pop();
            tabArgs.TagData       = tagData;
            tabArgs.MaxDepth      = GetMaxDepth(mainNode);
            tabArgs.TagClass      = tagClass;
            tabArgs.NameNode      = nameNode;
            tabArgs.MainNode      = mainNode;
            tabArgs.TagDefinition = tagDefinition;

            tabArguments.Add(tabArgs);
        }
예제 #2
0
        protected void ProcessGroup(BlockContainerPanel container, XmlNode node, bool mainBlock, int maxDepth)
        {
            // Make sure that this node is a direct child of the Main Struct.
            // (That's the only place that groups are allowed to exist.)
            if (node.ParentNode.Name.ToLower() == "struct")
            {
                if (node.ParentNode.Attributes["name"] != null)
                {
                    groupCount++;

                    string groupCaption = "";
                    if (node.Attributes["caption"] != null)
                    {
                        groupCaption = node.Attributes["caption"].InnerText;
                    }
                    else if (node.Attributes["name"] != null)
                    {
                        groupCaption = node.Attributes["name"].InnerText;
                    }
                    else
                    {
                        groupCaption = "Group " + groupCount;
                    }
                    //buildDepth.Push(0);
                    CreateTab(groupCaption);
                    //BlockContainerPanel newContainer = BuildStruct(new BlockGlobals(null, node, maxDepth));

                    TabArguments tabArgs = new TabArguments();
                    tabArgs.Container     = containers.Pop();
                    tabArgs.TagDefinition = tagDefinition;
                    tabArgs.Game          = gameDefinition;
                    tabArgs.MainNode      = node;
                    tabArgs.MaxDepth      = maxDepth;
                    tabArgs.TagData       = tagData;
                    tabArguments.Add(tabArgs);

                    //newContainer.DatabindChildrenToBlock(tagData);
                    //containers.Peek().AddFieldContainer(newContainer);
                    //containers.Pop();
                    //buildDepth.Pop();
                    return;
                }
            }
            throw new Exception("Unable to create group: Not a direct member of the main struct.");
        }
예제 #3
0
        private void LoadTab(TabArguments tabArgs)
        {
            this.tagData       = tabArgs.TagData;
            this.tagDefinition = tabArgs.TagDefinition;
            //XmlNode nameNode = tabArgs.NameNode;
            XmlNode mainNode = tabArgs.MainNode;
            int     maxDepth = tabArgs.MaxDepth;

            //tagDefinition = tabArgs.TagDefinition;
            containers.Push(tabArgs.Container);

            className = tagDefinition.SelectSingleNode("//xml/name").InnerText;

            buildDepth.Push(0);

            tabArgs.MainBlockGlobals = new ContainerGlobals(null, mainNode, maxDepth);
            tabArgs.MainBlockGlobals.DepthDifference = maxDepth;
            tabArgs.MainBlockGlobals.TagDefinition   = tabArgs.TagDefinition;

            // This is the top-most block container and is placed directly into the tab, because CreateTab pushes itself onto the stack.
            BlockContainerPanel container = BuildStruct(tabArgs.MainBlockGlobals);

            container.Location        = new Point((containers.Peek() as Control).Margin.Left, (containers.Peek() as Control).Margin.Top);
            container.DepthDifference = maxDepth;
            container.DatabindChildrenToBlock(tagData);
            container.AutoSizeMode = Prometheus.Controls.TagEditor.AutoSizeType.GrowAndShrink | Prometheus.Controls.TagEditor.AutoSizeType.WidthAndHeight;
            container.DrawBorder   = true;

            IFieldControlContainer cont = containers.Peek();

            cont.AddFieldContainer(container);

            buildDepth.Pop();

            ConnectBlocks(container);
            tabArgs.IsLoaded = true;

            //AttachedControl_SizeChanged(tabControl.Tabs[tabControl.TabIndex].AttachedControl, null);
        }