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


C# FileChooserDialog.SetFilename方法代码示例

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


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

示例1: 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");
        }
开发者ID:torvall,项目名称:pixclip-linux,代码行数:28,代码来源:Main.cs

示例2: 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

示例3: OnTargetHXMLFileButtonClicked

		protected void OnTargetHXMLFileButtonClicked (object sender, System.EventArgs e)
		{
			Gtk.FileChooserDialog fc =
                new Gtk.FileChooserDialog ("Target HXML file", this.Toplevel as Gtk.Window, FileChooserAction.Open,
                    "Cancel", ResponseType.Cancel,
                    "Select", ResponseType.Accept);
			
			Gtk.FileFilter filterHXML = new Gtk.FileFilter ();
			filterHXML.Name = "HXML Files";
			filterHXML.AddPattern ("*.nmml");
			
			Gtk.FileFilter filterAll = new Gtk.FileFilter ();
			filterAll.Name = "All Files";
			filterAll.AddPattern ("*");
			
			fc.AddFilter (filterHXML);
			fc.AddFilter (filterAll);
			
			if (mProject.TargetHXMLFile != "")
			{
				fc.SetFilename (mProject.TargetHXMLFile);
			}
			else
			{
				fc.SetFilename (mProject.BaseDirectory);
			}

			if (fc.Run () == (int)ResponseType.Accept)
			{
				string path = PathHelper.ToRelativePath (fc.Filename, mProject.BaseDirectory);
				
				TargetHXMLFileEntry.Text = path;
			}

			fc.Destroy ();
		}
开发者ID:igwtech,项目名称:md-haxebinding,代码行数:36,代码来源:HaxeProjectOptionsPanel.cs

示例4: OnButtonFileChooserClicked

 protected void OnButtonFileChooserClicked(object sender, EventArgs e)
 {
     FileChooserDialog fc =
         new FileChooserDialog ("Укажите файл резервной копии",
             this,
             FileChooserAction.Save,
             "Отмена", ResponseType.Cancel,
             "Сохранить", ResponseType.Accept);
     fc.SetFilename (entryFileName.Text);
     fc.Show ();
     if (fc.Run () == (int)ResponseType.Accept) {
         entryFileName.Text = fc.Filename;
     }
     fc.Destroy ();
 }
开发者ID:QualitySolution,项目名称:QSProjects,代码行数:15,代码来源:DBUpdateProcess.cs

示例5: OnWPlayerPathButtonClicked

        protected virtual void OnWPlayerPathButtonClicked(object sender, System.EventArgs e)
        {
            Gtk.FileChooserDialog fc =
                new Gtk.FileChooserDialog("Standalone Player Path", this.Toplevel as Gtk.Window, FileChooserAction.Open,
                    "Cancel", ResponseType.Cancel,
                    "Select", ResponseType.Accept);
            if (!String.IsNullOrEmpty(wSdkPathEntry.Text))
                fc.SetFilename(wPlayerPathEntry.Text);

            if (fc.Run() == (int)ResponseType.Accept) {
                wPlayerPathEntry.Text = fc.Filename;
            }

            fc.Destroy();
        }
开发者ID:tjhei,项目名称:md-haxebinding,代码行数:15,代码来源:HaxeOptionsPanel.cs

示例6: OnChoose

    private void OnChoose(object o, EventArgs args)
    {
        FileChooserDialog dialog = new FileChooserDialog("Choose resource", null, FileChooserAction.Open, new object[] {});
        dialog.AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
        dialog.AddButton(Gtk.Stock.Open, Gtk.ResponseType.Ok);
        dialog.DefaultResponse = Gtk.ResponseType.Ok;

        dialog.Action = FileChooserAction.Open;
        dialog.SetFilename(Settings.Instance.SupertuxData + entry.Text);
        int result = dialog.Run();
        if(result != (int) ResponseType.Ok) {
            dialog.Destroy();
            return;
        }

        if(dialog.Filename.StartsWith(Settings.Instance.SupertuxData))
            entry.Text = dialog.Filename.Substring(Settings.Instance.SupertuxData.Length,
                                                   dialog.Filename.Length - Settings.Instance.SupertuxData.Length);
        else
            entry.Text = System.IO.Path.GetFileName(dialog.Filename);
        // Fixes backslashes on windows:
        entry.Text = entry.Text.Replace("\\", "/");
        dialog.Destroy();
    }
