當前位置: 首頁>>代碼示例>>C#>>正文


C# FileDialog.GetFilterPattern方法代碼示例

本文整理匯總了C#中System.Windows.Forms.FileDialog.GetFilterPattern方法的典型用法代碼示例。如果您正苦於以下問題:C# FileDialog.GetFilterPattern方法的具體用法?C# FileDialog.GetFilterPattern怎麽用?C# FileDialog.GetFilterPattern使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Forms.FileDialog的用法示例。


在下文中一共展示了FileDialog.GetFilterPattern方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: FileDialogForm


//.........這裏部分代碼省略.........

					// The second line is "listBox", already created above.

					// Add the third line (file name entry fields).
					nameLabel = new Label();
					nameLabel.Text = S._("SWF_FileDialog_FileName",
										 "File name:");
					name = new TextBox();
					okButton = new Button();
					okButton.Text = fileDialogParent.OkButtonName;
					grid.SetControl(0, 0, nameLabel);
					grid.SetControl(1, 0, name);
					grid.SetControl(2, 0, okButton);

					// Add the fourth line (file type entry fields).
					typeLabel = new Label();
					typeLabel.Text = S._("SWF_FileDialog_FilesOfType",
										 "Files of type:");
					type = new ComboBox();
					cancelButton = new Button();
					cancelButton.Text = S._("SWF_MessageBox_Cancel", "Cancel");
					grid.SetControl(0, 1, typeLabel);
					grid.SetControl(1, 1, type);
					grid.SetControl(2, 1, cancelButton);

					// Add the fifth line (read-only checkbox).
					if(fileDialogParent is OpenFileDialog)
					{
						readOnly = new CheckBox();
						readOnly.Text = S._("SWF_FileDialog_ReadOnly",
											"Open as read-only");
						readOnly.Checked =
							((OpenFileDialog)fileDialogParent).ReadOnlyChecked;
						readOnly.Visible =
							((OpenFileDialog)fileDialogParent).ShowReadOnly;
						readOnly.CheckStateChanged +=
							new EventHandler(ReadOnlyStateChanged);
						vbox.Controls.Add(readOnly);
					}

					// Add the top-level vbox to the dialog and set the size.
					Controls.Add(vbox);
					Size size = vbox.RecommendedSize;
					if(size.Width < 500)
					{
						size.Width = 500;
					}
					if(size.Height < 300)
					{
						size.Height = 300;
					}
					ClientSize = size;
					MinimumSize = size;
					MinimizeBox = false;
					ShowInTaskbar = false;

					// Hook up interesting events.
					upButton.Click += new EventHandler(UpOneLevel);
					newDirButton.Click += new EventHandler(NewFolder);
					directory.SelectedIndexChanged +=
						new EventHandler(DirectorySelectionChanged);
					name.TextChanged += new EventHandler(NameTextChanged);
					okButton.Click += new EventHandler(AcceptDialog);
					cancelButton.Click += new EventHandler(CancelDialog);
					type.SelectedIndexChanged +=
						new EventHandler(TypeSelectionChanged);

					// Match the requested settings from the dialog parent.
					RefreshAll();

					// Scan the initial directory.
					String dir = fileDialogParent.InitialDirectory;
					pattern = fileDialogParent.GetFilterPattern();
					if(dir == null || dir.Length == 0)
					{
						dir = Directory.GetCurrentDirectory();
						String filename = fileDialogParent.fileName;
						if(filename != null && filename.Length > 0)
						{
							// Use the previous filename as a starting point.
							if(IsDirectory(filename) ||
							   filename == Path.GetPathRoot(filename))
							{
								dir = filename;
							}
							else
							{
								dir = Path.GetDirectoryName(filename);
							}
						}
					}
					else
					{
						dir = Path.GetFullPath(dir);
					}
					if(!ChangeDirectory(dir))
					{
						ChangeDirectory(Directory.GetCurrentDirectory());
					}
				}
開發者ID:jjenki11,項目名稱:blaze-chem-rendering,代碼行數:101,代碼來源:FileDialog.cs


注:本文中的System.Windows.Forms.FileDialog.GetFilterPattern方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。