Esempio n. 1
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);
        }
Esempio n. 2
0
        private void LoadBlock(IDynamicContainer container)
        {
            this.tagDefinition = container.Globals.TagDefinition;
            //int depth = (int)buildDepth.Pop();
            //buildDepth.Push(depth + 1);
            BlockContainerPanel panel = BuildStruct(container.Globals);

            panel.SuspendLayout();
            panel.DepthDifference = container.Globals.DepthDifference;
            container.FieldPanel  = panel;
            //container.Block.BlockChanged += new BlockChangedHandler(panel.DatabindChildrenToBlock);

            /*if (container.Block != null)
             * {
             * container.Block.BlockChanged += new BlockChangedHandler((panel as BlockContainerPanel).DatabindChildrenToBlock);
             * if (container.Block.SelectedBlockIndex > -1)
             *  (panel as BlockContainerPanel).DatabindChildrenToBlock(container.Block.BlockCollection.GetBlock(container.Block.SelectedBlockIndex));
             * else
             * {
             *  if ((container.Parent != null) && (container.Parent.Block != null) && (container.Parent.Block.SelectedBlockIndex != null))
             *    ((tabArguments[tabControl.SelectedTabIndex].Container as IDynamicContainer).FieldPanel).DatabindChildrenToBlock(container.Parent.Block.BlockCollection.GetBlock(container.Parent.Block.SelectedBlockIndex));
             *  else
             *    ((tabArguments[tabControl.SelectedTabIndex].Container as Control).Controls[0] as BlockContainerPanel).DatabindChildrenToBlock(tabArguments[tabControl.SelectedTabIndex].TagData, container);
             * }
             * }
             * else
             * {
             * //((tabArguments[tabControl.SelectedTabIndex].Container as Control).Controls[0] as BlockContainerPanel).DatabindChildrenToBlock(tabArguments[tabControl.SelectedTabIndex].TagData);
             * if ((container.Parent != null) && (container.Parent.Block != null) && (container.Parent.Block.SelectedBlockIndex != null))
             *  ((tabArguments[tabControl.SelectedTabIndex].Container as IDynamicContainer).FieldPanel).DatabindChildrenToBlock(container.Parent.Block.BlockCollection.GetBlock(container.Parent.Block.SelectedBlockIndex));
             * else
             *  ((tabArguments[tabControl.SelectedTabIndex].Container as Control).Controls[0] as BlockContainerPanel).DatabindChildrenToBlock(tabArguments[tabControl.SelectedTabIndex].TagData, container);
             * }*/
            // Sets the active block to being the block's selection and performs databinding
            IBlockControl block = panel.GetParentBlock();

            if ((block != null) && (block.BlockCollection != null))
            {
                block.BlockChanged += new BlockChangedHandler(panel.DatabindChildrenToBlock);
                IBlock tempBlock = null;
                if (block.BlockCollection.BlockCount > 0)
                {
                    if (block.SelectedBlockIndex > 0)
                    {
                        tempBlock = block.BlockCollection.GetBlock(block.SelectedBlockIndex);
                    }
                    else
                    {
                        block.SelectedBlockIndex = 0;
                        tempBlock = block.BlockCollection.GetBlock(0);
                    }
                }


                // if this is a region, we don't want the databinding to disable the controls.
                // Basically, it will always databind if it's not null, or if it is a block, rather than a region/section/whatever.
                if ((tempBlock != null) || (container is BlockContainer))
                {
                    panel.DatabindChildrenToBlock(tempBlock);
                }
            }
            else
            {
                panel.DatabindChildrenToBlock(tabArguments[tabControl.SelectedTabIndex].TagData, panel);
            }

            // Databind the block.
            if (panel != null)
            {
                panel.Visible = true;
                if (panel is BlockContainerPanel)
                {
                    ConnectBlocks(panel as BlockContainerPanel);
                }
            }
            container.Globals.IsLoaded = true;
            panel.ResumeLayout();
        }