开发者ID:BackupTheBerlios,项目名称:supertux-svn,代码行数:24,代码来源:ChooseResourceWidget.cs

示例7: CreateFileChooserDialog

		protected virtual FileChooserDialog CreateFileChooserDialog()
		{
			// TODO: set parent
			var dlg = new FileChooserDialog(Title, null, Action);
			dlg.Response += HandleDlgResponse;

			if (ShowHelp)
				dlg.AddButton(FileDialogStrings.Help, ResponseType.Help);
			dlg.AddButton(FileDialogStrings.Cancel, ResponseType.Cancel);
			dlg.AddButton(AcceptButtonText, ResponseType.Accept);

			dlg.LocalOnly = true;
			dlg.SelectMultiple = Multiselect;
			if (!string.IsNullOrEmpty(InitialDirectory))
				dlg.SetCurrentFolder(InitialDirectory);
			if (!string.IsNullOrEmpty(FileName))
				dlg.SetFilename(FileName);

			ApplyFilter(dlg);

			return dlg;
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:22,代码来源:FileDialogLinux.cs

示例8: chooseTpkgPath

        // END HERZUM SPRINT 3: TLAB-86

        private bool chooseTpkgPath(out string path){
            bool result = false;
            var fileChooserDialog = new FileChooserDialog (Mono.Unix.Catalog.GetString ("Choose package name"),
                                                           null,
                                                           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;

            AddFilters(fileChooserDialog);
            String currentPath = changePathToTpkg(m_applicationViewModel.Experiment.ExperimentInfo.FilePath);
            fileChooserDialog.SetFilename(currentPath);
            fileChooserDialog.SetCurrentFolder (currentPath);

            int response = fileChooserDialog.Run();

            string filename = null;

            if(response == (int)Gtk.ResponseType.Ok) 
            {
                filename = fileChooserDialog.Filename;
            }

            fileChooserDialog.Destroy();
            result = true;
            path = addTpkgExtIfNeeded(filename);

            return result;
        }
开发者ID:CoEST,项目名称:TraceLab,代码行数:35,代码来源:ExperimentCanvasPad.cs

示例9: OnButton17Pressed

 // Save
 protected void OnButton17Pressed(object sender, EventArgs e)
 {
     FileChooserDialog sav = new FileChooserDialog("Save My Nes palette present file",
                                 this, FileChooserAction.Save,
                                 Stock.Cancel, ResponseType.Cancel,
                                 Stock.Save, ResponseType.Accept);
     FileFilter filter = new FileFilter();
     filter.Name = "My Nes Palette Present (*.mnpp)";
     filter.AddMimeType("mnpp");
     filter.AddPattern("*.mnpp");
     sav.AddFilter(filter);
     sav.SetFilename("present.mnpp");
     if (sav.Run() == (int)ResponseType.Accept)
     {
         List<string> lines = new List<string>();
         lines.Add("Brightness=" + NTSCPaletteGenerator.brightness);
         lines.Add("Contrast=" + NTSCPaletteGenerator.contrast);
         lines.Add("Gamma=" + NTSCPaletteGenerator.gamma);
         lines.Add("Hue=" + NTSCPaletteGenerator.hue_tweak);
         lines.Add("Saturation=" + NTSCPaletteGenerator.saturation);
         File.WriteAllLines(sav.Filename, lines.ToArray());
     }
     sav.Destroy();
 }
开发者ID:Blizz9,项目名称:FanCut,代码行数:25,代码来源:Dialog_Palettes.cs

示例10: OnSaveActionActivated

    protected void OnSaveActionActivated(object sender, EventArgs e)
    {
        if (gameInfoList == null)
        {
            Gtk.MessageDialog dialog = new Gtk.MessageDialog(this,
                                           Gtk.DialogFlags.DestroyWithParent,
                                           Gtk.MessageType.Error,
                                           Gtk.ButtonsType.Ok,
                                           "No info entry to save !!");

            dialog.Run();
            dialog.Destroy();
            return;
        }

        FileChooserDialog openD = new FileChooserDialog("Save text file",
                                      this, FileChooserAction.Save,
                                      Stock.Cancel, ResponseType.Cancel,
                                      Stock.Save, ResponseType.Accept);
        FileFilter filter = new FileFilter();
        filter.Name = "Text file (*.txt)";
        filter.AddMimeType("Text");
        filter.AddPattern("*.txt");
        openD.AddFilter(filter);
        openD.SetFilename(filechooserwidget2.Filename.Replace(".nes", ".txt"));
        if (openD.Run() == (int)ResponseType.Accept)
        {
            File.WriteAllLines(openD.Filename, gameInfoLines.ToArray(), System.Text.Encoding.UTF8);
            try
            {
                Process.Start(openD.Filename);
            }
            catch
            {
            }
        }
        openD.Destroy();
    }
开发者ID:Blizz9,项目名称:FanCut,代码行数:38,代码来源:MainWindow.cs

示例11: FileDialog

		/// <summary>
		/// Opens a file dialog with the given settings.
		/// </summary>
		public bool FileDialog(FileDialogDef def)
		{
			// decide which action to use
			gtk.FileChooserAction action = gtk.FileChooserAction.Save;
			string accept = "";
			if (def.Type == FileDialogType.Open)
			{
				action = gtk.FileChooserAction.Open;
				accept = "Open";
			}
			else if (def.Type == FileDialogType.SaveAs)
			{
				action = gtk.FileChooserAction.Save;
				accept = "Save";
			}
			
			var dialog = new gtk.FileChooserDialog(def.Title, 
							this.Toplevel as gtk.Window, action,
							"Cancel", gtk.ResponseType.Cancel,
                            accept, gtk.ResponseType.Accept);
			if (def.FileName != null)
				dialog.SetFilename(def.FileName);
			
			// assemble the filters
			foreach (var ext in def.Extensions)
			{
				var filter = new gtk.FileFilter();
				var pattern = "*." + ext;
				filter.AddPattern(pattern);
				filter.Name = def.GetDescription(ext) + " (" + pattern + ")";
				dialog.AddFilter(filter);
			}
			
			var ret = dialog.Run() == (int)gtk.ResponseType.Accept;
			def.FileName = dialog.Filename;
			dialog.Destroy();
			return ret;
		}
开发者ID:erisonliang,项目名称:monoworks,代码行数:41,代码来源:ViewportAdapter.cs

示例12: 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

示例13: LoadCEStage


//.........这里部分代码省略.........
        {
            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)
            {
                fcd.SetFilename(mStage.RawFileName);
                rpw.Filename = mStage.RawFileName;
                rsw.RawFileName = mStage.RawFileName;
                fcd.PreviewWidgetActive = rpw.FileIsGood;
                options_box.Sensitive = rpw.FileIsGood;
            }

            string filename = ""; int prescale = 2;
            bool ok = false;

            if (fcd.Run() == (int)Gtk.ResponseType.Accept)
            {
                ok = true;
                filename = fcd.Filename;
                prescale = pssw.Value;
            }

            fcd.Destroy();

            if (ok)
            {
                if (mStage.RawFileName != filename)
                {
                    mStage.AskLoadImage(filename, prescale);
                }
                mStage.LoadStage(rsw.SelectedReceiptFileName);
                return true;
            }
        }
        return false;
    }
