예제 #1
0
        public static string ShowBrowseFolderDialog(string title, ref string defaultPath)
        {
            var filename = MacUtils.ShowBrowseFolderDialog(title, ref defaultPath);

            if (!string.IsNullOrEmpty(filename))
            {
                if (Directory.Exists(filename))
                {
                    defaultPath = filename;
                }
                else
                {
                    defaultPath = Path.GetDirectoryName(filename);
                }
                return(defaultPath);
            }
            return(null);
        }
예제 #2
0
        public static string ShowBrowseFolderDialog(string title, ref string defaultPath)
        {
#if FAMISTUDIO_MACOS
            var filename = MacUtils.ShowBrowseFolderDialog(title, defaultPath);
            if (!string.IsNullOrEmpty(filename))
            {
                if (Directory.Exists(filename))
                {
                    defaultPath = filename;
                }
                else
                {
                    defaultPath = Path.GetDirectoryName(filename);
                }
                return(defaultPath);
            }
            return(null);
#else
            Gtk.FileChooserDialog filechooser =
                new Gtk.FileChooserDialog("Choose the file to save",
                                          null,
                                          FileChooserAction.Save,
                                          "Cancel", ResponseType.Cancel,
                                          "Save", ResponseType.Accept);

            filechooser.KeepAbove       = true;
            filechooser.Modal           = true;
            filechooser.Action          = FileChooserAction.SelectFolder;
            filechooser.SkipTaskbarHint = true;
            filechooser.TransientFor    = FamiStudioForm.Instance;
            filechooser.SetCurrentFolder(defaultPath);

            string filename = null;
            if (filechooser.Run() == (int)ResponseType.Accept)
            {
                filename    = filechooser.Filename;
                defaultPath = Path.GetDirectoryName(filename);
            }

            filechooser.Destroy();

            return(filename);
#endif
        }