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


C# FileFilter.AddCustom方法代码示例

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


在下文中一共展示了FileFilter.AddCustom方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadCEStage

    /*
    public void LoadCEStage(string filename, bool findRawForCEStage)
    {
        try
        {
            mStage.LoadStage(filename);

            string raw_filename; int prescale = 2;
            if (mStage.Prescale != 0) prescale = mStage.Prescale;

            if (findRawForCEStage && MainClass.FindRawsForCestageAndAskToOpen(filename, out raw_filename, ref prescale))
            {
                mStage.AskLoadImage(raw_filename, prescale);
            }
        }
        catch (StageDeserializationException sdex)
        {
            Gtk.MessageDialog md = new Gtk.MessageDialog(
                this, DialogFlags.Modal,
                MessageType.Error, ButtonsType.Ok,
                false, "Can't load stage from the file \"{0}\".\n{1}", filename, sdex.Message);

            md.Title = MainClass.APP_NAME;

            md.Run();
            md.Destroy();
        }
    }
    */
    public bool ShowLoadImageDialog()
    {
        if (mStage.TheUIState == UIState.Loading)
        {
            Gtk.MessageDialog md = new Gtk.MessageDialog(this, DialogFlags.Modal,
                                                         MessageType.Error, ButtonsType.Ok,
                                                         "Loading is in progress");
            md.Title = MainClass.APP_NAME;
            md.Run();
            md.Destroy();
        }
        else
        {
            Gtk.FileChooserDialog fcd = new Gtk.FileChooserDialog("Open RAW image",
                                                                  this,
                                                                  FileChooserAction.Open,
                                                                  "Cancel", ResponseType.Cancel,
                                                                  "Open", ResponseType.Accept);

            // Filter for RAWs
            FileFilter ff = new FileFilter();

            ff.AddCustom(FileFilterFlags.Filename, delegate (Gtk.FileFilterInfo ffi) {
                return RawLoader.IsRaw(ffi.Filename);
            });
            ff.Name = "RAW image";

            fcd.AddFilter(ff);

            // Setting current folder to stage file folder or to RAW file folder
            if (mStage.StageFileName != null && mStage.StageFileName != ""
                    && !fcd.SetCurrentFolder(System.IO.Path.GetDirectoryName(mStage.StageFileName)))
                fcd.SetCurrentFolder(System.IO.Path.GetDirectoryName(mStage.RawFileName));

            // Adding preview widget

            ReceiptSelectorWidget rsw = new ReceiptSelectorWidget();
            RawPreviewWidget rpw = new RawPreviewWidget();

            // Adding options widget

            PreScaleSelectorWidget pssw = new PreScaleSelectorWidget();
            pssw.Value = 2;
            if (mStage.Prescale != 0) pssw.Value = mStage.Prescale;

            VBox preview_box = new VBox(false, 4);
            preview_box.PackStart(rpw, true, true, 0);
            preview_box.ShowAll();
            fcd.PreviewWidget = preview_box;

            HBox options_box = new HBox(false, 20);
            options_box.PackStart(rsw, true, true, 0);
            options_box.PackEnd(pssw, false, true, 0);
            fcd.ExtraWidget = options_box;
            options_box.ShowAll();

            // Adding events

            fcd.UpdatePreview += delegate {
                rpw.Filename = fcd.Filename;
            };
            fcd.SelectionChanged += delegate {
                rpw.Filename = fcd.Filename;
                rsw.RawFileName = fcd.Filename;
            };
            rpw.FileIsGoodChanged += delegate {
                options_box.Sensitive = rpw.FileIsGood;
                fcd.PreviewWidgetActive = rpw.FileIsGood;
            };

            if (mStage.RawFileName != null)
//.........这里部分代码省略.........
开发者ID:bigfatbrowncat,项目名称:CatEye,代码行数:101,代码来源:StageEditorWindow.cs

示例2: OnOpenActionActivated

 protected virtual void OnOpenActionActivated(object sender, System.EventArgs e)
 {
     var fileChooser = new FileChooserDialog (Catalog.GetString ("Open directory"), this, FileChooserAction.Open, Stock.Cancel, ResponseType.Cancel, Stock.Open, ResponseType.Close);
     FileFilter filter = new FileFilter ();
     filter.AddCustom (FileFilterFlags.Filename, info => Directory.Exists (info.Filename));
     fileChooser.Filter = filter;
     if (fileChooser.Run () == (int)ResponseType.Close) {
         logic.LoadDirectory (fileChooser.Filename ?? fileChooser.CurrentFolder);
     }
     fileChooser.Destroy ();
 }
开发者ID:scheibenkaes,项目名称:DirectoryHistory,代码行数:11,代码来源:MainWindow.cs


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