本文整理汇总了C#中SelectFileDialog类的典型用法代码示例。如果您正苦于以下问题:C# SelectFileDialog类的具体用法?C# SelectFileDialog怎么用?C# SelectFileDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SelectFileDialog类属于命名空间,在下文中一共展示了SelectFileDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowBrowseDialog
protected override string ShowBrowseDialog (string name, string startIn)
{
var fd = new SelectFileDialog (name, Action);
if (startIn != null)
fd.CurrentFolder = startIn;
fd.SetFilters (FileFilters);
fd.TransientFor = GetTransientFor ();
if (fd.Run ())
return fd.SelectedFile;
return null;
}
示例2: ShowBrowseDialog
protected override string ShowBrowseDialog (string name, string start_in)
{
SelectFileDialog fd = new SelectFileDialog (name);
if (start_in != null)
fd.InitialFileName = start_in;
fd.TransientFor = GetTransientFor ();
if (fd.Run ())
return fd.SelectedFile;
else
return null;
}
示例3: LaunchDialogue
public override void LaunchDialogue ()
{
var kindAtt = this.Property.Attributes.OfType<FilePathIsFolderAttribute> ().FirstOrDefault ();
SelectFileDialogAction action;
string title;
if (kindAtt == null) {
action = SelectFileDialogAction.Open;
title = GettextCatalog.GetString ("Select File...");
} else {
action = SelectFileDialogAction.SelectFolder;
title = GettextCatalog.GetString ("Select Folder...");
}
var fs = new SelectFileDialog (title, action);
if (fs.Run ())
Property.SetValue (Instance, fs.SelectedFile);
}
示例4: 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);
}
示例5: 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;
}
示例6: OnAddAssembly
protected void OnAddAssembly ()
{
var config = (NUnitAssemblyGroupProjectConfiguration) CurrentNode.DataItem;
var dlg = new SelectFileDialog (GettextCatalog.GetString ("Add files")) {
TransientFor = IdeApp.Workbench.RootWindow,
SelectMultiple = true,
};
if (!dlg.Run ())
return;
foreach (string file in dlg.SelectedFiles)
config.Assemblies.Add (new TestAssembly (file));
IdeApp.Workspace.Save();
}
示例7: 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"));
dlg.AddFilter (new SelectFileDialogFilter (
GettextCatalog.GetString ("XML Files"),
new string[] { "*.xsd" },
new string[] { "text/xml", "application/xml" }
));
dlg.AddAllFilesFilter ();
if (dlg.Run ())
return dlg.SelectedFile;
return null;
}
示例8: AddWorkspaceItem
public WorkspaceItem AddWorkspaceItem (Workspace parentWorkspace)
{
WorkspaceItem res = null;
var dlg = new SelectFileDialog () {
Action = Gtk.FileChooserAction.Open,
CurrentFolder = parentWorkspace.BaseDirectory,
SelectMultiple = false,
};
dlg.AddAllFilesFilter ();
dlg.DefaultFilter = dlg.AddFilter (GettextCatalog.GetString ("Solution Files"), "*.mds", "*.sln");
if (dlg.Run ()) {
try {
res = AddWorkspaceItem (parentWorkspace, dlg.SelectedFile);
} catch (Exception ex) {
MessageService.ShowException (ex, GettextCatalog.GetString ("The file '{0}' could not be loaded.", dlg.SelectedFile));
}
}
return res;
}
示例9: 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;
}
示例10: TryGet
public static Credentials TryGet (string url, string userFromUrl, SupportedCredentialTypes types, GitCredentialsType type)
{
bool result = true;
Uri uri = null;
GitCredentialsState state;
if (!credState.TryGetValue (type, out state))
credState [type] = state = new GitCredentialsState ();
state.UrlUsed = url;
// We always need to run the TryGet* methods as we need the passphraseItem/passwordItem populated even
// if the password store contains an invalid password/no password
if ((types & SupportedCredentialTypes.UsernamePassword) != 0) {
uri = new Uri (url);
string username;
string password;
if (!state.NativePasswordUsed && TryGetUsernamePassword (uri, out username, out password)) {
state.NativePasswordUsed = true;
return new UsernamePasswordCredentials {
Username = username,
Password = password
};
}
}
Credentials cred;
if ((types & SupportedCredentialTypes.UsernamePassword) != 0)
cred = new UsernamePasswordCredentials ();
else {
// Try ssh-agent on Linux.
if (!Platform.IsWindows && !state.AgentUsed) {
bool agentUsable;
if (!state.AgentForUrl.TryGetValue (url, out agentUsable))
state.AgentForUrl [url] = agentUsable = true;
if (agentUsable) {
state.AgentUsed = true;
return new SshAgentCredentials {
Username = userFromUrl,
};
}
}
int key;
if (!state.KeyForUrl.TryGetValue (url, out key)) {
if (state.KeyUsed + 1 < Keys.Count)
state.KeyUsed++;
else {
SelectFileDialog dlg = null;
bool success = false;
DispatchService.GuiSyncDispatch (() => {
dlg = new SelectFileDialog (GettextCatalog.GetString ("Select a private SSH key to use."));
dlg.ShowHidden = true;
dlg.CurrentFolder = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
success = dlg.Run ();
});
if (!success || !File.Exists (dlg.SelectedFile + ".pub"))
throw new VersionControlException (GettextCatalog.GetString ("Invalid credentials were supplied. Aborting operation."));
cred = new SshUserKeyCredentials {
Username = userFromUrl,
Passphrase = "",
PrivateKey = dlg.SelectedFile,
PublicKey = dlg.SelectedFile + ".pub",
};
if (KeyHasPassphrase (dlg.SelectedFile)) {
DispatchService.GuiSyncDispatch (delegate {
using (var credDlg = new CredentialsDialog (url, types, cred))
result = MessageService.ShowCustomDialog (credDlg) == (int)Gtk.ResponseType.Ok;
});
}
if (result)
return cred;
throw new VersionControlException (GettextCatalog.GetString ("Invalid credentials were supplied. Aborting operation."));
}
} else
state.KeyUsed = key;
cred = new SshUserKeyCredentials {
Username = userFromUrl,
Passphrase = "",
PrivateKey = Keys [state.KeyUsed],
PublicKey = Keys [state.KeyUsed] + ".pub",
};
return cred;
}
DispatchService.GuiSyncDispatch (delegate {
using (var credDlg = new CredentialsDialog (url, types, cred))
result = MessageService.ShowCustomDialog (credDlg) == (int)Gtk.ResponseType.Ok;
});
if (result) {
if ((types & SupportedCredentialTypes.UsernamePassword) != 0) {
var upcred = (UsernamePasswordCredentials)cred;
if (!string.IsNullOrEmpty (upcred.Password)) {
PasswordService.AddWebUserNameAndPassword (uri, upcred.Username, upcred.Password);
//.........这里部分代码省略.........
示例11: 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);
}
示例12: 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);
}
}
示例13: OnButtonBrowseClicked
protected virtual void OnButtonBrowseClicked(object sender, System.EventArgs e)
{
var dlg = new SelectFileDialog (GettextCatalog.GetString ("Select File")) {
CurrentFolder = entry.BaseDirectory,
SelectMultiple = false,
TransientFor = this.Toplevel as Gtk.Window,
};
if (!dlg.Run ())
return;
if (System.IO.Path.IsPathRooted (dlg.SelectedFile))
entryCommand.Text = FileService.AbsoluteToRelativePath (entry.BaseDirectory, dlg.SelectedFile);
else
entryCommand.Text = dlg.SelectedFile;
}
示例14: 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);
}
示例15: 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;
}