本文整理汇总了C#中Gtk.FileChooserDialog.SetCurrentFolder方法的典型用法代码示例。如果您正苦于以下问题:C# FileChooserDialog.SetCurrentFolder方法的具体用法?C# FileChooserDialog.SetCurrentFolder怎么用?C# FileChooserDialog.SetCurrentFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.FileChooserDialog
的用法示例。
在下文中一共展示了FileChooserDialog.SetCurrentFolder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VideoOpenDialog
public VideoOpenDialog () : base(gladeFilename) {
dialog = GetDialog() as FileChooserDialog;
if (Base.IsDocumentLoaded && Base.Document.TextFile.IsPathRooted)
dialog.SetCurrentFolder(Base.Document.TextFile.Directory);
else
dialog.SetCurrentFolder(Environment.GetFolderPath(Environment.SpecialFolder.Personal));
SetFilters();
}
示例2: OpenClicked
protected virtual void OpenClicked (object sender, System.EventArgs e)
{
FileChooserDialog dlg = new FileChooserDialog (
GettextCatalog.GetString ("Select Executable"), null, FileChooserAction.Open,
"gtk-cancel", ResponseType.Cancel,
"gtk-open", ResponseType.Accept
);
dlg.SelectMultiple = false;
dlg.LocalOnly = true;
dlg.Modal = true;
dlg.SetCurrentFolder (Environment.GetFolderPath (Environment.SpecialFolder.Personal));
FileFilter filterExe = new FileFilter ();
filterExe.AddPattern ("*.exe");
filterExe.Name = GettextCatalog.GetString ("Executables");
FileFilter filterAll = new FileFilter ();
filterAll.AddPattern ("*");
filterAll.Name = GettextCatalog.GetString ("All files");
dlg.AddFilter (filterExe);
dlg.AddFilter (filterAll);
if (dlg.Run () == (int)ResponseType.Accept)
entryExecutable.Text = dlg.Filename;
dlg.Destroy ();
}
示例3: Activated
private void Activated(object sender, EventArgs e)
{
var fcd = new Gtk.FileChooserDialog (Catalog.GetString ("Open Image File"), PintaCore.Chrome.MainWindow,
FileChooserAction.Open, Gtk.Stock.Cancel, Gtk.ResponseType.Cancel,
Gtk.Stock.Open, Gtk.ResponseType.Ok);
// Add image files filter
FileFilter ff = new FileFilter ();
ff.AddPixbufFormats ();
ff.AddPattern ("*.ora");
ff.Name = Catalog.GetString ("Image files");
fcd.AddFilter (ff);
FileFilter ff2 = new FileFilter ();
ff2.Name = Catalog.GetString ("All files");
ff2.AddPattern ("*.*");
fcd.AddFilter (ff2);
fcd.AlternativeButtonOrder = new int[] { (int)ResponseType.Ok, (int)ResponseType.Cancel };
fcd.SetCurrentFolder (PintaCore.System.LastDialogDirectory);
fcd.SelectMultiple = true;
int response = fcd.Run ();
if (response == (int)Gtk.ResponseType.Ok) {
PintaCore.System.LastDialogDirectory = fcd.CurrentFolder;
foreach (var file in fcd.Filenames)
if (PintaCore.Workspace.OpenFile (file))
RecentManager.Default.AddFull (fcd.Uri, PintaCore.System.RecentData);
}
fcd.Destroy ();
}
示例4: OpenExperimentDialog
internal static string OpenExperimentDialog(Window parentWindow)
{
var fileChooserDialog = new Gtk.FileChooserDialog(Mono.Unix.Catalog.GetString ("Open Experiment File"),
parentWindow,
FileChooserAction.Open,
Gtk.Stock.Cancel,
Gtk.ResponseType.Cancel,
Gtk.Stock.Open, Gtk.ResponseType.Ok);
fileChooserDialog.AlternativeButtonOrder = new int[] { (int)ResponseType.Ok, (int)ResponseType.Cancel };
fileChooserDialog.SelectMultiple = false;
// HERZUM SPRINT 4 TLAB-214
fileChooserDialog.SetCurrentFolder(TraceLab.Core.Settings.Settings.GetSettings().DefaultExperimentsDirectory);
// END SPRINT HERZUM 4 HERZUM 4: TLAB-214
AddFilters(fileChooserDialog);
int response = fileChooserDialog.Run();
string filename = null;
if(response == (int)Gtk.ResponseType.Ok)
{
filename = fileChooserDialog.Filename;
}
fileChooserDialog.Destroy();
return filename;
}
示例5: GetClip
static void GetClip()
{
// TODO: Do not offer to save clip after selection and popup a clickable tooltip instead.
FileChooserDialog fcd = new FileChooserDialog("PixClip - Save clip as...", null, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept);
FileFilter fltJpg = new FileFilter();
fltJpg.AddMimeType("image/jpeg");
fltJpg.Name = "JPEG image format";
fcd.SetFilename("clip.jpg");
fcd.SetCurrentFolder(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop));
fcd.AddFilter(fltJpg);
Console.WriteLine("main: selecting save target");
if (fcd.Run() == (int) ResponseType.Accept) {
// TODO: Add quality setting to options form.
// http://library.gnome.org/devel/gdk-pixbuf/stable/gdk-pixbuf-file-saving.html
string [] keys = {"quality"};
string [] values = {"90"};
pixClip.Savev(fcd.Filename, "jpeg", keys, values);
Console.WriteLine("main: image saved");
} else {
Console.WriteLine("main: image save canceled");
}
fcd.Destroy();
Clipboard clip = Gtk.Clipboard.Get(Atom.Intern("CLIPBOARD", false));
clip.Image = pixClip;
Console.WriteLine("main: image added to the clipboard");
}
示例6: OpenFileButton_Clicked
private void OpenFileButton_Clicked(object sender, EventArgs e)
{
var fileChooser = new FileChooserDialog("Pick a file", this.Window, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
fileChooser.Filter = new FileFilter();
fileChooser.Filter.AddPattern("*.xt");
#if DEBUG
fileChooser.SetCurrentFolder(@"c:\tmp\traces");
#endif
var result = (ResponseType)Enum.ToObject(typeof(ResponseType), fileChooser.Run());
switch (result)
{
case ResponseType.Accept:
var filename = fileChooser.Filename;
Parser parser = null;
fileChooser.Destroy();
try
{
parser = Parser.ParseFile(filename);
}
catch (Exception ex)
{
var dlg = new MessageDialog(this.Window, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, "Failed to load/parse the selected file! \r\nSome indication: " + ex.Message);
dlg.Run();
}
if (parser != null)
{
ShowTraces(parser);
}
break;
case ResponseType.Cancel:
case ResponseType.DeleteEvent:
fileChooser.Destroy();
break;
}
}
示例7: OnSaveButtonClicked
protected void OnSaveButtonClicked(object sender, EventArgs e)
{
try
{
FileChooserDialog fc = new FileChooserDialog("Save Filterset", this, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept);
FileFilter filter = new FileFilter();
filter.Name = "DeSERt Filterset";
filter.AddMimeType("Filterset/fis");
filter.AddPattern("*.fis");
fc.AddFilter(filter);
fc.DoOverwriteConfirmation = true;
fc.CurrentName = FiltersetnameEntry.Text.Replace(" ", "-");
if (Directory.Exists(MySettings.LastFilterDir)) { fc.SetCurrentFolder(MySettings.LastFilterDir); }
ResponseType res = (ResponseType)fc.Run();
if (res == ResponseType.Ok || res == ResponseType.Close)
{
string path;
if (!System.IO.Path.HasExtension(fc.Filename)) { path = fc.Filename + ".fis"; }
else { path = fc.Filename; }
MySettings.LastFilterDir = System.IO.Path.GetDirectoryName(fc.Filename);
MySettings.Save();
fst.Name = FiltersetnameEntry.Text;
Filterset.SaveFilterset(path, fst);
saved = true;
}
fc.Destroy();
if (res == ResponseType.Close) { this.Destroy(); }
}
catch (Exception ex) { ErrorReport.ReportError("Save Button (Create Filterset)", ex); }
}
示例8: ChooseDialog
// 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;
}
示例9: loadBatchPoints
//Will load in multiple files, or a folder of files which will be matched against
//loaded templates
public static List<Tuple<string, List<PointD>>> loadBatchPoints()
{
List<Tuple<string,List<PointD>>> result = new List<Tuple<string,List<PointD>>> ();
//Setup of dialog and limiting it to only XML files
FileChooserDialog fileChooser = new FileChooserDialog ("Open Files", null, FileChooserAction.Open);
fileChooser.AddButton (Stock.Cancel, ResponseType.Cancel);
fileChooser.AddButton (Stock.Open, ResponseType.Ok);
fileChooser.Filter = new FileFilter ();
fileChooser.Filter.AddPattern ("*.xml");
string tmp = System.IO.Directory.GetCurrentDirectory();
string newTmp = tmp + "/../../Gestures/RecordedDataPoints/";
fileChooser.SetCurrentFolder (newTmp);
fileChooser.SelectMultiple = true;
ResponseType retVal = (ResponseType)fileChooser.Run ();
if (retVal == ResponseType.Ok) {
foreach (string file in fileChooser.Filenames) {
result.Add (XMLParser.BatchLoadPoints (file));
}
}
fileChooser.Destroy ();
return result;
}
示例10: Show
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;
}
示例11: OnActivated
protected override void OnActivated()
{
base.OnActivated();
if(String.IsNullOrEmpty(MainClass.Workspace.FilePath)){
MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("workspace_not_exist"), MainClass.Languages.Translate("please_create_workspace"), Gtk.MessageType.Error);
md.ShowDialog();
return;
}
Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog(MainClass.Languages.Translate("chose_project_import"), MainClass.MainWindow, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
if (!String.IsNullOrEmpty(MainClass.Settings.LastOpenedImportDir))
fc.SetCurrentFolder(MainClass.Settings.LastOpenedImportDir);
FileFilter filter = new FileFilter();
filter.Name = "zip files";
filter.AddMimeType("zip file");
filter.AddPattern("*.zip");
fc.AddFilter(filter);
if (fc.Run() == (int)ResponseType.Accept) {
MainClass.Settings.LastOpenedImportDir = System.IO.Path.GetDirectoryName(fc.Filename);
MainClass.MainWindow.ImportProject(fc.Filename,true);
}
fc.Destroy();
}
示例12: OnActivated
protected override void OnActivated()
{
base.OnActivated();
Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog(MainClass.Languages.Translate("chose_workspace_open"), MainClass.MainWindow, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
FileFilter filter = new FileFilter();
filter.Name = "Workspace files";
filter.AddMimeType("Workspace file");
filter.AddPattern("*.msw");
fc.AddFilter(filter);
if (!String.IsNullOrEmpty(MainClass.Settings.LastOpenedWorkspaceDir))
fc.SetCurrentFolder(MainClass.Settings.LastOpenedWorkspaceDir);
if (fc.Run() == (int)ResponseType.Accept) {
MainClass.Settings.LastOpenedWorkspaceDir = System.IO.Path.GetDirectoryName(fc.Filename);
//CloseActualWorkspace();
Workspace.Workspace workspace = Workspace.Workspace.OpenWorkspace(fc.Filename);
if (workspace != null){
//MainClass.Settings.RecentFiles.AddWorkspace(fc.Filename,fc.Filename);
MainClass.MainWindow.ReloadWorkspace(workspace,true,true);
}
}
fc.Destroy();
}
示例13: OnActivated
protected override void OnActivated()
{
base.OnActivated();
if(String.IsNullOrEmpty(MainClass.Workspace.FilePath)){
MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("workspace_not_exist"), MainClass.Languages.Translate("please_create_workspace"), Gtk.MessageType.Error);
md.ShowDialog();
return;
}
Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog(MainClass.Languages.Translate("save_project_export"), MainClass.MainWindow, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept);
if (!String.IsNullOrEmpty(MainClass.Settings.LastOpenedExportDir))
fc.SetCurrentFolder(MainClass.Settings.LastOpenedExportDir);
FileFilter filter = new FileFilter();
filter.Name = "zip files";
filter.AddMimeType("zip file");
filter.AddPattern("*.zip");
fc.AddFilter(filter);
string appname = "";
int typ = -1;
Gtk.TreeIter ti = new Gtk.TreeIter();
MainClass.MainWindow.WorkspaceTree.GetSelectedFile(out appname, out typ, out ti);
if (String.IsNullOrEmpty(appname)){
return;
}
Project p = MainClass.Workspace.FindProject_byApp(appname, true);
if(p== null){
return;
}
fc.CurrentName =p.ProjectName+"_"+p.AppFile.Version.Replace(".","_") ;
//fc.SetFilename(p.ProjectName);
if (fc.Run() != (int)ResponseType.Accept) {
fc.Destroy();
return;
}
string name =fc.Filename;
string ext = System.IO.Path.GetExtension(name);
if(ext.ToLower() != ".zip"){
name = name+".zip";
}
if(p!= null){
p.Export(name,true);
MainClass.Settings.LastOpenedExportDir = System.IO.Path.GetDirectoryName(fc.Filename);
}
fc.Destroy();
}
示例14: FileOpenDialog
protected FileOpenDialog (bool toEnableVideo, string title) : base(gladeFilename) {
dialog = GetDialog() as FileChooserDialog;
dialog.Title = title;
InitEncodingComboBox();
if (toEnableVideo)
EnableVideo();
string startFolder = GetStartFolder();
dialog.SetCurrentFolder(startFolder);
SetFilters();
}
示例15: OnBrowseButtonClicked
private void OnBrowseButtonClicked(object sender, EventArgs args)
{
FileChooserDialog chooser = new FileChooserDialog ("Select a path:", (Window)preferencesForm["preferencesDialog"], FileChooserAction.SelectFolder, Stock.Ok);
if (defaultOutputPathEntry.Text.Length != 0) {
chooser.SetCurrentFolder (defaultOutputPathEntry.Text);
}
chooser.AddButton (Stock.Ok, ResponseType.Accept);
ResponseType responseType = (ResponseType) chooser.Run ();
switch (responseType) {
case ResponseType.Accept:
defaultOutputPathEntry.Text = chooser.CurrentFolder;
break;
default:
break;
}
chooser.Destroy ();
}