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 FormBlockReplace_Load(object sender, EventArgs e) { try { this.Blueprint.LoadBlocks(); this.BlockIdList = this.Blueprint.BlockDefinitions;// BlockDefinitionStore.LoadBlockDefinitions(); this.GroupMap = BlockDefinitionStore.LoadGroupMap(); this.cmbGroupFrom.Items.Clear(); foreach (var key in this.GroupMap.Keys) { this.cmbGroupFrom.Items.Add(key); } this.cmbGroupTo.Items.Clear(); foreach (var key in this.GroupMap.Keys) { this.cmbGroupTo.Items.Add(key); } this.cmbGroupFrom.SelectedIndex = 0; this.cmbGroupTo.SelectedIndex = 0; this.cmbBlockFrom.DataSource = this.BlockIdList.Select(s => s.Value).ToList(); this.cmbBlockTo.DataSource = this.BlockIdList.Select(s => s.Value).ToList(); this.cmbColor.Items.Clear(); for (int i = 0; i < 32; i++) { var index = this.cmbColor.Items.Add(i); } this.cmbColor.SelectedIndex = 0; this.cmbActionColorNumbers.Items.Clear(); for (int i = 0; i < 32; i++) { var index = this.cmbActionColorNumbers.Items.Add(i); } this.cmbActionColorNumbers.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.BlockIdList, this.TargetCondition, this.inputZoom.Value); } 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 Form2_Load(object sender, EventArgs e) { this.Blueprint.LoadBlocks(); this.BlockIdList = BlockDefinitionStore.LoadBlockDefinitions(); }