本文整理汇总了C#中Gtk.FileChooserDialog.Run方法的典型用法代码示例。如果您正苦于以下问题:C# FileChooserDialog.Run方法的具体用法?C# FileChooserDialog.Run怎么用?C# FileChooserDialog.Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.FileChooserDialog
的用法示例。
在下文中一共展示了FileChooserDialog.Run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: open
protected void open(object sender, EventArgs e)
{
int width, height;
this.GetDefaultSize (out width, out height);
this.Resize (width, height);
// Create and display a fileChooserDialog
FileChooserDialog chooser = new FileChooserDialog (
"Please select a file to open ...",
this,
FileChooserAction.Open,
"cancel", ResponseType.Cancel,
"view", ResponseType.Accept);
if (chooser.Run () == (int)ResponseType.Accept) {
System.IO.StreamReader file =
System.IO.File.OpenText (chooser.Filename);
textview2.Buffer.Text=file.ReadToEnd ();
this.Title = " ssource editor -- " + chooser.Filename.ToString ();
this.Resize (640, 480);
file.Close ();
string[] forsaveas=new[]{chooser.Filename};
System.IO.File.WriteAllLines (@".ssourcefile.txt",forsaveas);//write name of file so that it can be saved also after
ready = true;
this.entry1.Text = ("opened : " + chooser.Filename);
}
chooser.Destroy ();
}
示例3: OnBtnSelectFileClicked
/// <summary>
/// On click "..." button - select file
/// </summary>
protected virtual void OnBtnSelectFileClicked(object sender, System.EventArgs e)
{
Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog (
AddinManager.CurrentLocalizer.GetString ("Choose the file to open"), new Dialog(),
Gtk.FileChooserAction.Open,
AddinManager.CurrentLocalizer.GetString ("Cancel"), ResponseType.Cancel,
AddinManager.CurrentLocalizer.GetString ("Open"), ResponseType.Accept);
if (!string.IsNullOrEmpty (this.eCommand.Text)) {
fc.SetFilename(this.eCommand.Text);
}
if (fc.Run() == (int) ResponseType.Accept) {
// check
UnixFileInfo info = new UnixFileInfo (fc.Filename);
if ((info.FileAccessPermissions & FileAccessPermissions.UserExecute)
!= FileAccessPermissions.UserExecute) {
MessageDialog md = new MessageDialog (new Dialog(),
DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Close,
AddinManager.CurrentLocalizer.GetString ("Selected invalid file!\nShould be executable."));
md.Run ();
md.Destroy();
} else {
this.eCommand.Text = fc.Filename;
}
}
fc.Destroy();
}
示例4: 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();
}
示例5: 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); }
}
示例6: GetTemplateFromDisk
public static byte[] GetTemplateFromDisk()
{
//Читаем файл документа
FileChooserDialog Chooser = new FileChooserDialog ("Выберите шаблон документа...",
null,
FileChooserAction.Open,
"Отмена", ResponseType.Cancel,
"Выбрать", ResponseType.Accept);
FileFilter Filter = new FileFilter ();
Filter.Name = "ODT документы и OTT шаблоны";
Filter.AddMimeType ("application/vnd.oasis.opendocument.text");
Filter.AddMimeType ("application/vnd.oasis.opendocument.text-template");
Filter.AddPattern ("*.odt");
Filter.AddPattern ("*.ott");
Chooser.AddFilter (Filter);
Filter = new FileFilter ();
Filter.Name = "Все файлы";
Filter.AddPattern ("*.*");
Chooser.AddFilter (Filter);
byte[] file = null;
if ((ResponseType)Chooser.Run () == ResponseType.Accept) {
Chooser.Hide ();
logger.Info ("Чтение файла...");
file = File.ReadAllBytes(Chooser.Filename);
logger.Info ("Ok");
}
Chooser.Destroy ();
return file;
}
示例7: 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();
}
示例8: 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;
}
示例9: 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;
}
}
示例10: AskForQuizFilePath
public string AskForQuizFilePath()
{
string output;
Gtk.FileChooserDialog fc =
new Gtk.FileChooserDialog("Choose the quiz to open",
this,
FileChooserAction.Open,
"Cancel",ResponseType.Cancel,
"Open",ResponseType.Accept);
if (fc.Run() == (int)ResponseType.Accept)
{
output = fc.Filename;
}
else
{
throw new ApplicationException("Could for some reason not read the wanted file: " + fc.Filename);
}
//Don't forget to call Destroy() or the FileChooserDialog window won't get closed.
fc.Destroy();
return output;
}
示例11: 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 ();
}
示例12: OnButtonLoadPhotoClicked
protected void OnButtonLoadPhotoClicked(object sender, EventArgs e)
{
FileChooserDialog Chooser = new FileChooserDialog ("Выберите фото для загрузки...",
(Window)this.Toplevel,
FileChooserAction.Open,
"Отмена", ResponseType.Cancel,
"Загрузить", ResponseType.Accept);
FileFilter Filter = new FileFilter ();
Filter.AddPixbufFormats ();
Filter.Name = "Все изображения";
Chooser.AddFilter (Filter);
if ((ResponseType)Chooser.Run () == ResponseType.Accept) {
Chooser.Hide ();
logger.Info ("Загрузка фотографии...");
FileStream fs = new FileStream (Chooser.Filename, FileMode.Open, FileAccess.Read);
if (Chooser.Filename.ToLower ().EndsWith (".jpg")) {
using (MemoryStream ms = new MemoryStream ()) {
fs.CopyTo (ms);
ImageFile = ms.ToArray ();
}
} else {
logger.Info ("Конвертация в jpg ...");
Gdk.Pixbuf image = new Gdk.Pixbuf (fs);
ImageFile = image.SaveToBuffer ("jpeg");
}
fs.Close ();
buttonSavePhoto.Sensitive = true;
logger.Info ("Ok");
}
Chooser.Destroy ();
}
示例13: Activate
public void Activate()
{
object[] buttonResponses = new object[] {"Accept", ResponseType.Accept, "Cancel", ResponseType.Cancel};
FileChooserDialog fileDialog = new FileChooserDialog("Local Studies", (Window)_mainView.GuiElement, FileChooserAction.SelectFolder, buttonResponses);
int result = fileDialog.Run();
string folder = fileDialog.Filename;
fileDialog.Destroy(); // must manually destroy the dialog
if(result == (int)ResponseType.Accept)
{
LocalImageLoader loader = new LocalImageLoader();
string studyUID = loader.Load(folder);
//if(studyUID == "" || WorkstationModel.StudyManager.StudyTree.GetStudy(studyUID) == null)
if(studyUID == "" || ImageWorkspace.StudyManager.StudyTree.GetStudy(studyUID) == null)
{
//Platform.ShowMessageBox(ClearCanvas.Workstation.Model.SR.ErrorUnableToLoadStudy);
Platform.ShowMessageBox(ClearCanvas.ImageViewer.SR.ErrorUnableToLoadStudy);
}
else
{
ImageWorkspace ws = new ImageWorkspace(studyUID);
//WorkstationModel.WorkspaceManager.Workspaces.Add(ws);
DesktopApplication.WorkspaceManager.Workspaces.Add(ws);
}
}
}
示例14: OnOpenActionActivated
protected void OnOpenActionActivated(object sender, EventArgs e)
{
Gtk.FileChooserDialog fc = new FileChooserDialog (
"Choose image to open",
this,
Gtk.FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
fc.Filter = new FileFilter();
fc.Filter.AddPattern ("*.png");
fc.Filter.AddPattern ("*.jpg");
fc.Filter.AddPattern("*.jpeg");
fc.Filter.AddPattern ("*.gif");
fc.Filter.AddPattern("*.tiff");
if (fc.Run() == (int)ResponseType.Accept)
{
System.Drawing.Image host = System.Drawing.Image.FromFile (fc.Filename);
Bitmap hostImage = new Bitmap (host);
MemoryStream pic = new MemoryStream ();
hostImage.Save (pic, System.Drawing.Imaging.ImageFormat.Png);
pic.Seek (0, SeekOrigin.Begin);
Gdk.Pixbuf pb = new Gdk.Pixbuf (pic);
originalImage.Pixbuf = pb;
}
//Don't forget to call Destroy() or the FileChooserDialog window won't get closed.
fc.Destroy();
}
示例15: 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");
}