private void FormDefineEditor_Load(object sender, EventArgs e)
        {
            try
            {
                this.BlockIdList = BlockDefinitionStore.LoadBlockDefinitions();
                this.Tree        = CategoryTree.Load(CategoryTree.CATEGORY_TREE_FILE);
                this.AddSubCategories(this.Tree.SubCategories, 0);

                var table = new DataTable();
                table.Columns.Add("UID");
                table.Columns.Add("Name");
                table.Columns.Add("Wdith");
                table.Columns.Add("Height");
                table.Columns.Add("Length");
                table.Columns.Add("Definitions");
                table.Columns.Add("Category");
                table.Columns.Add("Grouped");
                table.Columns.Add("IsSubconstruction");

                foreach (var item in this.BlockIdList.Values)
                {
                    table.Rows.Add(new object[] { item.Uid, item.Name, item.Width, item.Height, item.Length, item.Defined, item.Category, item.Grouped, item.IsSubconstruction });
                }

                this.dataGridView1.DataSource = table;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                this.BlockIdList.Clear();
                foreach (DataGridViewRow row in this.dataGridView1.Rows)
                {
                    var uid               = row.Cells[0].Value as string;
                    var name              = row.Cells[1].Value as string;
                    var width             = row.Cells[2].Value as string;
                    var height            = row.Cells[3].Value as string;
                    var length            = row.Cells[4].Value as string;
                    var category          = row.Cells[6].Value as string;
                    var isSubconstruction = row.Cells[8].Value as string;

                    var item = new BlockDefinition();
                    item.Uid      = uid;
                    item.Name     = name;
                    item.Category = category;
                    int temp;
                    if (int.TryParse(width, out temp))
                    {
                        item.Width = temp;
                    }
                    if (int.TryParse(height, out temp))
                    {
                        item.Height = temp;
                    }
                    if (int.TryParse(length, out temp))
                    {
                        item.Length = temp;
                    }

                    bool tempFlag = false;
                    if (bool.TryParse(isSubconstruction, out tempFlag))
                    {
                        item.IsSubconstruction = tempFlag;
                    }

                    this.BlockIdList.Add(uid, item);
                }

                this.FillCategoryItems(this.Tree);

                BlockDefinitionStore.SaveBlockDefinitions(this.BlockIdList);
                CategoryTree.Save(CategoryTree.CATEGORY_TREE_FILE, this.Tree);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void FormBlockErase_Load(object sender, EventArgs e)
        {
            try
            {
                this.Tree = CategoryTree.Load(CategoryTree.CATEGORY_TREE_FILE);
                this.Blueprint.LoadBlocks();
                this.BlockDefinitions = this.Blueprint.BlockDefinitions; // BlockDefinitionStore.LoadBlockDefinitions();

                this.treeBlocks.Nodes.Clear();
                this.AddTreeNode(this.Tree, null);

                {
                    var node = new TreeNode("unknown");
                    var list = this.BlockDefinitions.Where(w => string.IsNullOrEmpty(w.Value.Category)).ToList();
                    foreach (var item in list)
                    {
                        var block = this.BlockDefinitions[item.Key];
                        node.Nodes.Add(block.Name).Tag = block;
                    }
                    this.treeBlocks.Nodes.Add(node);
                }

                {
                    var node = new TreeNode("undefined");
                    this.treeBlocks.Nodes.Add(node);
                }

                this.cmbColor.Items.Clear();
                for (int i = 0; i < 32; i++)
                {
                    var index = this.cmbColor.Items.Add(i);
                }
                this.cmbColor.SelectedIndex = 0;

                this.chkObjects.Items.Clear();
                this.chkObjects.Items.Add("main object", true);
                this.chkObjects.Items.Add("sub object", true);


                this.lblName.Text = this.Blueprint.Name;
                this.FillCondition();
                this.pictureBox1.Image = this.Blueprint.GetBmp(this.BlockDefinitions, this.TargetCondition, this.inputZoom.Value);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }