本文整理汇总了C#中SelectFileDialog.AddFilter方法的典型用法代码示例。如果您正苦于以下问题:C# SelectFileDialog.AddFilter方法的具体用法?C# SelectFileDialog.AddFilter怎么用?C# SelectFileDialog.AddFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SelectFileDialog
的用法示例。
在下文中一共展示了SelectFileDialog.AddFilter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: OnButton24Clicked
protected virtual void OnButton24Clicked (object sender, System.EventArgs e)
{
var dialog = new SelectFileDialog (GettextCatalog.GetString ("Add items to toolbox")) {
SelectMultiple = true,
TransientFor = this,
};
dialog.AddFilter (null, "*.dll");
if (dialog.Run ()) {
indexModified = true;
// Add the new files to the index
using (var monitor = new MessageDialogProgressMonitor (true, false, false, true)) {
monitor.BeginTask (GettextCatalog.GetString ("Looking for components..."), dialog.SelectedFiles.Length);
foreach (string s in dialog.SelectedFiles) {
var cif = index.AddFile (s);
monitor.Step (1);
if (cif != null) {
// Select all new items by default
foreach (var it in cif.Components)
currentItems.Add (it, it);
}
else
MessageService.ShowWarning (GettextCatalog.GetString ("The file '{0}' does not contain any component.", s));
}
}
Fill ();
}
}
示例3: 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;
}
示例4: 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 ();
}
}
示例5: 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);
}
}
示例6: 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);
}
示例7: 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;
}
示例8: 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;
}
示例9: BrowseForStylesheetFile
/// <summary>Allows the user to browse the file system for a stylesheet.</summary>
/// <returns>The stylesheet filename the user selected; otherwise null.</returns>
public static string BrowseForStylesheetFile ()
{
var dlg = new SelectFileDialog (GettextCatalog.GetString ("Select XSLT Stylesheet")) {
TransientFor = IdeApp.Workbench.RootWindow,
};
dlg.AddFilter (new SelectFileDialogFilter (
GettextCatalog.GetString ("XML Files"),
new string[] { "*.xml" },
new string[] { "text/xml", "application/xml" }
));
dlg.AddFilter (new SelectFileDialogFilter(
GettextCatalog.GetString ("XSL Files"),
new string[] { "*.xslt", "*.xsl" },
new string[] { "text/x-xslt" }
));
dlg.AddAllFilesFilter ();
if (dlg.Run ())
return dlg.SelectedFile;
return null;
}
示例10: AddColorScheme
void AddColorScheme (object sender, EventArgs args)
{
var dialog = new SelectFileDialog (GettextCatalog.GetString ("Application to Debug"), Gtk.FileChooserAction.Open) {
TransientFor = this.Toplevel as Gtk.Window,
};
dialog.AddFilter (null, "*.xml");
if (!dialog.Run ())
return;
System.Collections.Generic.List<System.Xml.Schema.ValidationEventArgs> validationResult;
try {
validationResult = Mono.TextEditor.Highlighting.SyntaxModeService.ValidateStyleFile (dialog.SelectedFile);
} catch (Exception) {
MessageService.ShowError (GettextCatalog.GetString ("Validation of style file failed."));
return;
}
if (validationResult.Count == 0) {
string newFileName = SourceEditorDisplayBinding.SyntaxModePath.Combine (dialog.SelectedFile.FileName);
if (!newFileName.EndsWith ("Style.xml"))
newFileName = SourceEditorDisplayBinding.SyntaxModePath.Combine (dialog.SelectedFile.FileNameWithoutExtension + "Style.xml");
bool success = true;
try {
File.Copy (dialog.SelectedFile, newFileName);
} catch (Exception e) {
success = false;
LoggingService.LogError ("Can't copy syntax mode file.", e);
}
if (success) {
SourceEditorDisplayBinding.LoadCustomStylesAndModes ();
ShowStyles ();
}
} else {
StringBuilder errorMessage = new StringBuilder ();
errorMessage.AppendLine (GettextCatalog.GetString ("Validation of style file failed."));
int count = 0;
foreach (System.Xml.Schema.ValidationEventArgs vArg in validationResult) {
errorMessage.AppendLine (vArg.Message);
if (count++ > 5) {
errorMessage.AppendLine ("...");
break;
}
}
MessageService.ShowError (errorMessage.ToString ());
}
}
示例11: AddColorScheme
void AddColorScheme (object sender, EventArgs args)
{
var dialog = new SelectFileDialog (GettextCatalog.GetString ("Highlighting Scheme"), Gtk.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 = SourceEditorDisplayBinding.SyntaxModePath.Combine (dialog.SelectedFile.FileName);
bool success = true;
try {
File.Copy (dialog.SelectedFile.FullPath, newFileName);
} catch (Exception e) {
success = false;
LoggingService.LogError ("Can't copy syntax mode file.", e);
}
if (success) {
SourceEditorDisplayBinding.LoadCustomStylesAndModes ();
ShowStyles ();
}
}
示例12: HandleButtonExportClicked
void HandleButtonExportClicked (object sender, EventArgs e)
{
var dialog = new SelectFileDialog (GettextCatalog.GetString ("Highlighting Scheme"), Gtk.FileChooserAction.Save) {
TransientFor = this.Toplevel as Gtk.Window,
};
dialog.AddFilter (null, "*.xml");
if (!dialog.Run ())
return;
TreeIter selectedIter;
if (styleTreeview.Selection.GetSelected (out selectedIter)) {
var sheme = (Mono.TextEditor.Highlighting.ColorSheme)this.styleStore.GetValue (selectedIter, 1);
sheme.Save (dialog.SelectedFile);
}
}
示例13: 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);
}
示例14: 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;
}
示例15: 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);
}