本文整理汇总了C#中OpenFileDialog.Run方法的典型用法代码示例。如果您正苦于以下问题:C# OpenFileDialog.Run方法的具体用法?C# OpenFileDialog.Run怎么用?C# OpenFileDialog.Run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenFileDialog
的用法示例。
在下文中一共展示了OpenFileDialog.Run方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PatchWidget
public PatchWidget (ComparisonView comparisonView, VersionControlDocumentInfo info)
{
this.Build ();
diffEditor = new Mono.TextEditor.TextEditor ();
diffEditor.Document.MimeType = "text/x-diff";
diffEditor.Options.FontName = info.Document.Editor.Options.FontName;
diffEditor.Options.ColorScheme = info.Document.Editor.Options.ColorScheme;
diffEditor.Options.ShowFoldMargin = false;
diffEditor.Options.ShowIconMargin = false;
diffEditor.Options.ShowTabs = true;
diffEditor.Options.ShowSpaces = true;
diffEditor.Options.ShowInvalidLines = info.Document.Editor.Options.ShowInvalidLines;
diffEditor.Document.ReadOnly = true;
scrolledwindow1.Child = diffEditor;
diffEditor.ShowAll ();
using (var writer = new StringWriter ()) {
UnifiedDiff.WriteUnifiedDiff (comparisonView.Diff, writer,
System.IO.Path.GetFileName (info.Item.Path) + " (repository)",
System.IO.Path.GetFileName (info.Item.Path) + " (working copy)",
3);
diffEditor.Document.Text = writer.ToString ();
}
buttonSave.Clicked += delegate {
var dlg = new OpenFileDialog (GettextCatalog.GetString ("Save as..."), FileChooserAction.Save) {
TransientFor = IdeApp.Workbench.RootWindow
};
if (!dlg.Run ())
return;
File.WriteAllText (dlg.SelectedFile, diffEditor.Document.Text);
};
}
示例2: Run
protected override void Run ()
{
var dlg = new OpenFileDialog (GettextCatalog.GetString ("File to Open"), Gtk.FileChooserAction.Open) {
TransientFor = IdeApp.Workbench.RootWindow,
ShowEncodingSelector = true,
ShowViewerSelector = true,
};
if (!dlg.Run ())
return;
var file = dlg.SelectedFile;
if (dlg.SelectedViewer != null) {
dlg.SelectedViewer.OpenFile (file, dlg.Encoding);
return;
}
if (Services.ProjectService.IsWorkspaceItemFile (file) || Services.ProjectService.IsSolutionItemFile (file)) {
IdeApp.Workspace.OpenWorkspaceItem (file, dlg.CloseCurrentWorkspace);
}
else
IdeApp.Workbench.OpenDocument (file, dlg.Encoding);
}
示例3: OnCtagsBrowseClicked
protected virtual void OnCtagsBrowseClicked (object sender, System.EventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog (GettextCatalog.GetString ("Choose ctags executable"), FileChooserAction.Open);
if (dialog.Run ())
ctagsEntry.Text = dialog.SelectedFile;
}
示例4: 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 ();
}
}
示例5: ShowLoadSourceFile
void ShowLoadSourceFile (StackFrame sf)
{
if (messageOverlayWindow != null) {
messageOverlayWindow.Destroy ();
messageOverlayWindow = null;
}
messageOverlayWindow = new OverlayMessageWindow ();
var hbox = new HBox ();
hbox.Spacing = 8;
var label = new Label (string.Format ("{0} not found. Find source file at alternative location.", Path.GetFileName (sf.SourceLocation.FileName)));
hbox.TooltipText = sf.SourceLocation.FileName;
var color = (HslColor)editor.ColorStyle.NotificationText.Foreground;
label.ModifyFg (StateType.Normal, color);
int w, h;
label.Layout.GetPixelSize (out w, out h);
hbox.PackStart (label, true, true, 0);
var openButton = new Button (Gtk.Stock.Open);
openButton.WidthRequest = 60;
hbox.PackEnd (openButton, false, false, 0);
var container = new HBox ();
const int containerPadding = 8;
container.PackStart (hbox, true, true, containerPadding);
messageOverlayWindow.Child = container;
messageOverlayWindow.ShowOverlay (editor);
messageOverlayWindow.SizeFunc = () => openButton.SizeRequest ().Width + w + hbox.Spacing * 5 + containerPadding * 2;
openButton.Clicked += delegate {
var dlg = new OpenFileDialog (GettextCatalog.GetString ("File to Open"), SelectFileDialogAction.Open) {
TransientFor = IdeApp.Workbench.RootWindow,
ShowEncodingSelector = true,
ShowViewerSelector = true
};
if (!dlg.Run ())
return;
var newFilePath = dlg.SelectedFile;
try {
if (File.Exists (newFilePath)) {
if (SourceCodeLookup.CheckFileMd5 (newFilePath, sf.SourceLocation.FileHash)) {
SourceCodeLookup.AddLoadedFile (newFilePath, sf.SourceLocation.FileName);
sf.UpdateSourceFile (newFilePath);
if (IdeApp.Workbench.OpenDocument (newFilePath, null, sf.SourceLocation.Line, 1, OpenDocumentOptions.Debugger) != null) {
this.WorkbenchWindow.CloseWindow (false);
}
} else {
MessageService.ShowWarning ("File checksum doesn't match.");
}
} else {
MessageService.ShowWarning ("File not found.");
}
} catch (Exception) {
MessageService.ShowWarning ("Error opening file");
}
};
}
示例6: Run
protected override void Run ()
{
var lang = "text/x-csharp";
OpenFileDialog dlg = new OpenFileDialog ("Export Rules", FileChooserAction.Save);
dlg.InitialFileName = "rules.html";
if (!dlg.Run ())
return;
Dictionary<BaseCodeIssueProvider, Severity> severities = new Dictionary<BaseCodeIssueProvider, Severity> ();
foreach (var node in RefactoringService.GetInspectors (lang)) {
severities [node] = node.GetSeverity ();
if (node.HasSubIssues) {
foreach (var subIssue in node.SubIssues) {
severities [subIssue] = subIssue.GetSeverity ();
}
}
}
var grouped = severities.Keys.OfType<CodeIssueProvider> ()
.GroupBy (node => node.Category)
.OrderBy (g => g.Key, StringComparer.Ordinal);
using (var sw = new StreamWriter (dlg.SelectedFile)) {
sw.WriteLine ("<h1>Code Rules</h1>");
foreach (var g in grouped) {
sw.WriteLine ("<h2>" + g.Key + "</h2>");
sw.WriteLine ("<table border='1'>");
foreach (var node in g.OrderBy (n => n.Title, StringComparer.Ordinal)) {
var title = node.Title;
var desc = node.Description != title ? node.Description : "";
sw.WriteLine ("<tr><td>" + title + "</td><td>" + desc + "</td><td>" + node.GetSeverity () + "</td></tr>");
if (node.HasSubIssues) {
foreach (var subIssue in node.SubIssues) {
title = subIssue.Title;
desc = subIssue.Description != title ? subIssue.Description : "";
sw.WriteLine ("<tr><td> - " + title + "</td><td>" + desc + "</td><td>" + subIssue.GetSeverity () + "</td></tr>");
}
}
}
sw.WriteLine ("</table>");
}
Dictionary<CodeActionProvider, bool> providerStates = new Dictionary<CodeActionProvider, bool> ();
string disabledNodes = PropertyService.Get ("ContextActions." + lang, "");
foreach (var node in RefactoringService.ContextAddinNodes.Where (n => n.MimeType == lang)) {
providerStates [node] = disabledNodes.IndexOf (node.IdString, StringComparison.Ordinal) < 0;
}
sw.WriteLine ("<h1>Code Actions</h1>");
sw.WriteLine ("<table border='1'>");
var sortedAndFiltered = providerStates.Keys.OrderBy (n => n.Title, StringComparer.Ordinal);
foreach (var node in sortedAndFiltered) {
var desc = node.Title != node.Description ? node.Description : "";
sw.WriteLine ("<tr><td>" + node.Title + "</td><td>" + desc + "</td></tr>");
}
sw.WriteLine ("</table>");
}
}
示例7: 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"));
}
}
}
示例8: 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"));
}
}
}
示例9: OnCucumberBrowseClicked
protected virtual void OnCucumberBrowseClicked(object sender, EventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog (GettextCatalog.GetString ("Choose cucumber executable"), Gtk.FileChooserAction.Open);
if (dialog.Run ())
cucumberEntry.Text = dialog.SelectedFile;
}
示例10: GetFileLocation
// return a file location prompting user where necessary. return null to cancel
string GetFileLocation(string fileName)
{
var dialog = new OpenFileDialog (GettextCatalog.GetString ("Select where to save file to"),
Gtk.FileChooserAction.Save);
dialog.InitialFileName = fileName;
if (dialog.Run ())
return dialog.SelectedFile.ToString ();
else
return null; // cancelled
}
示例11: Run
protected override void Run ()
{
var lang = "text/x-csharp";
OpenFileDialog dlg = new OpenFileDialog ("Export Rules", MonoDevelop.Components.FileChooserAction.Save);
dlg.InitialFileName = "rules.html";
if (!dlg.Run ())
return;
Dictionary<CodeDiagnosticDescriptor, DiagnosticSeverity?> severities = new Dictionary<CodeDiagnosticDescriptor, DiagnosticSeverity?> ();
foreach (var node in BuiltInCodeDiagnosticProvider.GetBuiltInCodeDiagnosticDecsriptorsAsync (CodeRefactoringService.MimeTypeToLanguage(lang), true).Result) {
severities [node] = node.DiagnosticSeverity;
// if (node.GetProvider ().SupportedDiagnostics.Length > 1) {
// foreach (var subIssue in node.GetProvider ().SupportedDiagnostics) {
// severities [subIssue] = node.GetSeverity (subIssue);
// }
// }
}
var grouped = severities.Keys.OfType<CodeDiagnosticDescriptor> ()
.GroupBy (node => node.GetProvider ().SupportedDiagnostics.First ().Category)
.OrderBy (g => g.Key, StringComparer.Ordinal);
using (var sw = new StreamWriter (dlg.SelectedFile)) {
sw.WriteLine ("<h1>Code Rules</h1>");
foreach (var g in grouped) {
sw.WriteLine ("<h2>" + g.Key + "</h2>");
sw.WriteLine ("<table border='1'>");
foreach (var node in g.OrderBy (n => n.Name, StringComparer.Ordinal)) {
var title = node.Name;
var desc = node.GetProvider ().SupportedDiagnostics.First ().Description.ToString () != title ? node.GetProvider ().SupportedDiagnostics.First ().Description : "";
sw.WriteLine ("<tr><td>" + title + "</td><td>" + desc + "</td><td>" + node.DiagnosticSeverity + "</td></tr>");
if (node.GetProvider ().SupportedDiagnostics.Length > 1) {
foreach (var subIssue in node.GetProvider ().SupportedDiagnostics) {
title = subIssue.Description.ToString ();
desc = subIssue.Description.ToString () != title ? subIssue.Description : "";
sw.WriteLine ("<tr><td> - " + title + "</td><td>" + desc + "</td><td>" + node.GetSeverity (subIssue) + "</td></tr>");
}
}
}
sw.WriteLine ("</table>");
}
var providerStates = new Dictionary<CodeRefactoringDescriptor, bool> ();
foreach (var node in BuiltInCodeDiagnosticProvider.GetBuiltInCodeRefactoringDescriptorsAsync (CodeRefactoringService.MimeTypeToLanguage(lang), true).Result) {
providerStates [node] = node.IsEnabled;
}
sw.WriteLine ("<h1>Code Actions</h1>");
sw.WriteLine ("<table border='1'>");
var sortedAndFiltered = providerStates.Keys.OrderBy (n => n.Name, StringComparer.Ordinal);
foreach (var node in sortedAndFiltered) {
sw.WriteLine ("<tr><td>" + node.IdString + "</td><td>" + node.Name + "</td></tr>");
}
sw.WriteLine ("</table>");
}
}