public static bool IsProjectNameDuplicate(string projectName) { foreach (Project project in XmlHandling.GetProjectsFromXml()) { if (project.Name.ToLower() == projectName.ToLower()) { return(true); } } return(false); }
private static void Main(string[] args) { UpdateNGCompilerPaths(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); IDEConfiguration ideConfiguration = IDEConfiguration.Load(); List <Project> availableProjects = XmlHandling.GetProjectsFromXml(); List <Plugin> availablePlugins = XmlHandling.GetPluginsFromXml(); using (IDE ide = new IDE(ideConfiguration, availableProjects, availablePlugins)) { using (FormStart form = new FormStart(ide)) { if (args.Length > 0) { if (Path.GetExtension(args[0]).ToLower() != ".trproj") { MessageBox.Show("Invalid file type. TombIDE can only open .trproj files.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ide.IDEConfiguration.RememberedProject = string.Empty; form.OpenTrprojWithTombIDE(args[0]); // Changes ide.Configuration.RememberedProject to the opened project on success if (string.IsNullOrEmpty(ide.IDEConfiguration.RememberedProject)) { return; // Opening project failed } Application.Run(form); // Reset the RememberedProject setting after closing ide.IDEConfiguration.RememberedProject = string.Empty; ide.IDEConfiguration.Save(); } else { Application.Run(form); } } } #if (DEBUG) System.Diagnostics.Process.GetCurrentProcess().Kill(); // Faster app closing while debugging #endif }
private void button_Apply_Click(object sender, EventArgs e) { try { string newName = PathHelper.RemoveIllegalPathSymbols(textBox_NewName.Text.Trim()); if (string.IsNullOrWhiteSpace(newName) || newName.ToLower() == "engine") { throw new ArgumentException("Invalid name."); } bool renameDirectory = checkBox_RenameDirectory.Checked; if (newName == _targetProject.Name) { // If the name hasn't changed, but the directory name is different and the user wants to rename it if (Path.GetFileName(_targetProject.ProjectPath) != newName && renameDirectory) { HandleDirectoryRenaming(); _targetProject.Rename(newName, true); _targetProject.Save(); } else { DialogResult = DialogResult.Cancel; } } else { // Check if a project with the same name already exists on the list foreach (Project project in XmlHandling.GetProjectsFromXml()) { if (project.Name.ToLower() == newName.ToLower()) { // Check if the project we found IS the current _ide.Project if (project.ProjectPath.ToLower() == _targetProject.ProjectPath.ToLower()) { if (renameDirectory) { HandleDirectoryRenaming(); } break; } else { throw new ArgumentException("A project with the same name already exists on the list."); } } } _targetProject.Rename(newName, renameDirectory); _targetProject.Save(); } } catch (Exception ex) { DarkMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult = DialogResult.None; } }