public static FileInfo OpenFileDialog(string currentFile, string path, string fileType, string fileExt) { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } var ofd = new OpenFileDialog { FileName = !string.IsNullOrWhiteSpace(currentFile) ? Path.GetFileName(currentFile) : PathManager.FilesystemSafeName(Global.Game) + "." + fileExt, InitialDirectory = path, Filter = string.Format("{0} (*.{1})|*.{1}|All Files|*.*", fileType, fileExt), RestoreDirectory = true }; var result = ofd.ShowHawkDialog(); if (result != DialogResult.OK) { return null; } return new FileInfo(ofd.FileName); }
public static MovieZone LoadMacro() { OpenFileDialog dialog = new OpenFileDialog(); dialog.InitialDirectory = SuggestedFolder(); dialog.Filter = "Movie Macros (*.bk2m)|*.bk2m|All Files|*.*"; DialogResult result = dialog.ShowHawkDialog(); if (result != DialogResult.OK) return null; MovieZone ret = new MovieZone(dialog.FileName); if (ret != null) Global.Config.RecentMacros.Add(dialog.FileName); return ret; }
private void button1_Click(object sender, EventArgs e) { using (var ofd = new OpenFileDialog { InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries["Global_NULL", "ROM"].Path, "Global_NULL"), Filter = MainForm.RomFilter, RestoreDirectory = true }) { var result = ofd.ShowHawkDialog(); if (result == DialogResult.OK) { PathBox.Text = ofd.FileName; } } }
public static FileInfo GetWatchFileFromUser(string currentFile) { var ofd = new OpenFileDialog(); if (!string.IsNullOrWhiteSpace(currentFile)) { ofd.FileName = Path.GetFileNameWithoutExtension(currentFile); } ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.WatchPathFragment, null); ofd.Filter = "Watch Files (*.wch)|*.wch|All Files|*.*"; ofd.RestoreDirectory = true; var result = ofd.ShowHawkDialog(); if (result != DialogResult.OK) { return null; } return new FileInfo(ofd.FileName); }
private void ImportMovieMenuItem_Click(object sender, EventArgs e) { var ofd = new OpenFileDialog { InitialDirectory = PathManager.GetRomsPath(Global.Emulator.SystemId), Multiselect = true, Filter = FormatFilter( "Movie Files", "*.fm2;*.mc2;*.mcm;*.mmv;*.gmv;*.vbm;*.lsmv;*.fcm;*.fmv;*.vmv;*.nmv;*.smv;*.ymv;*.zmv;*.bkm;*.pjm;*.pxm", "FCEUX", "*.fm2", "PCEjin/Mednafen", "*.mc2;*.mcm", "Dega", "*.mmv", "Gens", "*.gmv", "Visual Boy Advance", "*.vbm", "LSNES", "*.lsmv", "FCEU", "*.fcm", "Famtasia", "*.fmv", "VirtuaNES", "*.vmv", "Nintendulator", "*.nmv", "Snes9x", "*.smv", "Yabause", "*.ymv", "ZSNES", "*.zmv", "PSXjin", "*.pjm", "PCSX", "*.pxm", "BizHawk Bkm", "*.bkm", "All Files", "*.*"), RestoreDirectory = false }; var result = ofd.ShowHawkDialog(); if (result == DialogResult.OK) { foreach (var fn in ofd.FileNames) { ProcessMovieImport(fn); } } }
private void OpenAdvancedMenuItem_Click(object sender, EventArgs e) { var oac = new OpenAdvancedChooser(this); if (oac.ShowHawkDialog() == System.Windows.Forms.DialogResult.Cancel) return; if (oac.Result == OpenAdvancedChooser.Command.RetroLaunchNoGame) { var argsNoGame = new LoadRomArgs(); argsNoGame.OpenAdvanced = new OpenAdvanced_LibretroNoGame(Global.Config.LibretroCore); LoadRom("", argsNoGame); return; } var args = new LoadRomArgs(); var filter = RomFilter; if (oac.Result == OpenAdvancedChooser.Command.RetroLaunchGame) { args.OpenAdvanced = new OpenAdvanced_Libretro(); filter = oac.SuggestedExtensionFilter; } else if (oac.Result == OpenAdvancedChooser.Command.ClassicLaunchGame) args.OpenAdvanced = new OpenAdvanced_OpenRom(); else throw new InvalidOperationException("Automatic Alpha Sanitizer"); //----------------- //CLONE OF CODE FROM OpenRom (mostly) var ofd = new OpenFileDialog { InitialDirectory = PathManager.GetRomsPath(Global.Emulator.SystemId), Filter = filter, RestoreDirectory = false, FilterIndex = _lastOpenRomFilter, Title = "Open Advanced" }; var result = ofd.ShowHawkDialog(); if (result != DialogResult.OK) { return; } var file = new FileInfo(ofd.FileName); Global.Config.LastRomPath = file.DirectoryName; _lastOpenRomFilter = ofd.FilterIndex; //----------------- LoadRom(file.FullName, args); }
private void LoadTableFileMenuItem_Click(object sender, EventArgs e) { string romName; string intialDirectory; if (Global.Config.RecentRoms.MostRecent.Contains('|')) { romName = Global.Config.RecentRoms.MostRecent.Split('|').Last(); intialDirectory = Global.Config.RecentRoms.MostRecent.Split('|').First(); } else { romName = Global.Config.RecentRoms.MostRecent; intialDirectory = Path.GetDirectoryName(PathManager.MakeAbsolutePath(romName, null)); } var ofd = new OpenFileDialog { FileName = Path.GetFileNameWithoutExtension(romName) + ".tbl", InitialDirectory = intialDirectory, Filter = "Text Table files (*.tbl)|*.tbl|All Files|*.*", RestoreDirectory = false }; var result = ofd.ShowHawkDialog(); if (result == DialogResult.OK) { LoadTable(ofd.FileName); RecentTables.Add(ofd.FileName); UpdateValues(); } }
private void OpenRom() { var ofd = new OpenFileDialog { InitialDirectory = PathManager.GetRomsPath(Global.Emulator.SystemId), Filter = RomFilter, RestoreDirectory = false, FilterIndex = _lastOpenRomFilter }; var result = ofd.ShowHawkDialog(); if (result != DialogResult.OK) { return; } var file = new FileInfo(ofd.FileName); Global.Config.LastRomPath = file.DirectoryName; _lastOpenRomFilter = ofd.FilterIndex; LoadRom(file.FullName); }
private void LoadStateAs() { if (!Global.Emulator.HasSavestates()) { return; } var ofd = new OpenFileDialog { InitialDirectory = PathManager.GetSaveStatePath(Global.Game), Filter = "Save States (*.State)|*.State|All Files|*.*", RestoreDirectory = true }; var result = ofd.ShowHawkDialog(); if (result != DialogResult.OK) { return; } if (File.Exists(ofd.FileName) == false) { return; } LoadState(ofd.FileName, Path.GetFileName(ofd.FileName)); }
private static FileInfo GetFileFromUser(string filter) { var ofd = new OpenFileDialog { InitialDirectory = PathManager.GetLuaPath(), Filter = filter, RestoreDirectory = true }; if (!Directory.Exists(ofd.InitialDirectory)) { Directory.CreateDirectory(ofd.InitialDirectory); } var result = ofd.ShowHawkDialog(); return result == DialogResult.OK ? new FileInfo(ofd.FileName) : null; }
private void BrowseMovies_Click(object sender, EventArgs e) { var ofd = new OpenFileDialog { Filter = "Movie Files (*." + MovieService.DefaultExtension + ")|*." + MovieService.DefaultExtension + "|TAS project Files (*." + TasMovie.Extension + ")|*." + TasMovie.Extension + "|All Files|*.*", InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null) }; var result = ofd.ShowHawkDialog(); if (result == DialogResult.OK) { var file = new FileInfo(ofd.FileName); if (!file.Exists) { return; } int? index = AddMovieToList(ofd.FileName, true); RefreshMovieList(); if (index.HasValue) { MovieView.SelectedIndices.Clear(); MovieView.setSelection(index.Value); MovieView.SelectItem(index.Value, true); } } }
private void LoadConfigFromMenuItem_Click(object sender, EventArgs e) { var path = PathManager.DefaultIniPath; var ofd = new OpenFileDialog { InitialDirectory = Path.GetDirectoryName(path), FileName = Path.GetFileName(path), Filter = "Config File (*.ini)|*.ini" }; var result = ofd.ShowHawkDialog(); if (result == DialogResult.OK) { Global.Config = ConfigService.Load<Config>(ofd.FileName); Global.Config.ResolveDefaults(); GlobalWin.OSD.AddMessage("Config file loaded"); } }
public static FileInfo GetCdlFileFromUser(string currentFile) { var ofd = new OpenFileDialog { Filter = "Code Data Logger Files (*.cdl)|*.cdl|All Files|*.*", InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.LogPathFragment, null), RestoreDirectory = true }; if (!string.IsNullOrWhiteSpace(currentFile)) { ofd.FileName = Path.GetFileNameWithoutExtension(currentFile); } var result = ofd.ShowHawkDialog(); if (result != DialogResult.OK) { return null; } return new FileInfo(ofd.FileName); }
public static FileInfo GetCheatFileFromUser(string currentFile) { var ofd = new OpenFileDialog(); if (!string.IsNullOrWhiteSpace(currentFile)) { ofd.FileName = Path.GetFileNameWithoutExtension(currentFile); } ofd.InitialDirectory = PathManager.GetCheatsPath(Global.Game); ofd.Filter = "Cheat Files (*.cht)|*.cht|All Files|*.*"; ofd.RestoreDirectory = true; var result = ofd.ShowHawkDialog(); if (result != DialogResult.OK) { return null; } return new FileInfo(ofd.FileName); }
private void OpenRom() { var ofd = new OpenFileDialog { InitialDirectory = PathManager.GetRomsPath(Global.Emulator.SystemId) }; // adelikat: ugly design for this, I know if (VersionInfo.DeveloperBuild) { ofd.Filter = FormatFilter( "Rom Files", "*.nes;*.fds;*.sms;*.gg;*.sg;*.pce;*.sgx;*.bin;*.smd;*.rom;*.a26;*.a78;*.cue;*.exe;*.gb;*.gbc;*.gen;*.md;*.col;.int;*.smc;*.sfc;*.prg;*.d64;*.g64;*.crt;*.sgb;*.xml;*.z64;*.v64;*.n64;*.ws;*.wsc;%ARCH%", "Music Files", "*.psf;*.sid", "Disc Images", "*.cue", "NES", "*.nes;*.fds;%ARCH%", "Super NES", "*.smc;*.sfc;*.xml;%ARCH%", "Master System", "*.sms;*.gg;*.sg;%ARCH%", "PC Engine", "*.pce;*.sgx;*.cue;%ARCH%", "TI-83", "*.rom;%ARCH%", "Archive Files", "%ARCH%", "Savestate", "*.state", "Atari 2600", "*.a26;*.bin;%ARCH%", "Atari 7800", "*.a78;*.bin;%ARCH%", "Genesis", "*.gen;*.smd;*.bin;*.md;*.cue;%ARCH%", "Gameboy", "*.gb;*.gbc;*.sgb;%ARCH%", "Colecovision", "*.col;%ARCH%", "Intellivision (very experimental)", "*.int;*.bin;*.rom;%ARCH%", "PSX Executables (very experimental)", "*.exe", "PSF Playstation Sound File (very experimental)", "*.psf", "Commodore 64 (experimental)", "*.prg; *.d64, *.g64; *.crt;%ARCH%", "SID Commodore 64 Music File", "*.sid;%ARCH%", "Nintendo 64", "*.z64;*.v64;*.n64", "WonderSawn", "*.ws;*.wsc;%ARCH%", "All Files", "*.*"); } else { ofd.Filter = FormatFilter( "Rom Files", "*.nes;*.fds;*.sms;*.gg;*.sg;*.gb;*.gbc;*.pce;*.sgx;*.bin;*.smd;*.gen;*.md;*.smc;*.sfc;*.a26;*.a78;*.col;*.rom;*.cue;*.sgb;*.z64;*.v64;*.n64;*.ws;*.wsc;*.xml;%ARCH%", "Disc Images", "*.cue", "NES", "*.nes;*.fds;%ARCH%", "Super NES", "*.smc;*.sfc;*.xml;%ARCH%", "Nintendo 64", "*.z64;*.v64;*.n64", "Gameboy", "*.gb;*.gbc;*.sgb;%ARCH%", "Master System", "*.sms;*.gg;*.sg;%ARCH%", "PC Engine", "*.pce;*.sgx;*.cue;%ARCH%", "Atari 2600", "*.a26;%ARCH%", "Atari 7800", "*.a78;%ARCH%", "Colecovision", "*.col;%ARCH%", "TI-83", "*.rom;%ARCH%", "Archive Files", "%ARCH%", "Savestate", "*.state", "Genesis", "*.gen;*.md;*.smd;*.bin;*.cue;%ARCH%", "WonderSawn", "*.ws;*.wsc;%ARCH%", "All Files", "*.*"); } ofd.RestoreDirectory = false; ofd.FilterIndex = _lastOpenRomFilter; var result = ofd.ShowHawkDialog(); if (result != DialogResult.OK) { return; } var file = new FileInfo(ofd.FileName); Global.Config.LastRomPath = file.DirectoryName; _lastOpenRomFilter = ofd.FilterIndex; LoadRom(file.FullName); }