开发者ID:bigfatbrowncat,项目名称:CatEye,代码行数:101,代码来源:StageEditorWindow.cs

示例14: SaveFileAs

        // This is actually both for "Save As" and saving a file that never
        // been saved before.  Either way, we need to prompt for a filename.
        private bool SaveFileAs(Document document)
        {
            var fcd = new FileChooserDialog (Mono.Unix.Catalog.GetString ("Save Image File"),
                                           PintaCore.Chrome.MainWindow,
                                           FileChooserAction.Save,
                                           Gtk.Stock.Cancel,
                                           Gtk.ResponseType.Cancel,
                                           Gtk.Stock.Save, Gtk.ResponseType.Ok);

            fcd.DoOverwriteConfirmation = true;
            fcd.SetCurrentFolder (lastDialogDir);
            fcd.AlternativeButtonOrder = new int[] { (int)ResponseType.Ok, (int)ResponseType.Cancel };

            bool hasFile = document.HasFile;

            if (hasFile)
                fcd.SetFilename (document.PathAndFileName);

            Dictionary<FileFilter, FormatDescriptor> filetypes = new Dictionary<FileFilter, FormatDescriptor> ();

            // Add all the formats we support to the save dialog
            foreach (var format in PintaCore.System.ImageFormats.Formats) {
                if (!format.IsReadOnly ()) {
                    fcd.AddFilter (format.Filter);
                    filetypes.Add (format.Filter, format);
                }
            }

            // If we already have a format, set it to the default.
            // If not, default to jpeg
            if (hasFile)
                fcd.Filter = PintaCore.System.ImageFormats.GetFormatByFile (document.Filename).Filter;
            else
                fcd.Filter = PintaCore.System.ImageFormats.GetDefaultFormat ().Filter;

            // Replace GTK's ConfirmOverwrite with our own, for UI consistency
            fcd.ConfirmOverwrite += (eventSender, eventArgs) => {
                if (this.ConfirmOverwrite (fcd, fcd.Filename))
                    eventArgs.RetVal = FileChooserConfirmation.AcceptFilename;
                else
                    eventArgs.RetVal = FileChooserConfirmation.SelectAgain;
            };

            while (fcd.Run () == (int)Gtk.ResponseType.Ok) {
                FormatDescriptor format = filetypes[fcd.Filter];
                string file = fcd.Filename;

                if (string.IsNullOrEmpty (Path.GetExtension (file))) {
                    // No extension; add one from the format descriptor.
                    file = string.Format ("{0}.{1}", file, format.Extensions[0]);
                    fcd.CurrentName = Path.GetFileName (file);

                    // We also need to display an overwrite confirmation message manually,
                    // because MessageDialog won't do this for us in this case.
                    if (File.Exists (file) && !ConfirmOverwrite (fcd, file))
                        continue;
                }

                // Always follow the extension rather than the file type drop down
                // ie: if the user chooses to save a "jpeg" as "foo.png", we are going
                // to assume they just didn't update the dropdown and really want png
                var format_type = PintaCore.System.ImageFormats.GetFormatByFile (file);

                if (format_type != null)
                    format = format_type;

                lastDialogDir = fcd.CurrentFolder;
                SaveFile (document, file, format);
                RecentManager.Default.AddFull (fcd.Uri, recentData);
                PintaCore.System.ImageFormats.SetDefaultFormat (Path.GetExtension (file));

                document.HasFile = true;
                document.PathAndFileName = file;

                fcd.Destroy ();
                return true;
            }

            fcd.Destroy ();
            return false;
        }
开发者ID:RodH257,项目名称:Pinta,代码行数:83,代码来源:DialogHandlers.cs

示例15: FileChooser

        string FileChooser(string title, string defaultName,
			string defaultFolder, string filterName, string extensionFilter,
			FileChooserAction action)
        {
            FileChooserDialog fChooser;
            FileFilter filter;
            string button, path;

            if (action == FileChooserAction.Save)
                button = "gtk-save";
            else
                button = "gtk-open";

            fChooser = new FileChooserDialog(title, mainWindow as Gtk.Window, action,
                "gtk-cancel",ResponseType.Cancel, button, ResponseType.Accept);

            if (defaultFolder != null)
                fChooser.SetCurrentFolder(defaultFolder);
            if (defaultName != null)
                fChooser.SetFilename(defaultName);
            if (filterName != null) {
                filter = new FileFilter();
                filter.Name = filterName;
                filter.AddPattern(extensionFilter);
                fChooser.AddFilter(filter);
            }

            if (fChooser.Run() != (int)ResponseType.Accept)
                path = null;
            else
                path = fChooser.Filename;

            fChooser.Destroy();
            return path;
        }
开发者ID:dineshkummarc,项目名称:longomatch,代码行数:35,代码来源:GUIToolkit.cs


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