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


C# Gtk.FileChooserDialog类代码示例

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


FileChooserDialog类属于Gtk命名空间,在下文中一共展示了FileChooserDialog类的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;
        }
开发者ID:ivynetca,项目名称:lapsestudio,代码行数:29,代码来源:GtkFileDialog.cs

示例2: SelectFileDialog

        private string SelectFileDialog(Window parentWindow) 
        {
            var fileChooserDialog = new Gtk.FileChooserDialog(Mono.Unix.Catalog.GetString ("Select 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;

            //add filter for all files
            FileFilter allFilesFilter = new FileFilter();
            allFilesFilter.Name = Mono.Unix.Catalog.GetString("All files");
            allFilesFilter.AddPattern("*.*");
            fileChooserDialog.AddFilter(allFilesFilter);

            int response = fileChooserDialog.Run();
            
            string filename = null;
            if(response == (int)Gtk.ResponseType.Ok) 
            {
                filename = fileChooserDialog.Filename;
            }
            
            fileChooserDialog.Destroy();
            
            return filename;
        }
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:30,代码来源:FilePathEditor.cs

示例3: ChooseDialog

        // creates a custom choose dialog
        static string[] ChooseDialog(FileChooserAction action, string title, bool many)
        {
            FileChooserDialog dialog = new FileChooserDialog (title, null, action);

            if (last_folder != null)
                dialog.SetCurrentFolder (last_folder);
            if (many)
                dialog.SelectMultiple = true;

            dialog.AddButton (Stock.Cancel, ResponseType.Cancel);
            dialog.AddButton (Stock.Ok, ResponseType.Ok);

            int response = dialog.Run ();
            string[] ret = null;

            if ((ResponseType) response == ResponseType.Ok)
                ret = dialog.Filenames;
            if ((ResponseType) response == ResponseType.Cancel)
                ret = null;

            last_folder = dialog.CurrentFolder;
            dialog.Destroy ();

            if(ret != null && ret.Length == 0) ret = null;
            return ret;
        }
开发者ID:gsterjov,项目名称:fusemc,代码行数:27,代码来源:Dialogs.cs

示例4: 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 ();
        }
开发者ID:tjhei,项目名称:md-haxebinding,代码行数:30,代码来源:NMEProjectOptionsPanel.cs

示例5: 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;
        }
开发者ID:CoEST,项目名称:TraceLab,代码行数:30,代码来源:FileDialogs.cs

示例6: loadBatchPoints

        //Will load in multiple files, or a folder of files which will be matched against
        //loaded templates
        public static List<Tuple<string, List<PointD>>> loadBatchPoints()
        {
            List<Tuple<string,List<PointD>>> result = new List<Tuple<string,List<PointD>>> ();

            //Setup of dialog and limiting it to only XML files
            FileChooserDialog fileChooser = new FileChooserDialog ("Open Files", null, FileChooserAction.Open);
            fileChooser.AddButton (Stock.Cancel, ResponseType.Cancel);
            fileChooser.AddButton (Stock.Open, ResponseType.Ok);

            fileChooser.Filter = new FileFilter ();
            fileChooser.Filter.AddPattern ("*.xml");

            string tmp = System.IO.Directory.GetCurrentDirectory();
            string newTmp = tmp + "/../../Gestures/RecordedDataPoints/";
            fileChooser.SetCurrentFolder (newTmp);

            fileChooser.SelectMultiple = true;

            ResponseType retVal = (ResponseType)fileChooser.Run ();

            if (retVal == ResponseType.Ok) {
                foreach (string file in fileChooser.Filenames) {
                    result.Add (XMLParser.BatchLoadPoints (file));
                }
            }

            fileChooser.Destroy ();
            return result;
        }
开发者ID:justingruber,项目名称:Protractor,代码行数:31,代码来源:CustomFunctions.cs

示例7: Execute

        public override bool Execute()
        {
            Image image = null;
              if (File.Exists(_path))
            {
              image = Image.Load(RunMode.Noninteractive, _path, _path);
            }
              else
            {
              var choose = new FileChooserDialog("Open...",
                         null,
                         FileChooserAction.Open,
                         "Cancel", ResponseType.Cancel,
                         "Open", ResponseType.Accept);
              if (choose.Run() == (int) ResponseType.Accept)
            {
              string fileName = choose.Filename;
              image = Image.Load(RunMode.Noninteractive, fileName, fileName);
            };
              choose.Destroy();
            }

              if (image != null)
            {
              image.CleanAll();
              ActiveDisplay = new Display(image);
              ActiveImage = image;
              return true;
            }

              return false;
        }
开发者ID:unhammer,项目名称:gimp-sharp,代码行数:32,代码来源:OpenEvent.cs

