public NewModPropNewForm(NewModForm modform, ListViewItem listViewItem) { InitializeComponent(); Modform = modform; WorkingListViewItem = listViewItem; // Clears all items inside of GroupComboBox. GroupComboBox.Items.Clear(); // Adds all groups from the ListView into GroupComboBox. foreach (ListViewGroup group in modform.GetListView().Groups) { GroupComboBox.Items.Add(group.Header); } // Adds "Add Group" to GroupComboBox so the user can create groups. GroupComboBox.Items.Add("Add Group"); GroupComboBox.SelectedIndex = 0; Text = "New Property"; if (listViewItem != null) { Text = "Edit Property"; label1.Text = "Edit Property: " + listViewItem.Text; TypeComboBox.Text = listViewItem.Tag as string; textBox1.Text = listViewItem.Text; GroupComboBox.SelectedIndex = modform.GetListView().Groups.IndexOf(listViewItem.Group); AddButton.Text = "Update"; ValueTextBox.Select(); UpdateType(); // Parses the text. switch (listViewItem.Tag) { case "Integer": if (listViewItem.SubItems[1].Text.Length > 0) { ValueNumericUpDown.Value = int.Parse(listViewItem.SubItems[1].Text); } break; case "Boolean": if (listViewItem.SubItems[1].Text.Length > 0) { ValueCheckBox.Checked = bool.Parse(listViewItem.SubItems[1].Text); } break; default: ValueTextBox.Text = listViewItem.SubItems[1].Text.Replace("\\n", "\r\n"); break; } } }
private void OkBtn_Click(object sender, EventArgs e) { Close(); if (RadioButton_Make.Checked) { var nmnf = new NewModNameForm(); if (nmnf.ShowDialog() == DialogResult.OK) { var nmf = new NewModForm(nmnf.GetModName()); nmf.ShowDialog(); } } if (RadioButton_Folder.Checked) { var sfd = new SaveFileDialog() { Title = "Install Mod From Folder...", FileName = "Enter into a directory that contains mod.ini and press Save" }; if (sfd.ShowDialog() == DialogResult.OK) { InstallFromFolder(Path.GetDirectoryName(sfd.FileName)); } } if (RadioButton_Archive.Checked) { var ofd = new OpenFileDialog() { Title = "Install Mod From Archive...", Filter = "All Supported Archives (*.zip, *.7z, *.rar)|*.zip;*.7z;*.rar" }; if (ofd.ShowDialog() == DialogResult.OK) { InstallFromZip(ofd.FileName); } } }