本文整理汇总了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());
}
}