Exemple #1
0
        private void ProcessBlock(ContainerGlobals globals, XmlNode valueNode, IFieldControl fieldControl, string fullPropertyName)
        {
            int maxDepth = globals.MaxDepth;

            IBlockControl blockControl = fieldControl as IBlockControl;

            if (valueNode.Attributes["maxelements"] != null)
            {
                blockControl.MaxBlockCount = Convert.ToInt32(valueNode.Attributes["maxelements"].Value);
            }
            else
            {
                blockControl.MaxBlockCount = -1;
            }
            // At this point, we need to recurse and create the sub control for this block.
            // Step 1: Locate the proper struct in the document and construct it's full path.
            string  structName = valueNode.Attributes["struct"].InnerText;
            XmlNode structNode = tagDefinition.SelectSingleNode("//struct[@name='" + structName + "']");

            Controls.BlockContainer fieldControlContainer = new Controls.BlockContainer();
            fieldControlContainer.Globals = new ContainerGlobals(globals, structNode, maxDepth);
            InitContainer(fieldControlContainer);
            fieldControlContainer.ContainerName     = StringOps.CapitalizeWords(fieldControl.Title);
            fieldControlContainer.FooterText        = "End of '" + fieldControlContainer.ContainerName + "' Block";
            fieldControlContainer.BoundPropertyName = fullPropertyName;
            //fieldControlContainer.Block.BlockChanged += new BlockChangedHandler();

            // add the IBlockControl
            fieldControlContainer.AddField(fieldControl);

            containers.Peek().AddFieldContainer(fieldControlContainer);

            // Step 3: Wire up the BlockChanged event for databinding.
            blockControl.Initialize();
        }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of BlockArguments.
 /// </summary>
 /// <param name="parent">The parent block's arguments for this block. Null if this is the main block.</param>
 public ContainerGlobals(ContainerGlobals parent, XmlNode node, int maxDepth) : this()
 {
     MaxDepth  = maxDepth;
     BlockNode = node;
     Parent    = parent;
     if (parent != null)
     {
         TagDefinition = parent.TagDefinition;
     }
 }
Exemple #3
0
 void Subblock_OnExpanding(IDynamicContainer container, ContainerGlobals globals)
 {
     if (container.Globals != null)
     {
         if (!container.Globals.IsLoaded)
         {
             LoadBlock(container);
         }
     }
     ForceAutoCenter();
 }
Exemple #4
0
        protected void ProcessRegion(ContainerGlobals parent, XmlNode node, bool mainBlock, int maxDepth)
        {
            RegionContainer container = new RegionContainer();

            ContainerGlobals globals = new ContainerGlobals(parent.Parent, node, maxDepth);

            if (globals.Parent == null)
            {
                globals.TagDefinition = tagDefinition;
            }
            globals.DepthDifference = parent.DepthDifference - 1;
            container.Globals       = globals;
            InitContainer(container);
            //container.FieldPanel = BuildStruct(globals);
            container.FooterText      = "End of '" + container.ContainerName + "' Region";
            container.PerformingLoad += new DynamicContainerDelegate(Subblock_OnExpanding);
            containers.Peek().AddFieldContainer(container);
        }
Exemple #5
0
        protected FieldContainerBase(ContainerGlobals globals) : this()
        {
            XmlNode node = globals.BlockNode.SelectSingleNode("name");

            if (node != null)
            {
                Name = StringOps.CapitalizeWords(node.InnerText);
            }
            node = globals.BlockNode.SelectSingleNode("shortdesc");
            if (node != null)
            {
                ShortDescription = StringOps.CapitalizeWords(node.InnerText);
            }
            node = globals.BlockNode.SelectSingleNode("longdesc");
            if (node != null)
            {
                LongDescription = StringOps.CapitalizeWords(node.InnerText);
            }
        }
