本文整理汇总了C#中Gtk.FileChooserDialog.AddFilter方法的典型用法代码示例。如果您正苦于以下问题:C# FileChooserDialog.AddFilter方法的具体用法?C# FileChooserDialog.AddFilter怎么用?C# FileChooserDialog.AddFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.FileChooserDialog
的用法示例。
在下文中一共展示了FileChooserDialog.AddFilter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: 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 ();
}
示例3: AddFilters
private static void AddFilters(FileChooserDialog dialog)
{
// Add experiment files filter
FileFilter fileFilter = new FileFilter();
fileFilter.AddPattern("*.teml");
fileFilter.Name = Mono.Unix.Catalog.GetString("Experiment files (.teml)");
dialog.AddFilter(fileFilter);
//add another option of All files
FileFilter allFilesFilter = new FileFilter();
allFilesFilter.Name = Mono.Unix.Catalog.GetString("All files");
allFilesFilter.AddPattern("*.*");
dialog.AddFilter(allFilesFilter);
}
示例4: 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;
}
示例5: OnTargetNMMLFileButtonClicked
protected void OnTargetNMMLFileButtonClicked(object sender, System.EventArgs e)
{
Gtk.FileChooserDialog fc =
new Gtk.FileChooserDialog ("Target NMML file", this.Toplevel as Gtk.Window, FileChooserAction.Open,
"Cancel", ResponseType.Cancel,
"Select", ResponseType.Accept);
Gtk.FileFilter filter = new Gtk.FileFilter ();
filter.Name = "NMML files";
filter.AddPattern ("*.nmml");
fc.AddFilter (filter);
if (mProject.TargetNMMLFile != "")
{
fc.SetFilename (mProject.TargetNMMLFile);
}
else
{
fc.SetFilename (mProject.BaseDirectory);
}
if (fc.Run () == (int)ResponseType.Accept)
{
string path = PathHelper.ToRelativePath (fc.Filename, mProject.BaseDirectory);
TargetNMMLFileEntry.Text = path;
}
fc.Destroy ();
}
示例6: AddFilters
/// <summary>
/// Adds the filters. Returns default extension
/// </summary>
/// <returns>The filters.</returns>
/// <param name="dialog">Dialog.</param>
private static string AddFilters(FileChooserDialog dialog)
{
string defaultExtension = "teml";
string cryptedFileExtension = "temlx";
// Add experiment files filter
FileFilter fileFilter = new FileFilter();
fileFilter.AddPattern(string.Format("*.{0}", defaultExtension));
fileFilter.Name = Mono.Unix.Catalog.GetString(string.Format("Experiment files (.{0})", defaultExtension));
dialog.AddFilter(fileFilter);
// Add experiment files filter
//TLAB-67
//here: we check if the file is crypted, if it's so we ask the user to insert a password. then we decrypt the file and check the
/// password. if the pwd is the same we contninue with the standard process, otherwise we raise and error
FileFilter fileFilterCryptedFile = new FileFilter();
fileFilterCryptedFile.AddPattern(string.Format("*.{0}", cryptedFileExtension));
fileFilterCryptedFile.Name = Mono.Unix.Catalog.GetString(string.Format("Experiment files (.{0})", cryptedFileExtension));
dialog.AddFilter(fileFilterCryptedFile);
//add another option of All files
FileFilter allFilesFilter = new FileFilter();
allFilesFilter.Name = Mono.Unix.Catalog.GetString("All files");
allFilesFilter.AddPattern("*.*");
dialog.AddFilter(allFilesFilter);
return defaultExtension;
}
示例7: 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();
}
示例8: 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");
}
示例9: 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();
}
示例10: 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 ();
}
示例11: 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); }
}
示例12: 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();
}
示例13: Show
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;
}
示例14: OnBtnBrowseExtractImageFileClicked
/// <summary>
/// Raises the button browse extract ımage file clicked event.
/// </summary>
protected void OnBtnBrowseExtractImageFileClicked(object sender, EventArgs e)
{
var imageChooser = new Gtk.FileChooserDialog("Choose the image file",
this,
FileChooserAction.Open,
"Cancel", ResponseType.Cancel,
"Open", ResponseType.Accept);
imageChooser.AddFilter(GetImageFilters());
if (imageChooser.Run() == (int)ResponseType.Accept) {
txtImageFileExtract.Text = imageChooser.Filename;
}
imageChooser.Destroy();
}
示例15: OnFloppyActionActivated
protected void OnFloppyActionActivated(object sender, EventArgs e)
{
Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog("Save File",this,FileChooserAction.Save,Gtk.Stock.Cancel,ResponseType.Cancel,Gtk.Stock.Open,ResponseType.Accept);
Gtk.FileFilter filter = new Gtk.FileFilter();
filter.AddPattern("Images|*.png;*.bmp;*.jpg");
fc.AddFilter(filter);
/*sfd.Filter = "Images|*.png;*.bmp;*.jpg";
ImageFormat format = ImageFormat.Png;
if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
fileManager.save(sfd.FileName.Substring(0, sfd.FileName.IndexOf('.')), map, manager, getHeight());
backgroundMap.Image.Save(sfd.FileName, format);
}*/
if(fc.Run()==(int)ResponseType.Accept){
}
}