public void fillDataGridView(TPF menuTPF, DRB menuDRB) { iconBindingSource.Clear(); textures = new List <string>(); foreach (TPF.Texture entry in menuTPF.Textures) { textures.Add(entry.Name); } List <string> sortedNames = new List <string>(textures); sortedNames.Sort(); dgvIconsTextureCol.DataSource = sortedNames; drb = menuDRB; sprites = new List <SpriteWrapper>(); DRB.Dlg icons = menuDRB.Dlgs.Find(dlg => dlg.Name == "Icon"); foreach (DRB.Dlgo dlgo in icons.Dlgos.Where(dlgo => dlgo.Shape is DRB.Shape.Sprite)) { sprites.Add(new SpriteWrapper(dlgo, textures)); } sprites.Sort(); iconBindingSource.DataSource = sprites; }
private void btnAddIcon_Click(object sender, EventArgs e) { int id = (int)nudIconID.Value; if (shapePresent(id)) { DialogResult choice = MessageBox.Show("That icon ID is already in use.\nWould you like to use the next available one?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (choice == DialogResult.Yes) { while (shapePresent(id)) { id++; } if (id > 9999) { ShowError("ID may not exceed 9999."); return; } nudIconID.Value = id; } else { return; } } var shape = new DRB.Shape.Sprite() { TexLeftEdge = 1, TexTopEdge = 1, TexRightEdge = (short)(remastered ? 160 : 80), TexBottomEdge = (short)(remastered ? 180 : 90), }; var control = new DRB.Control.Static(); var dlgo = new DRB.Dlgo($"EquIcon_{id:D4}", shape, control); DRB.Dlg icons = drb.Dlgs.Find(dlg => dlg.Name == "Icon"); icons.Dlgos.Add(dlgo); var sprite = new SpriteWrapper(dlgo, textures); iconBindingSource.Add(sprite); sprites.Sort(); foreach (DataGridViewRow row in dgvIcons.Rows) { if ((int)row.Cells[0].Value == id) { dgvIcons.CurrentCell = row.Cells[0]; } } }