示例8: OpenClicked

		protected virtual void OpenClicked (object sender, System.EventArgs e)
		{
			FileChooserDialog dlg = new FileChooserDialog (
				GettextCatalog.GetString ("Select Executable"), null, FileChooserAction.Open,
				"gtk-cancel", ResponseType.Cancel,
				"gtk-open", ResponseType.Accept
			);
			dlg.SelectMultiple = false;
			dlg.LocalOnly = true;
			dlg.Modal = true;
			dlg.SetCurrentFolder (Environment.GetFolderPath (Environment.SpecialFolder.Personal));
			
			FileFilter filterExe = new FileFilter ();
			filterExe.AddPattern ("*.exe");
			filterExe.Name = GettextCatalog.GetString ("Executables");
			FileFilter filterAll = new FileFilter ();
			filterAll.AddPattern ("*");
			filterAll.Name = GettextCatalog.GetString ("All files");
			dlg.AddFilter (filterExe);
			dlg.AddFilter (filterAll);

			if (dlg.Run () == (int)ResponseType.Accept)
				entryExecutable.Text = dlg.Filename;
			dlg.Destroy ();
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:25,代码来源:SelectExecutableDialog.cs

示例9: OnButtonClicked

    protected void OnButtonClicked(object sender, EventArgs e)
    {
        if (sender == button1)
        {

            Gtk.FileChooserDialog dialog = new Gtk.FileChooserDialog ("Choose item...", this, FileChooserAction.Open, "Cancel",  ResponseType.Cancel, "Insert Spacer",  ResponseType.None, "Add", ResponseType.Accept);

            Gtk.Alignment align = new Alignment (1, 0, 0, 1);
            Gtk.Frame frame = new Frame ("Position");
            Gtk.HBox hbox = new HBox (false, 4);

            RadioButton rbRight;
            rbRight = new RadioButton ("Right");
            hbox.PackEnd(rbRight, false, false, 1);
            hbox.PackEnd(new RadioButton (rbRight, "Left"), false, false, 1);

            frame.Add (hbox);
            align.Add (frame);
            align.ShowAll ();
            dialog.ExtraWidget = align;

            ResponseType response = (ResponseType)dialog.Run ();
            if (response == ResponseType.Accept) {
                RunCommand ("defaults write com.apple.dock " + GetAlign(dialog.ExtraWidget) + " -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>" + dialog.Filename + "</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>' && /bin/sleep 1 &&/usr/bin/killall Dock");
            } else if (response == ResponseType.None) {
                RunCommand ("defaults write com.apple.dock " + GetAlign(dialog.ExtraWidget) + " -array-add '{tile-data={}; tile-type=\"spacer-tile\";}' && /bin/sleep 1 &&/usr/bin/killall Dock");
            }
            dialog.Destroy ();

        }
    }
开发者ID:Eun,项目名称:AddAnyDock,代码行数:31,代码来源:MainWindow.cs

示例10: ShowSaveAsDialog

        internal static string ShowSaveAsDialog(Window parentWindow, string currentFilename = null) 
        {
            var fileChooserDialog = new FileChooserDialog (Mono.Unix.Catalog.GetString ("Save Experiment File"),
                                             parentWindow,
                                             FileChooserAction.Save,
                                             Gtk.Stock.Cancel,
                                             Gtk.ResponseType.Cancel,
                                             Gtk.Stock.Save, Gtk.ResponseType.Ok);
            
            fileChooserDialog.DoOverwriteConfirmation = true;
            fileChooserDialog.AlternativeButtonOrder = new int[] { (int)ResponseType.Ok, (int)ResponseType.Cancel };
            fileChooserDialog.SelectMultiple = false;

            if (String.IsNullOrEmpty(currentFilename) == false)
            {
                fileChooserDialog.SetFilename(currentFilename);
            }

            AddFilters(fileChooserDialog);

            int response = fileChooserDialog.Run();
            
            string filename = null;
            if(response == (int)Gtk.ResponseType.Ok) 
            {
                filename = fileChooserDialog.Filename;
            }
            
            fileChooserDialog.Destroy();
            
            return filename;
        }
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:32,代码来源:FileDialogs.cs

示例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); }
        }
开发者ID:TimeScience,项目名称:desert-deflicker,代码行数:32,代码来源:CreateFilterset.cs

示例12: 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;
        }
开发者ID:QualitySolution,项目名称:QSProjects,代码行数:35,代码来源:TemplatesMain.cs

示例13: 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 ();
        }
开发者ID:rolandixor,项目名称:Pinta,代码行数:34,代码来源:OpenDocumentAction.cs

示例14: 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;
    }
开发者ID:NTAWolf,项目名称:CSharpExamPrepper,代码行数:25,代码来源:MainWindow.cs

示例15: 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();
        }
开发者ID:jrudolph,项目名称:do-plugins,代码行数:33,代码来源:SystemServicesConfig.cs


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