bool CreateProject() { if (templateView.CurrentlySelected != null) { PropertyService.Set("Dialogs.NewProjectDialog.LastSelectedCategory", ((ProjectTemplate)templateView.CurrentlySelected).Category); string template; // keep the old format if the language is not specified if (String.IsNullOrEmpty(templateView.CurrentlySelected.LanguageName)) { template = templateView.CurrentlySelected.Id; } else // use the newer format with language before id { template = templateView.CurrentlySelected.LanguageName + "/" + templateView.CurrentlySelected.Id; } recentTemplates.Remove(template); recentTemplates.Insert(0, template); if (recentTemplates.Count > 15) { recentTemplates.RemoveAt(recentTemplates.Count - 1); } string strRecent = string.Join(",", recentTemplates.ToArray()); PropertyService.Set("Dialogs.NewProjectDialog.RecentTemplates", strRecent); PropertyService.SaveProperties(); //PropertyService.Set("Dialogs.NewProjectDialog.LargeImages", ((RadioButton)ControlDictionary["largeIconsRadioButton"]).Checked); } string solution = txt_subdirectory.Text; string name = txt_name.Text; string location = ProjectLocation; if (solution.Equals("")) { solution = name; //This was empty when adding after first combine } if ( (CreateSolutionDirectory && !FileService.IsValidPath(solution)) || !FileService.IsValidFileName(name) || name.IndexOf(' ') >= 0 || !FileService.IsValidPath(location)) { MessageService.ShowError(GettextCatalog.GetString("Illegal project name.\nOnly use letters, digits, '.' or '_'.")); return(false); } if (parentFolder != null && parentFolder.ParentSolution.FindProjectByName(name) != null) { MessageService.ShowError(GettextCatalog.GetString("A Project with that name is already in your Project Space")); return(false); } PropertyService.Set( "MonoDevelop.Core.Gui.Dialogs.NewProjectDialog.AutoCreateProjectSubdir", CreateSolutionDirectory); if (templateView.CurrentlySelected == null || name.Length == 0) { return(false); } ProjectTemplate item = (ProjectTemplate)templateView.CurrentlySelected; try { if (Directory.Exists(ProjectLocation)) { var btn = MessageService.AskQuestion(GettextCatalog.GetString("Directory {0} already exists.\nDo you want to continue the Project creation?", ProjectLocation), AlertButton.No, AlertButton.Yes); if (btn != AlertButton.Yes) { return(false); } } System.IO.Directory.CreateDirectory(location); } catch (IOException) { MessageService.ShowError(GettextCatalog.GetString("Could not create directory {0}. File already exists.", location)); return(false); } catch (UnauthorizedAccessException) { MessageService.ShowError(GettextCatalog.GetString("You do not have permission to create to {0}", location)); return(false); } if (newItem != null) { newItem.Dispose(); newItem = null; } try { ProjectCreateInformation cinfo = CreateProjectCreateInformation(); if (newSolution) { newItem = item.CreateWorkspaceItem(cinfo); } else { newItem = item.CreateProject(parentFolder, cinfo); } } catch (UserException ex) { MessageService.ShowError(ex.Message, ex.Details); return(false); } catch (Exception ex) { MessageService.ShowException(ex, GettextCatalog.GetString("The project could not be created")); return(false); } selectedItem = item; return(true); }
bool CreateProject() { if (templateView.CurrentlySelected != null) { PropertyService.Set("Dialogs.NewProjectDialog.LastSelectedCategory", ((ProjectTemplate)templateView.CurrentlySelected).Category); recentIds.Remove(templateView.CurrentlySelected.Id); recentIds.Insert(0, templateView.CurrentlySelected.Id); if (recentIds.Count > 15) { recentIds.RemoveAt(recentIds.Count - 1); } string strRecent = string.Join(",", recentIds.ToArray()); PropertyService.Set("Dialogs.NewProjectDialog.RecentTemplates", strRecent); PropertyService.SaveProperties(); //PropertyService.Set("Dialogs.NewProjectDialog.LargeImages", ((RadioButton)ControlDictionary["largeIconsRadioButton"]).Checked); } string solution = txt_subdirectory.Text; string name = txt_name.Text; string location = entry_location.Path; if (solution.Equals("")) { solution = name; //This was empty when adding after first combine } if ( !FileService.IsValidPath(solution) || !FileService.IsValidFileName(name) || name.IndexOf(' ') >= 0 || !FileService.IsValidPath(location)) { MessageService.ShowError(GettextCatalog.GetString("Illegal project name.\nOnly use letters, digits, '.' or '_'.")); return(false); } if (parentFolder != null && parentFolder.ParentSolution.FindProjectByName(name) != null) { MessageService.ShowError(GettextCatalog.GetString("A Project with that name is already in your Project Space")); return(false); } PropertyService.Set( "MonoDevelop.Core.Gui.Dialogs.NewProjectDialog.AutoCreateProjectSubdir", CreateSolutionDirectory); if (templateView.CurrentlySelected == null || name.Length == 0) { return(false); } ProjectTemplate item = (ProjectTemplate)templateView.CurrentlySelected; try { System.IO.Directory.CreateDirectory(ProjectLocation); } catch (IOException) { MessageService.ShowError(GettextCatalog.GetString("Could not create directory {0}. File already exists.", ProjectLocation)); return(false); } catch (UnauthorizedAccessException) { MessageService.ShowError(GettextCatalog.GetString("You do not have permission to create to {0}", ProjectLocation)); return(false); } ProjectCreateInformation cinfo = CreateProjectCreateInformation(); try { if (newSolution) { newItem = item.CreateWorkspaceItem(cinfo); } else { newItem = item.CreateProject(parentFolder, cinfo); } } catch (Exception ex) { MessageService.ShowException(ex, GettextCatalog.GetString("The project could not be created")); return(false); } selectedItem = item; return(true); }