/// ------------------------------------------------------------------------------------ /// <summary> /// Browse for an existing project. /// </summary> /// ------------------------------------------------------------------------------------ private void tsbBrowse_Click(object sender, EventArgs e) { using (var dlg = new OpenFileDialog()) { var caption = LocalizationManager.LocalizeString( "WelcomeDlg.OpenFileDlgCaption", "Open Sponge Project", "Dialog Boxes"); var prjFilterText = LocalizationManager.LocalizeString( "WelcomeDlg.SpongePrjFileType", "Sponge Project (*.sprj)", "Dialog Boxes"); dlg.Title = caption; dlg.Filter = prjFilterText + "|*.sprj|" + Sponge.OFDlgAllFileTypeText + "|*.*"; dlg.InitialDirectory = SpongeProject.ProjectsFolder; dlg.CheckFileExists = true; dlg.CheckPathExists = true; if (dlg.ShowDialog(this) == DialogResult.Cancel) { return; } Project = SpongeProject.Load(dlg.FileName); if (Project != null) { MruProjects.AddNewPath(dlg.FileName); MruProjects.Save(); } } DialogResult = DialogResult.OK; Close(); }
public void AddNewPath() { // Test a path that does not exists. Assert.IsFalse(MruProjects.AddNewPath(Path.Combine(Path.GetTempPath(), "@#$%badpath"))); Assert.IsTrue(MruProjects.AddNewPath(_prjFiles[0])); Assert.AreEqual(_prjFiles[0], _paths[0]); Assert.AreEqual(1, _paths.Count); Assert.IsTrue(MruProjects.AddNewPath(_prjFiles[1])); Assert.AreEqual(_prjFiles[1], _paths[0]); Assert.AreEqual(2, _paths.Count); Assert.IsTrue(MruProjects.AddNewPath(_prjFiles[2])); Assert.AreEqual(_prjFiles[2], _paths[0]); Assert.AreEqual(3, _paths.Count); // Readd a path that already exists. Assert.IsTrue(MruProjects.AddNewPath(_prjFiles[1])); Assert.AreEqual(_prjFiles[1], _paths[0]); Assert.AreEqual(3, _paths.Count); _paths.Clear(); for (int i = 0; i < _prjFiles.Count; i++) { Assert.IsTrue(MruProjects.AddNewPath(_prjFiles[i])); Assert.IsTrue(_paths.Count <= MruProjects.MaxMRUListSize); if (i < MruProjects.MaxMRUListSize) { Assert.AreEqual(i + 1, _paths.Count); Assert.AreEqual(_prjFiles[i], _paths[0]); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create a new project. /// </summary> /// ------------------------------------------------------------------------------------ private void tsbCreate_Click(object sender, EventArgs e) { Project = SpongeProject.Create(this); if (Project != null) { MruProjects.AddNewPath(Project.FullFilePath); MruProjects.Save(); DialogResult = DialogResult.OK; Close(); } }
public void Latest() { Assert.IsNull(MruProjects.Latest); Assert.IsTrue(MruProjects.AddNewPath(_prjFiles[0])); Assert.AreEqual(_prjFiles[0], MruProjects.Latest); Assert.IsTrue(MruProjects.AddNewPath(_prjFiles[1])); Assert.AreEqual(_prjFiles[1], MruProjects.Latest); Assert.IsTrue(MruProjects.AddNewPath(_prjFiles[2])); Assert.AreEqual(_prjFiles[2], MruProjects.Latest); }
public void AddNewNullPath() { MruProjects.AddNewPath(null); }