private void levelBBrowseButton_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Title = "Swap Level B"; dialog.Filter = Ogmo.GetLevelFilter(); dialog.CheckFileExists = true; if (levelBTextbox.Text != "") { dialog.InitialDirectory = Path.GetDirectoryName(Path.Combine(Ogmo.Project.SavedDirectory, levelBTextbox.Text)); } else if (levelATextbox.Text != "") { dialog.InitialDirectory = Path.GetDirectoryName(Path.Combine(Ogmo.Project.SavedDirectory, levelATextbox.Text)); } else { dialog.InitialDirectory = Ogmo.Project.SavedDirectory; } DialogResult result = dialog.ShowDialog(this); if (result == System.Windows.Forms.DialogResult.OK) { levelBTextbox.Text = Util.RelativePath(Ogmo.Project.SavedDirectory, dialog.FileName); } }
private void performButton_Click(object sender, EventArgs e) { IEnumerable <string> files = null; if (allRadioButton.Checked) { files = Directory.EnumerateFiles(Ogmo.Project.SavedDirectory, "*.oel", SearchOption.AllDirectories); } else if (levelsRadioButton.Checked) { OpenFileDialog dialog = new OpenFileDialog(); dialog.InitialDirectory = Ogmo.Project.SavedDirectory; dialog.Title = "Batch Resaver"; dialog.Multiselect = true; dialog.Filter = Ogmo.GetLevelFilter(); dialog.CheckFileExists = true; DialogResult result = dialog.ShowDialog(this); if (result == System.Windows.Forms.DialogResult.Cancel) { return; } files = dialog.FileNames; } else if (directoryRadioButton.Checked) { FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.ShowNewFolderButton = false; dialog.SelectedPath = Ogmo.Project.SavedDirectory; dialog.RootFolder = Environment.SpecialFolder.MyDocuments; dialog.Description = "Select a folder to search for levels to resave."; DialogResult result = dialog.ShowDialog(this); if (result == System.Windows.Forms.DialogResult.Cancel) { return; } files = Directory.EnumerateFiles(dialog.SelectedPath, "*.oel", SearchOption.AllDirectories); } ResaveLevels(files); }
public bool SaveAs() { SaveFileDialog dialog = new SaveFileDialog(); if (Project.RecentLevelDirectory == "" || !Directory.Exists(Project.RecentLevelDirectory)) { dialog.InitialDirectory = Project.SavedDirectory; } else { dialog.InitialDirectory = Project.RecentLevelDirectory; } dialog.RestoreDirectory = true; dialog.FileName = SaveName; dialog.OverwritePrompt = true; dialog.Filter = Ogmo.GetLevelFilter(); //Handle cancel if (dialog.ShowDialog() == DialogResult.Cancel) { return(false); } SavePath = dialog.FileName; WriteTo(dialog.FileName); // Remember this directory string fileDirectory = Path.GetDirectoryName(dialog.FileName); if (Project.RecentLevelDirectory != fileDirectory) { Project.RecentLevelDirectory = fileDirectory; Project.Save(); } return(true); }