public static Project CreateNewProject(string ProjectPath, string ProjectName, Dictionary <string, string> FilesToAdd, string ProjectMap = null) { try { Project newproj = new Project(); newproj.ProjectName = ProjectName; newproj.SetLocation(ProjectPath); MapList MapList = MapList.GetByName(ProjectMap); if (MapList.MapFiles != null) { foreach (MapFile file in MapList.MapFiles) { FilesToAdd.Add(file.FileName, file.LocalFileName); } } foreach (KeyValuePair <string, string> Entry in FilesToAdd) { try { ProjectMeta meta = new ProjectMeta(newproj, Entry.Key); string path = Path.Combine(newproj.GetSourceDirectory(), Entry.Key); string p = Path.GetDirectoryName(path); if (!Directory.Exists(p)) { Directory.CreateDirectory(p); } File.WriteAllText(path, meta.ParseFileContents(File.ReadAllText(Entry.Value))); } catch (Exception ex) { MessageBox.Show(Configuration.DEBUGMODE ? ex.ToString() : ex.Message); } } ProjectManager.SaveProject(ProjectPath, newproj); Properties.Settings.Default.ProjectLocations.Add(ProjectPath); Properties.Settings.Default["CurrentOpenProject"] = ProjectPath; Properties.Settings.Default.Save(); return(newproj); } catch (Exception ex) { MessageBox.Show(Configuration.DEBUGMODE ? ex.ToString() : ex.Message); return(null); } }
private void button1_Click(object sender, EventArgs e) { FolderBrowserDialog fbd = new FolderBrowserDialog(); if (textBox1.Text != "") { if (fbd.ShowDialog() == DialogResult.OK) { Properties.Settings.Default["NewProjectLocation"] = fbd.SelectedPath; } } Properties.Settings.Default["NewProjectName"] = textBox1.Text; Properties.Settings.Default["NewProjectMap"] = MapList.GetByName((string)comboBox1.SelectedItem).FriendlyName; Properties.Settings.Default.Save(); this.Close(); }