Beispiel #1
0
        private TreeNode BlockField_CreateTreeNode(BlockField blockField)
        {
            //Prepare
            string displayName = blockField.Name;

            if (string.IsNullOrEmpty(displayName))
            {
                displayName = $"unnamed ({blockField.Create().BlockName})";
            }

            //Create tag block tree node
            TreeNode fieldNode = new TreeNode(displayName)
            {
                Tag = blockField
            };

            //Add children
            foreach (Block tagBlock in blockField.BlockList)
            {
                fieldNode.Nodes.Add(TagBlock_CreateTreeNode(tagBlock));
            }

            //Return
            return(fieldNode);
        }
Beispiel #2
0
        public static TagBlockList FromBlockField(BlockField blockField, int index, int count)
        {
            int addedCount = 0;
            var block      = blockField.Create();
            var data       = new TagBlockList()
            {
                BlockName = block.Name
            };

            for (int i = 0; i < count; i++)
            {
                int currentIndex = index + i;
                if (currentIndex < blockField.BlockList.Count)
                {
                    data.blocks.Add((Block)blockField.BlockList[currentIndex].Clone());
                    addedCount++;
                }
            }

            data.Count = addedCount;
            return(data);
        }
Beispiel #3
0
 public BlockControl(BlockField blockField) : this()
 {
     Tags.GenerateControls(controlsFlowLayoutPanel, blockField.Create());
     titleLabel.Text = blockField.Name;
     Field           = blockField;
 }
Beispiel #4
0
        private void tagStructureTreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            //Hide
            deleteBlockToolStripButton.Visible     = false;
            cloneBlockToolStripButton.Visible      = false;
            addBlockToolStripButton.Visible        = false;
            deleteTagBlocksToolStripButton.Visible = false;
            toolStripSeparator2.Visible            = false;
            copyToolStripMenuItem.Enabled          = false;
            pasteToolStripMenuButton.Enabled       = false;
            toolStripSeparator3.Visible            = false;
            moveBlockUpToolStripButton.Visible     = false;
            moveBlockDownToolStripButton.Visible   = false;

            //Prepare
            BlockField tagBlockField = null;
            DataField  dataField     = null;
            ITagBlock  tagBlock      = null;

            //Check
            if (e.Node.Tag is ITagBlock && e.Node.Parent != null && e.Node.Parent.Tag is BlockField)
            {
                //Get variables
                tagBlock      = (ITagBlock)e.Node.Tag;
                tagBlockField = (BlockField)e.Node.Parent.Tag;

                //Show
                toolStripSeparator2.Visible          = true;
                deleteBlockToolStripButton.Visible   = true;
                copyToolStripMenuItem.Enabled        = true;
                pasteToolStripMenuButton.Enabled     = true;
                cloneBlockToolStripButton.Visible    = tagBlockField.BlockList.Count < tagBlockField.Create().MaximumElementCount;
                toolStripSeparator3.Visible          = true;
                moveBlockUpToolStripButton.Visible   = true;
                moveBlockDownToolStripButton.Visible = true;
            }
            else if (e.Node.Tag is BlockField)
            {
                //Get variables
                tagBlockField = (BlockField)e.Node.Tag;

                //Show
                toolStripSeparator2.Visible            = true;
                deleteTagBlocksToolStripButton.Visible = true;
                copyToolStripMenuItem.Enabled          = true;
                pasteToolStripMenuButton.Enabled       = true;
                addBlockToolStripButton.Visible        = tagBlockField.BlockList.Count < tagBlockField.Create().MaximumElementCount;
            }
            else if (e.Node.Tag is DataField)
            {
                //Get vairables
                dataField = (DataField)e.Node.Tag;

                //Do nothing for now...
                toolStripSeparator2.Visible      = true;
                copyToolStripMenuItem.Enabled    = true;
                pasteToolStripMenuButton.Enabled = true;
            }
            else if (e.Node.Tag is StructField structField)
            {
                //Show
                toolStripSeparator2.Visible      = true;
                copyToolStripMenuItem.Enabled    = true;
                pasteToolStripMenuButton.Enabled = true;
            }
        }