private void AddMaterial(object sender, EventArgs e) { if (!Panel_Main.Visible) { return; } // Ask user for material name. NewObjectForm form = new NewObjectForm(true); form.SetLabel(Language.GetString("$QUESTION_NAME_OF_MAT")); form.LoadOption(new MaterialAddOption()); if (form.ShowDialog() == DialogResult.OK) { if (mtl.Materials.ContainsKey(FNV64.Hash(form.GetInputText()))) { MessageBox.Show("Found duplicate material. Will not be adding new material!", "Toolkit"); return; } // Create material with new name. IMaterial mat = MaterialFactory.ConstructMaterial(mtl.Version); mat.SetName(form.GetInputText()); mtl.Materials.Add(mat.GetMaterialHash(), mat); dataGridView1.Rows.Add(BuildRowData(mat)); } // Cleanup and reload. form.Dispose(); }
private void MatViewPanel_TextureEntryOnDoubleClick(object sender, EventArgs e) { // Get our entry TextureEntry Entry = (sender as TextureEntry); // Create our browser; once the user has finished with this menu they should? have a material. string MaterialName = ""; IMaterial OurMaterial = Entry.GetMaterial(); if (OurMaterial != null) { MaterialName = OurMaterial.GetMaterialName(); } MaterialBrowser Browser = new MaterialBrowser(MaterialName); IMaterial SelectedMaterial = Browser.GetSelectedMaterial(); // Set the new material data, notify the map editor that a change has been made. if (SelectedMaterial != null) { currentMaterials[Entry].MaterialName = SelectedMaterial.GetMaterialName(); currentMaterials[Entry].MaterialHash = SelectedMaterial.GetMaterialHash(); Entry.SetMaterial(SelectedMaterial); OnObjectUpdated(sender, e); } // Yeet the browser into the shadow realm. Browser.Dispose(); Browser = null; Entry.IsSelected = false; }
private DataGridViewRow BuildRowData(IMaterial mat) { DataGridViewRow row = new DataGridViewRow(); row.Tag = mat; row.CreateCells(dataGridView1, new object[] { mat.MaterialName, mat.GetMaterialHash() }); return(row); }