private void Open(FileChooserAction action) { string title = Catalog.GetString("Open"); if (action == FileChooserAction.SelectFolder) { title = Catalog.GetString("Select Folder"); } FileChooserDialog chooser = new FileChooserDialog(title, window, action); chooser.AddButton(Stock.Cancel, ResponseType.Cancel); chooser.AddButton(Stock.Open, ResponseType.Ok); chooser.SetUri(uri.ToString()); int response = chooser.Run(); if ((ResponseType)response == ResponseType.Ok) { CurrentUri = new System.Uri(chooser.Uri); } chooser.Destroy(); }
protected void OnTypeFileComboBoxChanged(object sender, EventArgs e) { switch (typeFileComboBox.ActiveText) { case "Fichier": fileType = FileType.File; fileChooserAction = FileChooserAction.Open; fileDestination = "TO_CP"; openButton.Sensitive = true; break; case "Répertoire": fileType = FileType.Folder; fileChooserAction = FileChooserAction.SelectFolder; fileDestination = "TO_CP"; openButton.Sensitive = true; break; default: // By default, everything is unsensitive openButton.Sensitive = false; duplicationFrame.Sensitive = false; fileFrame.Sensitive = false; break; } }
// creates a custom choose dialog static string[] ChooseDialog(FileChooserAction action, string title, bool many) { FileChooserDialog dialog = new FileChooserDialog (title, null, action); if (last_folder != null) dialog.SetCurrentFolder (last_folder); if (many) dialog.SelectMultiple = true; dialog.AddButton (Stock.Cancel, ResponseType.Cancel); dialog.AddButton (Stock.Ok, ResponseType.Ok); int response = dialog.Run (); string[] ret = null; if ((ResponseType) response == ResponseType.Ok) ret = dialog.Filenames; if ((ResponseType) response == ResponseType.Cancel) ret = null; last_folder = dialog.CurrentFolder; dialog.Destroy (); if(ret != null && ret.Length == 0) ret = null; return ret; }
public FileChooserDialog(string title, Window parent, FileChooserAction action) : base(title, parent, action) { LocalOnly = Banshee.IO.Provider.LocalOnly; SetCurrentFolderUri(LastFileChooserUri.Get(Environment.GetFolderPath(Environment.SpecialFolder.Personal))); WindowPosition = WindowPosition.Center; }
public FileChooserDialog(string backend, string title, Window parent, FileChooserAction action, params object[] button_data) : base(IntPtr.Zero) { if (GetType() != typeof(FileChooserDialog)) { CreateNativeObject(new string[] { "file-system-backend" }, new GLib.Value[] { new GLib.Value(backend) }); Title = title; if (parent != null) { TransientFor = parent; } Action = action; } else { IntPtr ntitle = GLib.Marshaller.StringToPtrGStrdup(title); IntPtr nbackend = GLib.Marshaller.StringToPtrGStrdup(backend); Raw = gtk_file_chooser_dialog_new_with_backend(ntitle, parent == null ? IntPtr.Zero : parent.Handle, (int)action, nbackend, IntPtr.Zero); GLib.Marshaller.Free(ntitle); GLib.Marshaller.Free(nbackend); } for (int i = 0; i < button_data.Length - 1; i += 2) { AddButton((string)button_data [i], (int)button_data [i + 1]); } }
public FileDialog(MainWindow window, FileChooserAction action) { if (action == FileChooserAction.Open) _dialog = new OpenFileDialog (); else _dialog = new FolderBrowserDialog (); }
public PosFilePickerDialog(Window pSourceWindow, DialogFlags pDialogFlags, FileFilter pFileFilter, FileChooserAction pFileChooserAction, string windowName) : base(pSourceWindow, pDialogFlags) { //Parameters _fileFilter = pFileFilter; _fileChooserAction = pFileChooserAction; //Init Local Vars string windowTitle = string.Format("{0} {1}", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "window_title_dialog_filepicker"), windowName); _windowSize = new Size(700, 473); String fileDefaultWindowIcon = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\Windows\icon_window_select_record.png"); //Init Content _fixedContent = new Fixed(); //Call Init UI InitUI(); //ActionArea Buttons TouchButtonIconWithText buttonOk = ActionAreaButton.FactoryGetDialogButtonType(PosBaseDialogButtonType.Ok); TouchButtonIconWithText buttonCancel = ActionAreaButton.FactoryGetDialogButtonType(PosBaseDialogButtonType.Cancel); //ActionArea ActionAreaButtons actionAreaButtons = new ActionAreaButtons(); actionAreaButtons.Add(new ActionAreaButton(buttonOk, ResponseType.Ok)); actionAreaButtons.Add(new ActionAreaButton(buttonCancel, ResponseType.Cancel)); //Init Object this.InitObject(this, pDialogFlags, fileDefaultWindowIcon, windowTitle, _windowSize, _fixedContent, actionAreaButtons); }
public FileSelector(string title, FileChooserAction action) : base(title, null, action) { switch (action) { case FileChooserAction.Open: AddButton(Gtk.Stock.Cancel, ResponseType.Cancel); AddButton(Gtk.Stock.Open, ResponseType.Ok); break; case FileChooserAction.SelectFolder: AddButton(Gtk.Stock.Cancel, ResponseType.Cancel); AddButton(GettextCatalog.GetString("Select Folder"), ResponseType.Ok); break; case FileChooserAction.Save: AddButton(Gtk.Stock.Cancel, ResponseType.Cancel); AddButton(Gtk.Stock.Save, ResponseType.Ok); break; default: break; } DefaultResponse = ResponseType.Ok; CommonSetup(); }
void Open(FileChooserAction action) { string title = Strings.Open; if (action == FileChooserAction.SelectFolder) { title = Strings.SelectFolder; } var chooser = new FileChooserDialog(title, Window, action); chooser.AddButton(Stock.Cancel, ResponseType.Cancel); chooser.AddButton(Stock.Open, ResponseType.Ok); chooser.SetUri(uri.ToString()); int response = chooser.Run(); if ((ResponseType)response == ResponseType.Ok) { CurrentUri = new Uri(chooser.Uri, true); } chooser.Destroy(); }
public FileChooserDialog (string title, Window parent, FileChooserAction action) : base (title, parent, action) { LocalOnly = Banshee.IO.Provider.LocalOnly; SetCurrentFolderUri (LastFileChooserUri.Get (Environment.GetFolderPath (Environment.SpecialFolder.Personal))); WindowPosition = WindowPosition.Center; }
public FileChooserDialog(string title, Window window, FileChooserAction action) { IntPtr p = (window != null) ? window.Handle : ((IntPtr) 0); IntPtr s = Marshal.StringToHGlobalAuto (title); Raw = gtk_file_chooser_dialog_new(s, p, (int) action, IntPtr.Zero); Marshal.FreeHGlobal (s); }
/// <summary>Ask user for a filename to open.</summary> /// <param name="prompt">String to use as dialog heading</param> /// <param name="fileSpec">The file specification used to filter the files.</param> /// <param name="action">Action to perform (currently either "Open" or "Save")</param> /// <param name="initialPath">Optional Initial starting filename or directory</param> static public string AskUserForFileName(string prompt, string fileSpec, FileChooserAction action = FileChooserAction.Open, string initialPath = "") { string fileName = null; if (ProcessUtilities.CurrentOS.IsWindows) { return(WindowsFileDialog(prompt, fileSpec, action, initialPath)); } else if (ProcessUtilities.CurrentOS.IsMac) { return(OSXFileDialog(prompt, fileSpec, action, initialPath)); } else { string btnText = "Open"; if (action == FileChooserAction.Save) { btnText = "Save"; } FileChooserDialog fileChooser = new FileChooserDialog(prompt, null, action, "Cancel", ResponseType.Cancel, btnText, ResponseType.Accept); if (!String.IsNullOrEmpty(fileSpec)) { string[] specParts = fileSpec.Split(new Char[] { '|' }); for (int i = 0; i < specParts.Length; i += 2) { FileFilter fileFilter = new FileFilter(); fileFilter.Name = specParts[i]; fileFilter.AddPattern(specParts[i + 1]); fileChooser.AddFilter(fileFilter); } } FileFilter allFilter = new FileFilter(); allFilter.AddPattern("*"); allFilter.Name = "All files"; fileChooser.AddFilter(allFilter); if (File.Exists(initialPath)) { fileChooser.SetFilename(initialPath); } else if (Directory.Exists(initialPath)) { fileChooser.SetCurrentFolder(initialPath); } else { fileChooser.SetCurrentFolder(Utility.Configuration.Settings.PreviousFolder); } if (fileChooser.Run() == (int)ResponseType.Accept) { fileName = fileChooser.Filename; } fileChooser.Destroy(); } return(fileName); }
/// <summary> /// Initializes a new instance of the <see cref="Sharpend.GtkSharp.FileChooserWrapper"/> class. /// /// </summary> /// <param name='title'> /// Title. /// </param> /// <param name='chooser'> /// Chooser. /// </param> /// <param name='entryPath'> /// Entry to display selected path (optional, can be null) /// </param> /// <param name='action'> /// Action. /// </param> public FileChooserButtonWrapper(String title, FileChooserButton chooser, Entry entryPath,FileChooserAction action) { Chooser = chooser; EntryPath = entryPath; Chooser.Action = action; ConfigFile = null; CurrentFilter = null; Chooser.Title = title; init(); }
public FileDialog(MainWindow window, FileChooserAction action) { if (action == FileChooserAction.Open) { _dialog = new OpenFileDialog(); } else { _dialog = new FolderBrowserDialog(); } }
string getFileName(string a, FileChooserAction t) { string n = ""; FileChooserDialog op = new FileChooserDialog(a, this, t, "Cancel", ResponseType.Cancel, a, ResponseType.Accept); if (op.Run() == (int)ResponseType.Accept) { n = op.Filename; } op.Destroy(); return(n); }
static string FileChooser(Widget parent, string title, string defaultName, string defaultFolder, string filterName, string[] extensions, FileChooserAction action) { List <string> res = MultiFileChooser(parent, title, defaultName, defaultFolder, filterName, extensions, action, false); if (res.Count == 1) { return(res [0]); } return(null); }
/// <summary>Ask user for a filename to open on Windows.</summary> /// <param name="prompt">String to use as dialog heading</param> /// <param name="fileSpec">The file specification used to filter the files.</param> /// <param name="action">Action to perform (currently either "Open" or "Save")</param> /// <param name="initialPath">Optional Initial starting filename or directory</param> static public string WindowsFileDialog(string prompt, string fileSpec, FileChooserAction action, string initialPath) { string fileName = null; FileDialog dialog; if (action == FileChooserAction.Open) { dialog = new OpenFileDialog(); } else { dialog = new SaveFileDialog(); } dialog.Title = prompt; if (!String.IsNullOrEmpty(fileSpec)) { dialog.Filter = fileSpec + "|All files (*.*)|*.*"; } if (!String.IsNullOrWhiteSpace(initialPath) && (File.Exists(initialPath) || action == FileChooserAction.Save)) { dialog.InitialDirectory = Path.GetDirectoryName(initialPath); dialog.FileName = null; // This almost works, but Windows is buggy. // If the file name is long, it doesn't display in a sensible way // dialog.FileName = Path.GetFileName(initialPath); } else if (Directory.Exists(initialPath)) { dialog.InitialDirectory = initialPath; } else { dialog.InitialDirectory = Utility.Configuration.Settings.PreviousFolder; } /* * if (!string.IsNullOrEmpty(initialPath)) * { * timer.Tick += new EventHandler(WindowsWorkaround); * timer.Interval = 50; * timer.Tag = dialog; * timer.Start(); * }*/ if (dialog.ShowDialog() == DialogResult.OK) { fileName = dialog.FileName; } dialog = null; return(fileName); }
public FileChooserDialog (string title, Window parent, FileChooserAction action, params object[] button_data) : base (IntPtr.Zero) { if (GetType () != typeof (FileChooserDialog)) { CreateNativeObject (new string[0], new GLib.Value[0]); Title = title; if (parent != null) TransientFor = parent; Action = action; } else { IntPtr native = GLib.Marshaller.StringToPtrGStrdup (title); Raw = gtk_file_chooser_dialog_new (native, parent == null ? IntPtr.Zero : parent.Handle, (int)action, IntPtr.Zero); GLib.Marshaller.Free (native); } for (int i = 0; i < button_data.Length - 1; i += 2) AddButton ((string) button_data [i], (int) button_data [i + 1]); }
public static ResponseType Show(FileChooserAction action, Window parent, string title, out string filename) { FileChooserDialog fc = null; switch (action) { case FileChooserAction.Open: fc = new FileChooserDialog(title, parent, FileChooserAction.Open, Stock.Cancel, ResponseType.Cancel, Stock.Open, ResponseType.Ok); break; case FileChooserAction.Save: fc = new FileChooserDialog(title, parent, FileChooserAction.Save, Stock.Cancel, ResponseType.Cancel, Stock.Save, ResponseType.Ok); break; case FileChooserAction.CreateFolder: throw new NotImplementedException(); case FileChooserAction.SelectFolder: throw new NotImplementedException(); } fc.SetCurrentFolder(Environment.GetFolderPath(Environment.SpecialFolder.Personal)); fc.Modal = true; fc.DestroyWithParent = true; fc.SkipTaskbarHint = true; fc.Icon = App.DefaultWindowIcon; FileFilter ff; ff = new FileFilter(); ff.Name = S._("VolumeDatabase files"); ff.AddPattern("*.vdb"); fc.AddFilter(ff); ff = new FileFilter(); ff.Name = S._("All files"); ff.AddPattern("*.*"); fc.AddFilter(ff); ResponseType r = (ResponseType)fc.Run(); filename = fc.Filename; fc.Destroy(); return(r); }
public FileSelector(string title, FileChooserAction action) : base(title, null, action) { switch (action) { case FileChooserAction.SelectFolder: AddButton (Gtk.Stock.Cancel, ResponseType.Cancel); AddButton ("Select Folder", ResponseType.Ok); break; case FileChooserAction.Save: AddButton (Gtk.Stock.Cancel, ResponseType.Cancel); AddButton (Gtk.Stock.Save, ResponseType.Ok); break; default: break; } CommonSetup (); }
private static bool escolher(string filtro, string titulo, FileChooserAction acao, string textoAcao) { FileChooserDialog fcdialog = new FileChooserDialog(titulo, null, acao, "Cancelar", ResponseType.Cancel, textoAcao, ResponseType.Accept); fcdialog.SetPosition(WindowPosition.Center); montaFiltro(fcdialog, filtro); fcdialog.SelectMultiple = false; fcdialog.SetFilename(nomeArquivo); fcdialog.SetCurrentFolder(diretorioCorrente); int retorno = fcdialog.Run(); nomeArquivo = fcdialog.Filename; diretorioCorrente = fcdialog.CurrentFolder; fcdialog.Destroy(); return(retorno == (int)ResponseType.Accept); }
public Gtk.FileChooserDialog CreateChooser(string title, FileChooserAction action) { var chooser = new Gtk.FileChooserDialog(title, this.Window, action) { DefaultResponse = ResponseType.Ok }; chooser.AddButton(Stock.Cancel, ResponseType.Cancel); chooser.AddFilter(GtkUtilities.GetFileFilter(Catalog.GetString("PDF Documents"), new string [] { "pdf" })); chooser.AddFilter(GtkUtilities.GetFileFilter(Catalog.GetString("All Files"), new string [] { "*" })); var dirs = new string [] { "DOWNLOAD", "DOCUMENTS" }.Select(s => GetXdgDir(s)) .Where(d => d != null) .ToArray(); Hyena.Gui.GtkUtilities.SetChooserShortcuts(chooser, dirs); return(chooser); }
public FileSelector(string title, FileChooserAction action) : base(title, null, action) { switch (action) { case FileChooserAction.SelectFolder: AddButton(Gtk.Stock.Cancel, ResponseType.Cancel); AddButton("Select Folder", ResponseType.Ok); break; case FileChooserAction.Save: AddButton(Gtk.Stock.Cancel, ResponseType.Cancel); AddButton(Gtk.Stock.Save, ResponseType.Ok); break; default: break; } CommonSetup(); }
/// <summary>Ask user for a filename to open on Windows.</summary> /// <param name="prompt">String to use as dialog heading</param> /// <param name="fileSpec">The file specification used to filter the files.</param> /// <param name="action">Action to perform (currently either "Open" or "Save")</param> /// <param name="initialPath">Optional Initial starting filename or directory</param> static public string WindowsFileDialog(string prompt, string fileSpec, FileChooserAction action, string initialPath) { string fileName = null; FileDialog dialog; if (action == FileChooserAction.Open) { dialog = new OpenFileDialog(); } else { dialog = new SaveFileDialog(); } dialog.Title = prompt; if (!String.IsNullOrEmpty(fileSpec)) { dialog.Filter = fileSpec + "|All files (*.*)|*.*"; } if (File.Exists(initialPath)) { dialog.InitialDirectory = Path.GetDirectoryName(initialPath); dialog.FileName = Path.GetFileName(initialPath); } else if (Directory.Exists(initialPath)) { dialog.InitialDirectory = initialPath; } else { dialog.InitialDirectory = Utility.Configuration.Settings.PreviousFolder; } if (dialog.ShowDialog() == DialogResult.OK) { fileName = dialog.FileName; } return(fileName); }
private string OpenFileOpenDialog(FileChooserAction action) { var dialog = new FileChooserDialog( "Please select a savegame.", this, action, "Cancel", ResponseType.Cancel, "Open", ResponseType.Ok ); var result = ""; if (dialog.Run() == (int)ResponseType.Ok) { result = dialog.Filename; } dialog.Hide(); return(result); }
public static ResponseType Show(FileChooserAction action, Window parent, string title, out string filename) { FileChooserDialog fc = null; switch(action) { case FileChooserAction.Open: fc = new FileChooserDialog(title, parent, FileChooserAction.Open, Stock.Cancel, ResponseType.Cancel, Stock.Open, ResponseType.Ok); break; case FileChooserAction.Save: fc = new FileChooserDialog(title, parent, FileChooserAction.Save, Stock.Cancel, ResponseType.Cancel, Stock.Save, ResponseType.Ok); break; case FileChooserAction.CreateFolder: throw new NotImplementedException(); case FileChooserAction.SelectFolder: throw new NotImplementedException(); } fc.SetCurrentFolder(Environment.GetFolderPath(Environment.SpecialFolder.Personal)); fc.Modal = true; fc.DestroyWithParent = true; fc.SkipTaskbarHint = true; fc.Icon = App.DefaultWindowIcon; FileFilter ff; ff = new FileFilter(); ff.Name = S._("VolumeDatabase files"); ff.AddPattern("*.vdb"); fc.AddFilter(ff); ff = new FileFilter(); ff.Name = S._("All files"); ff.AddPattern("*.*"); fc.AddFilter(ff); ResponseType r = (ResponseType)fc.Run(); filename = fc.Filename; fc.Destroy(); return r; }
public FileSelector (string title, FileChooserAction action) : base (title, null, action) { switch (action) { case FileChooserAction.Open: AddButton (Gtk.Stock.Cancel, ResponseType.Cancel); AddButton (Gtk.Stock.Open, ResponseType.Ok); break; case FileChooserAction.SelectFolder: AddButton (Gtk.Stock.Cancel, ResponseType.Cancel); AddButton (GettextCatalog.GetString ("Select Folder"), ResponseType.Ok); break; case FileChooserAction.Save: AddButton (Gtk.Stock.Cancel, ResponseType.Cancel); AddButton (Gtk.Stock.Save, ResponseType.Ok); break; default: break; } DefaultResponse = ResponseType.Ok; CommonSetup (); }
public static Gtk.FileChooserAction ToGtkAction(this FileChooserAction action) { if ((action & FileChooserAction.CreateFolder) != 0) { return(Gtk.FileChooserAction.CreateFolder); } else if ((action & FileChooserAction.SelectFolder) != 0) { return(Gtk.FileChooserAction.SelectFolder); } else if ((action & FileChooserAction.Open) != 0) { return(Gtk.FileChooserAction.Open); } else if ((action & FileChooserAction.Save) != 0) { return(Gtk.FileChooserAction.Save); } else { throw new NotSupportedException(); } }
//Function shows the custom dialog based on provided action description string ShowCustomDialog(FileChooserAction fca, string action) { var temporarydialog = new Gtk.FileChooserDialog("", this, fca, "Cancel", ResponseType.Cancel, action, ResponseType.Accept); temporarydialog.SetCurrentFolder(@"."); //Only *.pro files are supposed to be supported var filefilter = new FileFilter(); filefilter.Name = "Project Files (*.pro)"; filefilter.AddPattern("*.pro"); temporarydialog.AddFilter(filefilter); //Returns empty string on cancellation, filename otherwise. string export = string.Empty; if (temporarydialog.Run() == (int)ResponseType.Accept) { export = temporarydialog.Filename; //Check if extension is presented, enforce its presence string export_ext = System.IO.Path.GetExtension(export); export += export_ext == ".pro" ? string.Empty : ".pro"; } temporarydialog.Destroy(); return(export); }
public override WindowResponse Show() { FileChooserAction fca = FileChooserAction.Open; switch (DialogType) { case FileDialogType.OpenFile: fca = FileChooserAction.Open; break; case FileDialogType.SelectFolder: fca = FileChooserAction.SelectFolder; break; case FileDialogType.SaveFile: fca = FileChooserAction.Save; break; } fc = new FileChooserDialog(Title, null, fca, Message.GetString("Cancel"), ResponseType.Cancel, Message.GetString("Select"), ResponseType.Ok); fc.SetCurrentFolder(InitialDirectory); foreach (FileTypeFilter filter in FileTypeFilters) { FileFilter ft = new FileFilter(); ft.Name = filter.FilterName; foreach (string pat in filter.Filter) { ft.AddPattern("*." + pat); } fc.AddFilter(ft); } WindowResponse resp = GtkHelper.GetResponse((ResponseType)fc.Run()); SelectedPath = fc.Filename; return(resp); }
private string OpenFolderBrowserDialogHandler(Window parent, bool allowCreateFolder) { FileChooserAction action = allowCreateFolder ? FileChooserAction.CreateFolder : FileChooserAction.SelectFolder; using (FileChooserDialog dlg = new FileChooserDialog( "Select a folder", parent, action, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept )) { string result = null; if (dlg.Run() == (int)ResponseType.Accept) { result = dlg.Filename; } dlg.Destroy(); return(result); } }
// Constructor /// <summary> /// Creates a new <see cref="FileSelector" />. /// </summary> /// <param name="title"> /// The window title. /// </param> /// <param name="action"> /// The <see cref="FileChooserAction" /> to do. /// </param> /// <param name="gconf_path"> /// The GConf path which holds the starting directory. /// </param> public FileSelector (string title, FileChooserAction action, string gconf_path) : base(title, Global.Playlist, action, "gnome-vfs") { this.gconf_path = gconf_path; base.LocalOnly = false; base.AddButton(Stock.Cancel, ResponseType.Cancel); switch (action) { case FileChooserAction.Open: base.AddButton(Stock.Open, ResponseType.Ok); break; case FileChooserAction.Save: base.AddButton(Stock.Save, ResponseType.Ok); break; default: break; } base.DefaultResponse = ResponseType.Ok; string start_dir = (string)Config.Get(gconf_path, GConfDefaultStartDir); start_dir = start_dir.Replace("~", Gnome.Vfs.Uri.GetUriFromLocalPath(FileUtils.HomeDirectory)); SetCurrentFolderUri(start_dir); base.Response += OnResponse; }
/// <summary>Ask user for a filename to open on Windows.</summary> /// <param name="prompt">String to use as dialog heading</param> /// <param name="fileSpec">The file specification used to filter the files.</param> /// <param name="action">Action to perform (currently either "Open" or "Save")</param> /// <param name="initialPath">Optional Initial starting filename or directory</param> static public string OSXFileDialog(string prompt, string fileSpec, FileChooserAction action, string initialPath) { string fileName = null; int result = 0; NSSavePanel panel; if (action == FileChooserAction.Open) { panel = new NSOpenPanel(); } else { panel = new NSSavePanel(); } panel.Title = prompt; if (!String.IsNullOrEmpty(fileSpec)) { string[] specParts = fileSpec.Split(new Char[] { '|' }); int nExts = 0; string[] allowed = new string[specParts.Length / 2]; for (int i = 0; i < specParts.Length; i += 2) { string pattern = Path.GetExtension(specParts[i + 1]); if (!String.IsNullOrEmpty(pattern)) { pattern = pattern.Substring(1); // Get rid of leading "." if (!String.IsNullOrEmpty(pattern)) { allowed[nExts++] = pattern; } } } if (nExts > 0) { Array.Resize(ref allowed, nExts); panel.AllowedFileTypes = allowed; } } panel.AllowsOtherFileTypes = true; if (File.Exists(initialPath)) { panel.DirectoryUrl = new MonoMac.Foundation.NSUrl(Path.GetDirectoryName(initialPath)); panel.NameFieldStringValue = Path.GetFileName(initialPath); } else if (Directory.Exists(initialPath)) { panel.DirectoryUrl = new MonoMac.Foundation.NSUrl(initialPath); } else { panel.DirectoryUrl = new MonoMac.Foundation.NSUrl(Utility.Configuration.Settings.PreviousFolder); } result = panel.RunModal(); if (result == 1 /*NSFileHandlingPanelOKButton*/) { fileName = panel.Url.Path; } return(fileName); }
string FileChooser(string title, string defaultName, string defaultFolder, string filterName, string extensionFilter, FileChooserAction action) { FileChooserDialog fChooser; FileFilter filter; string button, path; if (action == FileChooserAction.Save) button = "gtk-save"; else button = "gtk-open"; fChooser = new FileChooserDialog(title, mainWindow as Gtk.Window, action, "gtk-cancel",ResponseType.Cancel, button, ResponseType.Accept); if (defaultFolder != null) fChooser.SetCurrentFolder(defaultFolder); if (defaultName != null) fChooser.SetFilename(defaultName); if (filterName != null) { filter = new FileFilter(); filter.Name = filterName; filter.AddPattern(extensionFilter); fChooser.AddFilter(filter); } if (fChooser.Run() != (int)ResponseType.Accept) path = null; else path = fChooser.Filename; fChooser.Destroy(); return path; }
public FormsFileChooserButton(string title, FileChooserAction action, string backend) : base(title, action, backend) { }
public FormsFileChooserButton(string title, FileChooserAction action) : base(title, action) { }
public OpenFileDialog(string title, FileChooserAction action) { Title = title; Action = action; }
public Gtk.FileChooserDialog CreateChooser (string title, FileChooserAction action) { var chooser = new Gtk.FileChooserDialog (title, this.Window, action) { DefaultResponse = ResponseType.Ok }; chooser.AddButton (Stock.Cancel, ResponseType.Cancel); chooser.AddFilter (GtkUtilities.GetFileFilter (Catalog.GetString ("PDF Documents"), new string [] {"pdf"})); chooser.AddFilter (GtkUtilities.GetFileFilter (Catalog.GetString ("All Files"), new string [] {"*"})); var dirs = new string [] { "DOWNLOAD", "DOCUMENTS" }.Select (s => GetXdgDir (s)) .Where (d => d != null) .ToArray (); Hyena.Gui.GtkUtilities.SetChooserShortcuts (chooser, dirs); return chooser; }
private void Open(FileChooserAction action) { string title = Catalog.GetString ("Open"); if (action == FileChooserAction.SelectFolder) title = Catalog.GetString ("Select Folder"); FileChooserDialog chooser = new FileChooserDialog (title, Window, action); chooser.AddButton (Stock.Cancel, ResponseType.Cancel); chooser.AddButton (Stock.Open, ResponseType.Ok); chooser.SetUri (uri.ToString ()); int response = chooser.Run (); if ((ResponseType) response == ResponseType.Ok) CurrentUri = new SafeUri (chooser.Uri, true); chooser.Destroy (); }
public FileChooserDialog (string title, FileChooserAction action) : this (title, null, action) { }
public PacketDumpSelector(Window parent, string title, FileChooserAction chooserAction) { _chooserDialog = new FileChooserDialog(title, parent, chooserAction, "_Cancel", 1, "_Open", 0, null); _chooserDialog.FileActivated += ChooserOnFileActivated; }
public SelectFolderDialog(string title, FileChooserAction action) { Title = title; Action = action; }
internal static extern IntPtr gtk_file_chooser_dialog_new(string title, IntPtr parent, FileChooserAction action, IntPtr first_button_text, int first_button_id, IntPtr second_button_text, int second_button_id, IntPtr args);
/// <summary> /// Sets the file chooser action and changes title and corresponding radiogroup state /// </summary> /// <param name='fc'> /// File chooser button. /// </param> /// <param name='action'> /// Action to set. /// </param> protected void SetFileChooserAction(FileChooserButton fc, FileChooserAction action) { fc.Action = action; if (fc.Action == FileChooserAction.Open) { radioFile.Active = true; fc.Title = Catalog.GetString ("Select a file"); } else { radioFolder.Active = true; fc.Title = Catalog.GetString ("Select a folder"); } }
public FileDialog(Window window, FileChooserAction action) { dialog = new FileChooserDialog("Select Folder", window, action, "Cancel", ResponseType.Cancel, "Select", ResponseType.Ok); }
public PosFilePickerDialog(Window pSourceWindow, DialogFlags pDialogFlags, FileFilter pFileFilter, FileChooserAction pFileChooserAction) : this(pSourceWindow, pDialogFlags, pFileFilter, FileChooserAction.Open, null) { }
protected override void StartFileChooser(string path, int requestCode, bool isForSave) { _userAction = new FileChooserAction(path, requestCode, isForSave, this); }
/// <summary> /// Creates Widget /// </summary> /// <param name="aAction"> /// FileChooser action <see cref="FileChooserAction"/> /// </param> public DataFileChooserWidget (FileChooserAction aAction) : base (aAction) { adaptor = new GtkControlAdaptor (this, false); }
/// <summary> /// Initializes a new instance of the <see cref="Sharpend.GtkSharp.FileChooserWrapper"/> class. /// </summary> /// <param name='title'> /// Title. /// </param> /// <param name='chooser'> /// Chooser. /// </param> /// <param name='action'> /// Action. /// </param> public FileChooserButtonWrapper(String title, FileChooserButton chooser,FileChooserAction action) : this(title,chooser,null,action) { }
static List <string> MultiFileChooser(Widget parent, string title, string defaultName, string defaultFolder, string filterName, string[] extensions, FileChooserAction action, bool allowMultiple = true) { Window toplevel; FileChooserDialog fChooser; FileFilter filter; string button; List <string> path; if (action == FileChooserAction.Save) { button = "gtk-save"; } else { button = "gtk-open"; } if (parent != null) { toplevel = parent.Toplevel as Window; } else { toplevel = null; } fChooser = new FileChooserDialog(title, toplevel, action, "gtk-cancel", ResponseType.Cancel, button, ResponseType.Accept); fChooser.SelectMultiple = allowMultiple; if (defaultFolder != null) { fChooser.SetCurrentFolder(defaultFolder); } else if (Config.LastDir != null) { fChooser.SetCurrentFolder(Config.LastDir); } if (defaultName != null) { fChooser.CurrentName = defaultName; } if (filterName != null) { filter = new FileFilter(); filter.Name = filterName; if (extensions != null) { foreach (string p in extensions) { filter.AddPattern(p); } } fChooser.Filter = filter; } if (fChooser.Run() != (int)ResponseType.Accept) { path = new List <string> (); } else { path = new List <string> (fChooser.Filenames); if (defaultFolder == null && fChooser.Filenames.Length > 0) { Config.LastDir = System.IO.Path.GetDirectoryName(fChooser.Filenames [0]); } } fChooser.Destroy(); return(path); }
/// <summary> /// Creates Widget /// </summary> /// <param name="aAction"> /// FileChooser action <see cref="FileChooserAction"/> /// </param> /// <param name="aDataSource"> /// DataSource connected to this widget <see cref="System.Object"/> /// </param> /// <param name="aMappings"> /// Mappings with this widget <see cref="System.String"/> /// </param> public DataFileChooserWidget (FileChooserAction aAction, object aDataSource, string aMappings) : base (aAction) { adaptor = new GtkControlAdaptor (this, false, aDataSource, aMappings); }