当前位置: 首页>>代码示例>>C#>>正文


C# FileChooserDialog.AddImagePreview方法代码示例

本文整理汇总了C#中Gtk.FileChooserDialog.AddImagePreview方法的典型用法代码示例。如果您正苦于以下问题:C# FileChooserDialog.AddImagePreview方法的具体用法?C# FileChooserDialog.AddImagePreview怎么用?C# FileChooserDialog.AddImagePreview使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gtk.FileChooserDialog的用法示例。


在下文中一共展示了FileChooserDialog.AddImagePreview方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 ();
            foreach (var format in PintaCore.System.ImageFormats.Formats)
            {
                foreach (var ext in format.Extensions)
                {
                    ff.AddPattern (string.Format("*.{0}", ext));
                }
            }

            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.GetDialogDirectory ());
            fcd.SelectMultiple = true;

            fcd.AddImagePreview ();

            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, fcd))
                        RecentManager.Default.AddFull (fcd.Uri, PintaCore.System.RecentData);
            }

            fcd.Destroy ();
        }
开发者ID:Kharevich,项目名称:Pinta,代码行数:42,代码来源:OpenDocumentAction.cs

示例2: HandlePintaCoreActionsLayersImportFromFileActivated

        private void HandlePintaCoreActionsLayersImportFromFileActivated(object sender, EventArgs e)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;
            PintaCore.Tools.Commit ();

            Gtk.FileChooserDialog fcd = new Gtk.FileChooserDialog (Catalog.GetString ("Open Image File"), null, FileChooserAction.Open, Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, Gtk.Stock.Open, Gtk.ResponseType.Ok);

            fcd.SetCurrentFolder (PintaCore.System.LastDialogDirectory);
            fcd.AlternativeButtonOrder = new int[] { (int) ResponseType.Ok, (int) ResponseType.Cancel };

            fcd.AddImagePreview ();

            int response = fcd.Run ();

            if (response == (int)Gtk.ResponseType.Ok) {

                string file = fcd.Filename;
                PintaCore.System.LastDialogDirectory = fcd.CurrentFolder;

                // Open the image and add it to the layers
                Layer layer = doc.AddNewLayer (System.IO.Path.GetFileName (file));

                using (var fs = new FileStream (file, FileMode.Open))
                    using (Pixbuf bg = new Pixbuf (fs))
                        using (Cairo.Context g = new Cairo.Context (layer.Surface)) {
                            CairoHelper.SetSourcePixbuf (g, bg, 0, 0);
                            g.Paint ();
                        }

                doc.SetCurrentLayer (layer);

                AddLayerHistoryItem hist = new AddLayerHistoryItem ("Menu.Layers.ImportFromFile.png", Catalog.GetString ("Import From File"), doc.Layers.IndexOf (layer));
                doc.History.PushNewItem (hist);

                doc.Workspace.Invalidate ();
            }

            fcd.Destroy ();
        }
开发者ID:jonnyro,项目名称:Pinta,代码行数:39,代码来源:LayerActions.cs


注:本文中的Gtk.FileChooserDialog.AddImagePreview方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。