Exemple #6
0
        protected void ProcessSection(ContainerGlobals parent, XmlNode node, bool mainBlock, int maxDepth)
        {
            SectionContainer container = new SectionContainer();

            ContainerGlobals globals = new ContainerGlobals(parent.Parent, node, maxDepth);

            if (globals.Parent == null)
            {
                globals.TagDefinition = tagDefinition;
            }
            globals.DepthDifference = parent.DepthDifference - 1;

            container.Globals = globals;

            InitContainer(container);

            container.FooterText = "End of '" + container.ContainerName + "' Section";

            containers.Peek().AddFieldContainer(container);
        }
Exemple #7
0
        /// <summary>
        /// Builds a BlockContainer control, populating it with the appropriate controls
        /// based on the supplied XML TDF data.
        /// </summary>
        protected BlockContainerPanel BuildStruct(ContainerGlobals globals)
        {
            XmlNode node      = globals.BlockNode;
            bool    mainBlock = globals.MainBlock;
            int     maxDepth  = globals.MaxDepth;

            //int depth = (int)buildDepth.Peek();

            // Setup the block container.
            BlockContainerPanel container = new BlockContainerPanel();

            container.Name = node.Attributes["name"].Value;
            container.SuspendLayout();
            container.Location          = new Point(0, 0);
            container.LinkedUndoManager = undoManager;
            container.LinkedUndoManager.StateChanged += new StateChangedHandler(LinkedUndoManager_StateChanged);
            containers.Push(container);

            XmlNodeList valueNodes = node.SelectNodes("*");

            foreach (XmlNode valueNode in valueNodes)
            {
                if (valueNode.Name.ToLower() == "group")
                {
                    ProcessGroup(container, valueNode, mainBlock, maxDepth);
                }
                else if (valueNode.Name.ToLower() == "section")
                {
                    ProcessSection(globals, valueNode, mainBlock, maxDepth);
                }
                else if (valueNode.Name.ToLower() == "region")
                {
                    ProcessRegion(globals, valueNode, mainBlock, maxDepth);
                }
                else if (valueNode.Name.ToLower() == "value")
                {
                    string        valueName = valueNode.Attributes["name"].InnerText;
                    IFieldControl fieldControl;
                    string        valueText        = valueNode.Attributes["type"].InnerText;
                    string        fullPropertyName = (mainBlock ? className + "Values." : "") + GlobalMethods.MakePublicName(valueName);

                    // Create the proper control based on the name that we got from the XML.
                    if (gameDefinition.FieldControlTable.ContainsKey(valueText))
                    {
                        Type     fieldControlType = gameDefinition.FieldControlTable[valueText];
                        Assembly targetAssembly   = Assembly.GetAssembly(fieldControlType);
                        fieldControl = (targetAssembly.CreateInstance(fieldControlType.FullName) as IFieldControl);

                        fieldControl.Configure(valueNode);
                        //((Control)fieldControl).Font = new Font("Verdana", 6.75f); // Set in Interfaces\TagEditor\FieldControl.cs
                        if (valueText != "Block")
                        {
                            // If this is a tag reference control, hook up its events.
                            if (fieldControl is ITagReferenceControl)
                            {
                                (fieldControl as ITagReferenceControl).OpenTag += new OpenTagEventHandler(TagEditorControl_OpenTag);
                            }

                            IFieldControlContainer c = containers.Peek();
                            c.AddField(fieldControl);
                            (fieldControl as Control).Visible = true;
                        }
                        else
                        {
                            ProcessBlock(globals, valueNode, fieldControl, fullPropertyName);
                        }
                    }
                    else
                    {
                        continue;
                    }
                    fieldControl.BoundPropertyName = fullPropertyName;
                }
            }
//      depth = (int)(buildDepth.Pop());
//    buildDepth.Push(depth - 1);
            containers.Pop();
            container.ResumeLayout(false);
            container.Width = container.Width;
            return(container);
        }
Exemple #8
0
 public void AddChild(ContainerGlobals child)
 {
     Children.Add(child);
 }