public static string ShowSaveFileDialog(string title, string extensions, ref string defaultPath) { var extensionList = GetExtensionList(extensions); #if FAMISTUDIO_MACOS var filename = MacUtils.ShowSaveDialog(title, extensionList, defaultPath); if (!string.IsNullOrEmpty(filename)) { defaultPath = Path.GetDirectoryName(filename); } return(filename); #else Gtk.FileChooserDialog filechooser = new Gtk.FileChooserDialog(title, null, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept); filechooser.KeepAbove = true; filechooser.Modal = true; filechooser.SkipTaskbarHint = true; filechooser.TransientFor = FamiStudioForm.Instance; filechooser.SetCurrentFolder(defaultPath); 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; // GTK file chooser does not add the extension automatically. var extension = Path.GetExtension(filename).ToLower(); var desiredExtension = $".{extensionList[0]}"; if (extension != desiredExtension) { filename = Path.ChangeExtension(filename, desiredExtension); } defaultPath = Path.GetDirectoryName(filename); } filechooser.Destroy(); return(filename); #endif }
public static string ShowSaveFileDialog(string title, string extensions, ref string defaultPath) { var extensionList = GetExtensionList(extensions); var filename = MacUtils.ShowSaveDialog(title, extensionList, defaultPath); if (!string.IsNullOrEmpty(filename)) { defaultPath = Path.GetDirectoryName(filename); } return(filename); }
public static string ShowSaveFileDialog(string title, string extensions) { var extensionList = GetExtensionList(extensions); #if FAMISTUDIO_MACOS return(MacUtils.ShowSaveDialog(title, extensionList)); #else Gtk.FileChooserDialog filechooser = new Gtk.FileChooserDialog("Choose the file to open", null, FileChooserAction.Save, "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 ShowSaveFileDialog(string title, string extensions) { return(MacUtils.ShowSaveDialog(title, GetExtensionList(extensions))); }