本文整理汇总了C#中Gtk.FileFilter.AddPixbufFormats方法的典型用法代码示例。如果您正苦于以下问题:C# FileFilter.AddPixbufFormats方法的具体用法?C# FileFilter.AddPixbufFormats怎么用?C# FileFilter.AddPixbufFormats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.FileFilter
的用法示例。
在下文中一共展示了FileFilter.AddPixbufFormats方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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 ();
}
示例2: 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 ();
}
示例3: HandlePintaCoreActionsFileOpenActivated
private void HandlePintaCoreActionsFileOpenActivated(object sender, EventArgs e)
{
bool canceled = false;
if (PintaCore.Workspace.IsDirty) {
var primary = Catalog.GetString ("Save the changes to image \"{0}\" before opening a new image?");
var secondary = Catalog.GetString ("If you don't save, all changes will be permanently lost.");
var markup = "<span weight=\"bold\" size=\"larger\">{0}</span>\n\n{1}\n";
markup = string.Format (markup, primary, secondary);
var md = new MessageDialog (PintaCore.Chrome.MainWindow, DialogFlags.Modal,
MessageType.Question, ButtonsType.None, true,
markup,
System.IO.Path.GetFileName (PintaCore.Workspace.Filename));
md.AddButton (Catalog.GetString ("Continue without saving"), ResponseType.No);
md.AddButton (Stock.Cancel, ResponseType.Cancel);
md.AddButton (Stock.Save, ResponseType.Yes);
md.DefaultResponse = ResponseType.Cancel;
ResponseType response = (ResponseType)md.Run ();
md.Destroy ();
if (response == ResponseType.Yes) {
Save.Activate ();
}
else {
canceled = response == ResponseType.Cancel;
}
}
if (!canceled) {
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.SetCurrentFolder (lastDialogDir);
int response = fcd.Run ();
if (response == (int)Gtk.ResponseType.Ok) {
lastDialogDir = fcd.CurrentFolder;
if (OpenFile (fcd.Filename)) {
AddRecentFileUri (fcd.Uri);
PintaCore.Workspace.ActiveDocument.HasFile = true;
}
}
fcd.Destroy ();
}
}
示例4: HandlePintaCoreActionsFileOpenActivated
private void HandlePintaCoreActionsFileOpenActivated(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 (lastDialogDir);
int response = fcd.Run ();
if (response == (int)Gtk.ResponseType.Ok) {
lastDialogDir = fcd.CurrentFolder;
if (OpenFile (fcd.Filename)) {
AddRecentFileUri (fcd.Uri);
PintaCore.Workspace.ActiveDocument.HasFile = true;
}
}
fcd.Destroy ();
}
示例5: OpenImage
// ========================================
// PRIVATE Methods
// ========================================
private string OpenImage()
{
FileChooserDialog dialog = new FileChooserDialog("Open Image", null,
FileChooserAction.Open);
dialog.SelectMultiple = false;
FileFilter filter = new FileFilter();
filter.AddPixbufFormats();
dialog.AddFilter(filter);
dialog.AddButton(Gtk.Stock.Cancel, ResponseType.Cancel);
dialog.AddButton(Gtk.Stock.Open, ResponseType.Ok);
string filename = null;
if ((ResponseType) dialog.Run() == ResponseType.Ok)
filename = dialog.Filename;
dialog.Destroy();
return(filename);
}
示例6: OnOpenActionActivated
protected void OnOpenActionActivated(object sender, EventArgs e)
{
TreeIter iter;
FileChooserDialog Chooser = new FileChooserDialog("Выберите изображения для загрузки...",
this,
FileChooserAction.Open,
"Отмена", ResponseType.Cancel,
"Открыть", ResponseType.Accept );
Chooser.SelectMultiple = true;
FileFilter Filter = new FileFilter();
Filter.AddPixbufFormats ();
Filter.Name = "Все изображения";
Chooser.AddFilter(Filter);
if((ResponseType) Chooser.Run () == ResponseType.Accept)
{
Chooser.Hide();
progresswork.Text = "Загрузка изображений...";
progresswork.Adjustment.Upper = Chooser.Filenames.Length;
foreach(string File in Chooser.Filenames)
{
logger.Debug(File);
iter = ImageListNewDoc();
FileStream fs = new FileStream(File, FileMode.Open, FileAccess.Read);
Pixbuf image = new Pixbuf(fs);
double ratio = 150f / Math.Max(image.Height, image.Width);
Pixbuf thumb = image.ScaleSimple((int)(image.Width * ratio),(int)(image.Height * ratio), InterpType.Bilinear);
fs.Close();
ImageList.AppendValues (iter,
0,
System.IO.Path.GetFileName(File),
File,
null,
thumb,
image,
true,
"",
"");
progresswork.Adjustment.Value++;
MainClass.WaitRedraw();
}
treeviewImages.ExpandAll ();
progresswork.Text = "Ок";
progresswork.Fraction = 0;
}
Chooser.Destroy ();
}