本文整理汇总了C#中OpenFileDialog.AddFilter方法的典型用法代码示例。如果您正苦于以下问题:C# OpenFileDialog.AddFilter方法的具体用法?C# OpenFileDialog.AddFilter怎么用?C# OpenFileDialog.AddFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenFileDialog
的用法示例。
在下文中一共展示了OpenFileDialog.AddFilter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleToFile
void HandleToFile (object sender, EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog (GettextCatalog.GetString ("Select Policy File"));
dlg.TransientFor = this;
dlg.InitialFileName = currentSet.Name + ".mdpolicy";
dlg.Action = FileChooserAction.Save;
dlg.AddFilter (BrandingService.BrandApplicationName (GettextCatalog.GetString ("MonoDevelop policy files")), "*.mdpolicy");
dlg.AddAllFilesFilter ();
dlg.CurrentFolder = ExportProjectPolicyDialog.DefaultFileDialogPolicyDir;
if (dlg.Run ()) {
try {
currentSet.SaveToFile (dlg.SelectedFile);
ExportProjectPolicyDialog.DefaultFileDialogPolicyDir = dlg.SelectedFile.ParentDirectory;
} catch (Exception ex) {
MessageService.ShowException (ex, GettextCatalog.GetString ("The policy set could not be saved"));
}
}
}
示例2: HandleClicked
void HandleClicked (object sender, EventArgs e)
{
var dlg = new OpenFileDialog (GettextCatalog.GetString ("Select Assembly"), FileChooserAction.Open);
// dlg.AddFilter (GettextCatalog.GetString ("Assemblies"), "*.[Dd][Ll][Ll]", "*.[Ee][Xx][Ee]");
dlg.AddFilter (GettextCatalog.GetString ("Assemblies"), "*.dll", "*.exe");
dlg.CurrentFolder = basePath;
dlg.SelectMultiple = true;
if (dlg.Run ()) {
basePath = dlg.CurrentFolder;
foreach (string file in dlg.SelectedFiles) {
var fn = new FilePath (file).CanonicalPath;
var asm = assemblies.FirstOrDefault (a => a.File.Equals (fn));
if (asm != null) {
if (!asm.Selected) {
asm.Selected = true;
AddReference (file);
}
continue;
}
bool isAssembly = true;
try {
SystemAssemblyService.GetAssemblyName (System.IO.Path.GetFullPath (file));
} catch {
isAssembly = false;
}
if (isAssembly) {
assemblies.Add (new AssemblyInfo (file) { Selected = true });
AddReference (file);
if (IsExternalAssembly (file))
selectDialog.RegisterFileReference (file);
else if (!IsNuGetAssembly (file))
selectDialog.RegisterFileReference (file, project.ParentSolution.FileName);
} else {
MessageService.ShowError (GettextCatalog.GetString ("File '{0}' is not a valid .Net Assembly", file));
}
}
Reset ();
}
}
示例3: HandleFromFile
void HandleFromFile (object sender, EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog (GettextCatalog.GetString ("Select Policy File"));
dlg.Action = FileChooserAction.Open;
dlg.TransientFor = this;
dlg.AddFilter (BrandingService.BrandApplicationName (GettextCatalog.GetString ("MonoDevelop policy files")), "*.mdpolicy");
dlg.AddAllFilesFilter ();
dlg.CurrentFolder = ExportProjectPolicyDialog.DefaultFileDialogPolicyDir;
if (dlg.Run ()) {
try {
PolicySet pset = new PolicySet ();
pset.LoadFromFile (dlg.SelectedFile);
if (string.IsNullOrEmpty (pset.Name))
pset.Name = dlg.SelectedFile.FileNameWithoutExtension;
pset.Name = GetUnusedName (pset.Name);
sets.Add (pset);
ExportProjectPolicyDialog.DefaultFileDialogPolicyDir = dlg.SelectedFile.ParentDirectory;
FillPolicySets ();
policiesCombo.Active = sets.IndexOf (pset);
} catch (Exception ex) {
MessageService.ShowException (ex, GettextCatalog.GetString ("The policy set could not be loaded"));
}
}
}