public static string[] ShowOpenFileDialog(string title, string extensions, ref string defaultPath, bool multiselect, Window parentWindow = null) { var extensionList = GetExtensionList(extensions); var filenames = MacUtils.ShowOpenDialog(title, extensionList, multiselect, defaultPath); if (filenames != null && !string.IsNullOrEmpty(filenames[0])) { defaultPath = Path.GetDirectoryName(filenames[0]); } return(filenames); }
public static string ShowOpenFileDialog(string title, string extensions, ref string defaultPath, Window parentWindow = null) { var extensionList = GetExtensionList(extensions); #if FAMISTUDIO_MACOS var filename = MacUtils.ShowOpenDialog(title, extensionList, defaultPath); if (!string.IsNullOrEmpty(filename)) { defaultPath = Path.GetDirectoryName(filename); } return(filename); #else Gtk.Rc.ResetStyles(Gtk.Settings.GetForScreen(Gdk.Screen.Default)); Gtk.Rc.ReparseAll(); Gtk.FileChooserDialog filechooser = new Gtk.FileChooserDialog(title, null, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept); filechooser.KeepAbove = true; filechooser.Modal = true; filechooser.SkipTaskbarHint = true; filechooser.TransientFor = parentWindow != null ? parentWindow : FamiStudioForm.Instance; filechooser.SetCurrentFolder(defaultPath); if (extensionList.Length > 0) { filechooser.Filter = new FileFilter(); foreach (var ext in extensionList) { filechooser.Filter.AddPattern($"*.{ext}"); } } string filename = null; if (filechooser.Run() == (int)ResponseType.Accept) { filename = filechooser.Filename; defaultPath = Path.GetDirectoryName(filename); } filechooser.Destroy(); return(filename); #endif }
public static string ShowOpenFileDialog(string title, string extensions) { var extensionList = GetExtensionList(extensions); #if FAMISTUDIO_MACOS return(MacUtils.ShowOpenDialog(title, extensionList)); #else Gtk.Rc.ResetStyles(Gtk.Settings.GetForScreen(Gdk.Screen.Default)); Gtk.Rc.ReparseAll(); Gtk.FileChooserDialog filechooser = new Gtk.FileChooserDialog("Choose the file to open", null, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept); filechooser.KeepAbove = true; filechooser.Modal = true; filechooser.SkipTaskbarHint = true; filechooser.Filter = new FileFilter(); foreach (var ext in extensionList) { filechooser.Filter.AddPattern($"*.{ext}"); } string filename = null; if (filechooser.Run() == (int)ResponseType.Accept) { filename = filechooser.Filename; } ProcessPendingEvents(); filechooser.Destroy(); ProcessPendingEvents(); return(filename); #endif }
public static string ShowOpenFileDialog(string title, string extensions) { return(MacUtils.ShowOpenDialog(title, GetExtensionList(extensions))); }