• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# SelectFileDialog类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



SelectFileDialog类属于命名空间,在下文中一共展示了SelectFileDialog类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ShowBrowseDialog

		protected override string ShowBrowseDialog (string name, string startIn)
		{
			var fd = new SelectFileDialog (name, Action);
			if (startIn != null)
				fd.CurrentFolder = startIn;

			fd.SetFilters (FileFilters);
			fd.TransientFor = GetTransientFor ();

			if (fd.Run ())
				return fd.SelectedFile;
			return null;
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:13,代码来源:FileEntry.cs


示例2: ShowBrowseDialog

		protected override string ShowBrowseDialog (string name, string start_in)
		{
			SelectFileDialog fd = new SelectFileDialog (name);
			if (start_in != null)
				fd.InitialFileName = start_in;
			
			fd.TransientFor = GetTransientFor ();
			
			if (fd.Run ())
				return fd.SelectedFile;
			else
				return null;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:13,代码来源:FileEntry.cs


示例3: LaunchDialogue

		public override void LaunchDialogue ()
		{
			var kindAtt = this.Property.Attributes.OfType<FilePathIsFolderAttribute> ().FirstOrDefault ();
			SelectFileDialogAction action;

			string title;
			if (kindAtt == null) {
				action = SelectFileDialogAction.Open;
				title = GettextCatalog.GetString ("Select File...");
			} else {
				action = SelectFileDialogAction.SelectFolder;
				title = GettextCatalog.GetString ("Select Folder...");
			}
			var fs = new SelectFileDialog (title, action);
			if (fs.Run ())
				Property.SetValue (Instance, fs.SelectedFile);
		}
开发者ID:behappyyoung,项目名称:monodevelop,代码行数:17,代码来源:FilePathEditor.cs


示例4: Add

		public void Add ()
		{
			var project = (DotNetProject) CurrentNode.GetParentDataItem (typeof(DotNetProject), true);
			
			var dlg = new SelectFileDialog (GettextCatalog.GetString ("Select Native Library"), Gtk.FileChooserAction.Open);
			dlg.SelectMultiple = true;
			dlg.AddAllFilesFilter ();
			//FIXME: add more filters, amke correct for platform
			dlg.AddFilter (GettextCatalog.GetString ("Static Library"), ".a");
			
			if (!dlg.Run ())
				return;
			
			foreach (var file in dlg.SelectedFiles) {
				var item = new NativeReference (file);
				project.Items.Add (item);
			}
			
			IdeApp.ProjectOperations.Save (project);
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:20,代码来源:NativeReferenceCommandHandler.cs


示例5: AddWorkspaceItem

		public async Task<WorkspaceItem> AddWorkspaceItem (Workspace parentWorkspace)
		{
			WorkspaceItem res = null;
			
			var dlg = new SelectFileDialog () {
				Action = FileChooserAction.Open,
				CurrentFolder = parentWorkspace.BaseDirectory,
				SelectMultiple = false,
			};
		
			dlg.AddAllFilesFilter ();
			dlg.DefaultFilter = dlg.AddFilter (GettextCatalog.GetString ("Solution Files"), "*.mds", "*.sln");
			
			if (dlg.Run ()) {
				try {
					if (WorkspaceContainsWorkspaceItem (parentWorkspace, dlg.SelectedFile)) {
						MessageService.ShowMessage (GettextCatalog.GetString ("The workspace already contains '{0}'.", Path.GetFileNameWithoutExtension (dlg.SelectedFile)));
						return res;
					}

					res = await AddWorkspaceItem (parentWorkspace, dlg.SelectedFile);
				} catch (Exception ex) {
					MessageService.ShowError (GettextCatalog.GetString ("The file '{0}' could not be loaded.", dlg.SelectedFile), ex);
				}
			}

			return res;
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:28,代码来源:ProjectOperations.cs


示例6: OnAddAssembly

		protected void OnAddAssembly ()
		{
			var config = (NUnitAssemblyGroupProjectConfiguration) CurrentNode.DataItem;
			
			var dlg = new SelectFileDialog (GettextCatalog.GetString ("Add files")) {
				TransientFor = IdeApp.Workbench.RootWindow,
				SelectMultiple = true,
			};
			if (!dlg.Run ())
				return;
			
			foreach (string file in dlg.SelectedFiles)
				config.Assemblies.Add (new TestAssembly (file));
			
			IdeApp.Workspace.Save();
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:16,代码来源:NUnitAssemblyGroupConfigurationNodeBuilder.cs


示例7: BrowseForSchemaFile

		/// <summary>Allows the user to browse the file system for a schema.</summary>
		/// <returns>The schema filename the user selected; otherwise null.</returns>
		public static string BrowseForSchemaFile ()
		{
			var dlg = new SelectFileDialog (GettextCatalog.GetString ("Select XML Schema"));
			dlg.AddFilter (new SelectFileDialogFilter (
				GettextCatalog.GetString ("XML Files"),
				new string[] { "*.xsd" },
				new string[] { "text/xml", "application/xml" }
			));
			dlg.AddAllFilesFilter ();
			
			if (dlg.Run ())
				return dlg.SelectedFile;
			return null;
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:16,代码来源:XmlEditorService.cs


示例8: AddWorkspaceItem

		public WorkspaceItem AddWorkspaceItem (Workspace parentWorkspace)
		{
			WorkspaceItem res = null;
			
			var dlg = new SelectFileDialog () {
				Action = Gtk.FileChooserAction.Open,
				CurrentFolder = parentWorkspace.BaseDirectory,
				SelectMultiple = false,
			};
		
			dlg.AddAllFilesFilter ();
			dlg.DefaultFilter = dlg.AddFilter (GettextCatalog.GetString ("Solution Files"), "*.mds", "*.sln");
			
			if (dlg.Run ()) {
				try {
					res = AddWorkspaceItem (parentWorkspace, dlg.SelectedFile);
				} catch (Exception ex) {
					MessageService.ShowException (ex, GettextCatalog.GetString ("The file '{0}' could not be loaded.", dlg.SelectedFile));
				}
			}

			return res;
		}
开发者ID:nocache,项目名称:monodevelop,代码行数:23,代码来源:ProjectOperations.cs


示例9: AddSolutionItem

		public SolutionItem AddSolutionItem (SolutionFolder parentFolder)
		{
			SolutionItem res = null;
			
			var dlg = new SelectFileDialog () {
				Action = Gtk.FileChooserAction.Open,
				CurrentFolder = parentFolder.BaseDirectory,
				SelectMultiple = false,
			};
		
			dlg.AddAllFilesFilter ();
			dlg.DefaultFilter = dlg.AddFilter (GettextCatalog.GetString ("Project Files"), "*.*proj");
			
			if (dlg.Run ()) {
				if (!Services.ProjectService.IsSolutionItemFile (dlg.SelectedFile)) {
					MessageService.ShowMessage (GettextCatalog.GetString ("The file '{0}' is not a known project file format.", dlg.SelectedFile));
					return res;
				}

				if (SolutionContainsProject (parentFolder, dlg.SelectedFile)) {
					MessageService.ShowMessage (GettextCatalog.GetString ("The project '{0}' has already been added.", Path.GetFileNameWithoutExtension (dlg.SelectedFile)));
					return res;
				}

				try {
					res = AddSolutionItem (parentFolder, dlg.SelectedFile);
				} catch (Exception ex) {
					MessageService.ShowError (GettextCatalog.GetString ("The file '{0}' could not be loaded.", dlg.SelectedFile), ex);
				}
			}
			
			if (res != null)
				IdeApp.Workspace.Save ();

			return res;
		}
开发者ID:lkalif,项目名称:monodevelop,代码行数:36,代码来源:ProjectOperations.cs


示例10: TryGet

		public static Credentials TryGet (string url, string userFromUrl, SupportedCredentialTypes types, GitCredentialsType type)
		{
			bool result = true;
			Uri uri = null;

			GitCredentialsState state;
			if (!credState.TryGetValue (type, out state))
				credState [type] = state = new GitCredentialsState ();
			state.UrlUsed = url;

			// We always need to run the TryGet* methods as we need the passphraseItem/passwordItem populated even
			// if the password store contains an invalid password/no password
			if ((types & SupportedCredentialTypes.UsernamePassword) != 0) {
				uri = new Uri (url);
				string username;
				string password;
				if (!state.NativePasswordUsed && TryGetUsernamePassword (uri, out username, out password)) {
					state.NativePasswordUsed = true;
					return new UsernamePasswordCredentials {
						Username = username,
						Password = password
					};
				}
			}

			Credentials cred;
			if ((types & SupportedCredentialTypes.UsernamePassword) != 0)
				cred = new UsernamePasswordCredentials ();
			else {
				// Try ssh-agent on Linux.
				if (!Platform.IsWindows && !state.AgentUsed) {
					bool agentUsable;
					if (!state.AgentForUrl.TryGetValue (url, out agentUsable))
						state.AgentForUrl [url] = agentUsable = true;

					if (agentUsable) {
						state.AgentUsed = true;
						return new SshAgentCredentials {
							Username = userFromUrl,
						};
					}
				}

				int key;
				if (!state.KeyForUrl.TryGetValue (url, out key)) {
					if (state.KeyUsed + 1 < Keys.Count)
						state.KeyUsed++;
					else {
						SelectFileDialog dlg = null;
						bool success = false;

						DispatchService.GuiSyncDispatch (() => {
							dlg = new SelectFileDialog (GettextCatalog.GetString ("Select a private SSH key to use."));
							dlg.ShowHidden = true;
							dlg.CurrentFolder = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
							success = dlg.Run ();
						});
						if (!success || !File.Exists (dlg.SelectedFile + ".pub"))
							throw new VersionControlException (GettextCatalog.GetString ("Invalid credentials were supplied. Aborting operation."));

						cred = new SshUserKeyCredentials {
							Username = userFromUrl,
							Passphrase = "",
							PrivateKey = dlg.SelectedFile,
							PublicKey = dlg.SelectedFile + ".pub",
						};

						if (KeyHasPassphrase (dlg.SelectedFile)) {
							DispatchService.GuiSyncDispatch (delegate {
								using (var credDlg = new CredentialsDialog (url, types, cred))
									result = MessageService.ShowCustomDialog (credDlg) == (int)Gtk.ResponseType.Ok;
							});
						}

						if (result)
							return cred;
						throw new VersionControlException (GettextCatalog.GetString ("Invalid credentials were supplied. Aborting operation."));
					}
				} else
					state.KeyUsed = key;

				cred = new SshUserKeyCredentials {
					Username = userFromUrl,
					Passphrase = "",
					PrivateKey = Keys [state.KeyUsed],
					PublicKey = Keys [state.KeyUsed] + ".pub",
				};
				return cred;
			}

			DispatchService.GuiSyncDispatch (delegate {
				using (var credDlg = new CredentialsDialog (url, types, cred))
					result = MessageService.ShowCustomDialog (credDlg) == (int)Gtk.ResponseType.Ok;
			});

			if (result) {
				if ((types & SupportedCredentialTypes.UsernamePassword) != 0) {
					var upcred = (UsernamePasswordCredentials)cred;
					if (!string.IsNullOrEmpty (upcred.Password)) {
						PasswordService.AddWebUserNameAndPassword (uri, upcred.Username, upcred.Password);
//.........这里部分代码省略.........
开发者ID:nerzhulart,项目名称:monodevelop,代码行数:101,代码来源:GitCredentials.cs


示例11: Run

		protected override void Run ()
		{
			var proj = GetSelectedMonoMacProject ();
			
			var settings = proj.UserProperties.GetValue<MonoMacPackagingSettings> (PROP_KEY)
				?? MonoMacPackagingSettings.GetAppStoreDefault ();
			
			MonoMacPackagingSettingsDialog dlg;
			try {
				dlg = new MonoMacPackagingSettingsDialog ();
				dlg.LoadSettings (settings);
				if (MessageService.RunCustomDialog (dlg) != (int)ResponseType.Ok)
					return;
				dlg.SaveSettings (settings);
			} finally {
				dlg.Destroy ();
			}
			
			var configSel = IdeApp.Workspace.ActiveConfiguration;
			var cfg = (MonoMacProjectConfiguration) proj.GetConfiguration (configSel);
			
			var ext = settings.CreatePackage? ".pkg" : ".app";
			
			var fileDlg = new SelectFileDialog () {
				Title = settings.CreatePackage?
					GettextCatalog.GetString ("Save Installer Package") :
					GettextCatalog.GetString ("Save Application Bundle"),
				InitialFileName = cfg.AppName + ext,
				Action = FileChooserAction.Save
			};
			fileDlg.DefaultFilter = fileDlg.AddFilter ("", "*" + ext);
			
			if (!fileDlg.Run ())
				return;
			
			proj.UserProperties.SetValue (PROP_KEY, settings);
			
			var target = fileDlg.SelectedFile;
			if (!string.Equals (target.Extension, ext, StringComparison.OrdinalIgnoreCase))
				target.ChangeExtension (ext);
			
			MonoMacPackaging.Package (proj, configSel, settings, target);
		}
开发者ID:carlosaml,项目名称:monodevelop,代码行数:43,代码来源:MonoMacCommands.cs


示例12: HandleButtonExportClicked

		void HandleButtonExportClicked (object sender, EventArgs e)
		{
			var dialog = new SelectFileDialog (GettextCatalog.GetString ("Highlighting Scheme"), MonoDevelop.Components.FileChooserAction.Save) {
				TransientFor = this.Toplevel as Gtk.Window,
			};
			dialog.AddFilter (GettextCatalog.GetString ("Color schemes"), "*.json");
			if (!dialog.Run ())
				return;
			TreeIter selectedIter;
			if (styleTreeview.Selection.GetSelected (out selectedIter)) {
				var sheme = (Mono.TextEditor.Highlighting.ColorScheme)this.styleStore.GetValue (selectedIter, 1);
				var selectedFile = dialog.SelectedFile.ToString ();
				if (!selectedFile.EndsWith (".json", StringComparison.Ordinal))
					selectedFile += ".json";
				sheme.Save (selectedFile);
			}

		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:18,代码来源:HighlightingPanel.cs


示例13: OnButtonBrowseClicked

		protected virtual void OnButtonBrowseClicked(object sender, System.EventArgs e)
		{
			var dlg = new SelectFileDialog (GettextCatalog.GetString ("Select File")) {
				CurrentFolder = entry.BaseDirectory,
				SelectMultiple = false,
				TransientFor = this.Toplevel as Gtk.Window,
			};
			if (!dlg.Run ())
				return;
			if (System.IO.Path.IsPathRooted (dlg.SelectedFile))
				entryCommand.Text = FileService.AbsoluteToRelativePath (entry.BaseDirectory, dlg.SelectedFile);
			else
				entryCommand.Text = dlg.SelectedFile;
		}
开发者ID:Tak,项目名称:monodevelop-novell,代码行数:14,代码来源:CustomCommandWidget.cs


示例14: HandleButtonExportClicked

		void HandleButtonExportClicked (object sender, EventArgs e)
		{
			if (comboboxProfiles.Active < 0)
				return;
			var dialog = new SelectFileDialog (GettextCatalog.GetString ("Export profile"), Gtk.FileChooserAction.Save) {
				TransientFor = this.Toplevel as Gtk.Window,
			};
			dialog.AddFilter (null, "*.xml");
			if (!dialog.Run ())
				return;
			policies[comboboxProfiles.Active].Save (dialog.SelectedFile);
		}
开发者ID:Tak,项目名称:monodevelop-novell,代码行数:12,代码来源:CSharpFormattingPolicyPanelWidget.cs


示例15: HandleButtonImportClicked

		void HandleButtonImportClicked (object sender, EventArgs e)
		{
			var dialog = new SelectFileDialog (GettextCatalog.GetString ("Profile to import"), Gtk.FileChooserAction.Open) {
				TransientFor = this.Toplevel as Gtk.Window,
			};
			dialog.AddFilter (null, "*.xml");
			if (!dialog.Run ())
				return;
			int selection = comboboxProfiles.Active;
			var p = CSharpFormattingPolicy.Load (dialog.SelectedFile);
			FormattingProfileService.AddProfile (p);
			policies.Add (p);
			InitComboBox ();
			comboboxProfiles.Active = selection;
		}
开发者ID:Tak,项目名称:monodevelop-novell,代码行数:15,代码来源:CSharpFormattingPolicyPanelWidget.cs


示例16: BrowseForSchemaFile

		/// <summary>Allows the user to browse the file system for a schema.</summary>
		/// <returns>The schema filename the user selected; otherwise null.</returns>
		public static string BrowseForSchemaFile ()
		{
			var dlg = new SelectFileDialog (GettextCatalog.GetString ("Select XML Schema")) {
				TransientFor = IdeApp.Workbench.RootWindow,
			};
			dlg.AddFilter (new SelectFileDialogFilter (GettextCatalog.GetString ("XML Files"), "*.xsd") {
				MimeTypes = { "text/xml", "application/xml" },
			});
			dlg.AddAllFilesFilter ();
			
			if (dlg.Run ())
				return dlg.SelectedFile;
			return null;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:16,代码来源:XmlEditorService.cs


示例17: HandleButtonImportClicked

		void HandleButtonImportClicked (object sender, EventArgs e)
		{
			var dialog = new SelectFileDialog (GettextCatalog.GetString ("Highlighting Scheme"), Gtk.FileChooserAction.Open)
				{
					TransientFor = this.Toplevel as Gtk.Window,
				};
			dialog.AddFilter ("Visual Studio 2010 settings file", "*.vssettings");
			dialog.AddFilter ("XML file", "*.xml");
			if (!dialog.Run ())
				return;
			
			var defStyle = Mono.TextEditor.Highlighting.SyntaxModeService.GetColorStyle (this.Style, "Default");
			var style = defStyle.Clone ();   
			var vsImporter = new VisualStudioHighlitingSchemeImporter ();  
			
			style.Name = "Absolutely new style";
			style.Description = "Absolutely new style description";
			
			var path = SourceEditorDisplayBinding.SyntaxModePath;
			var baseName = style.Name.Replace (" ", "_");
			
			while (File.Exists (System.IO.Path.Combine (path, baseName + "Style.xml")))
			{
				baseName = baseName + "_";
			}
			
			var fileName = System.IO.Path.Combine (path, baseName + "Style.xml");
			
			try
			{
				vsImporter.Import (dialog.SelectedFile, style);
				MonoDevelop.Ide.MessageService.ShowMessage (fileName);
				style.Save (fileName);
				Mono.TextEditor.Highlighting.SyntaxModeService.AddStyle (fileName, style);
			}
 			catch (Exception ex)
			{
				MonoDevelop.Ide.MessageService.ShowException (ex);
			}
			
			//var fileName = Mono.TextEditor.Highlighting.SyntaxModeService.GetFileNameForStyle (style);
			
			
			//style.Save (fileName);
		}
开发者ID:DarkMindCrawler,项目名称:monodevelop,代码行数:45,代码来源:HighlightingPanel.cs


示例18: Run

		protected override void Run ()
		{
			var dialog = new SelectFileDialog (GettextCatalog.GetString ("Application to Debug")) {
				TransientFor = IdeApp.Workbench.RootWindow,
			};
			if (dialog.Run ()) {
				if (IdeApp.ProjectOperations.CanDebugFile (dialog.SelectedFile))
					IdeApp.ProjectOperations.DebugApplication (dialog.SelectedFile);
				else
					MessageService.ShowError (GettextCatalog.GetString ("The file '{0}' can't be debugged", dialog.SelectedFile));
			}
		}
开发者ID:vitorelli,项目名称:monodevelop,代码行数:12,代码来源:DebugCommands.cs


示例19: Run

		protected override void Run ()
		{
			var dialog = new SelectFileDialog (GettextCatalog.GetString ("Application to Debug")) {
				TransientFor = IdeApp.Workbench.RootWindow,
			};
			if (dialog.Run ())
				IdeApp.ProjectOperations.DebugApplication (dialog.SelectedFile);
		}
开发者ID:acken,项目名称:monodevelop,代码行数:8,代码来源:DebugCommands.cs


示例20: AddColorScheme

		void AddColorScheme (object sender, EventArgs args)
		{
			var dialog = new SelectFileDialog (GettextCatalog.GetString ("Highlighting Scheme"), MonoDevelop.Components.FileChooserAction.Open) {
				TransientFor = this.Toplevel as Gtk.Window,
			};
			dialog.AddFilter (GettextCatalog.GetString ("Color schemes"), "*.json");
			dialog.AddFilter (GettextCatalog.GetString ("Visual Studio .NET settings"), "*.vssettings");
			if (!dialog.Run ())
				return;

			string newFileName = MonoDevelop.Ide.Editor.TextEditorDisplayBinding.SyntaxModePath.Combine (dialog.SelectedFile.FileName);

			bool success = true;
			try {
				if (File.Exists (newFileName)) {
					MessageService.ShowError (string.Format (GettextCatalog.GetString ("Highlighting with the same name already exists. Remove {0} first."), System.IO.Path.GetFileNameWithoutExtension (newFileName)));
					return;
				}

				File.Copy (dialog.SelectedFile.FullPath, newFileName);
			} catch (Exception e) {
				success = false;
				LoggingService.LogError ("Can't copy syntax mode file.", e);
			}
			if (success) {
				Mono.TextEditor.Highlighting.SyntaxModeService.LoadStylesAndModes (TextEditorDisplayBinding.SyntaxModePath);
				MonoDevelop.Ide.Editor.Highlighting.SyntaxModeService.LoadStylesAndModes (TextEditorDisplayBinding.SyntaxModePath);
				MonoDevelop.Ide.Editor.TextEditorDisplayBinding.LoadCustomStylesAndModes ();
				ShowStyles ();
			}
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:31,代码来源:HighlightingPanel.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SelectList类代码示例发布时间:2022-05-24
下一篇:
C# SelectExpression类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap