/// <summary> /// Runs create new model procedure. /// </summary> public void AddNewObjectUI() { string name = ""; while (true) { Type type = baseType; if (extraTypes.Length > 1) { if (ObjectSelector.Show(this, "Select class", "Add", extraTypes.ToDictionary(tt => tt.Name), out type)) { } else { return; } } name = NameDialog.Show(this, "Create new " + objectName + ":", "Add " + objectName, name); if (name == null) { return; } var fullPath = Path.Combine(fullSourceFolder, name + ".xml"); if (File.Exists(fullPath)) { var r = MessageBox.Show(this, string.Format("{0} '{1}' already exists", objectName, name), "Add", MessageBoxButtons.OKCancel); if (r == DialogResult.OK) { continue; } else { return; } } var newObject = Activator.CreateInstance(type); File.WriteAllText(fullPath, Misc.SaveObjectToXml(newObject, baseType, extraTypes)); RefreshFileList(); return; } }