本文整理汇总了C#中Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog类的典型用法代码示例。如果您正苦于以下问题:C# CommonOpenFileDialog类的具体用法?C# CommonOpenFileDialog怎么用?C# CommonOpenFileDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommonOpenFileDialog类属于Microsoft.WindowsAPICodePack.Dialogs命名空间,在下文中一共展示了CommonOpenFileDialog类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: AnotherReplayFolderCMDLink_Click
private static void AnotherReplayFolderCMDLink_Click( object s, EventArgs e )
{
var openFolderDialog = new CommonOpenFileDialog();
openFolderDialog.Title = "Select the wargame3 replay folders";
openFolderDialog.IsFolderPicker = true;
openFolderDialog.FileOk += ( sender, parameter ) =>
{
var dialog = (CommonOpenFileDialog)sender;
if ( !ReplayFolderPicker.ReplaysPathContainsReplay(dialog.FileName) )
{
parameter.Cancel = true;
MessageBox.Show("This folder doesn't contain any .wargamerpl2 files", "Error", MessageBoxButton.OK, MessageBoxImage.Asterisk);
}
};
CommonFileDialogResult result = openFolderDialog.ShowDialog();
if ( result == CommonFileDialogResult.Ok )
{
_newPath = openFolderDialog.FileName;
var s2 = (TaskDialogCommandLink)s;
var taskDialog = (TaskDialog)(s2.HostingDialog);
//taskDialog.Close(TaskDialogResult.CustomButtonClicked);
}
}
开发者ID:RemiGC,项目名称:RReplay,代码行数:28,代码来源:ReplayFolderPicker.cs
示例2: OnOutputPathButtonClick
private void OnOutputPathButtonClick(object sender, RoutedEventArgs e)
{
string path = string.Empty;
if (CommonFileDialog.IsPlatformSupported)
{
using (CommonOpenFileDialog dialog = new CommonOpenFileDialog())
{
dialog.IsFolderPicker = true;
dialog.Multiselect = false;
dialog.DefaultDirectory = this.OutputPathBox.Text;
if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
{
path = dialog.FileName;
}
}
}
else
{
using (FolderBrowserDialog dialog = new FolderBrowserDialog())
{
dialog.RootFolder = Environment.SpecialFolder.MyMusic;
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
path = dialog.SelectedPath;
}
}
}
extractor.OutputPath = path;
}
开发者ID:alocay,项目名称:ExtractorProject,代码行数:31,代码来源:MainWindow.xaml.cs
示例3: ShowFolderBrowserDialog
public string ShowFolderBrowserDialog()
{
using (CommonOpenFileDialog dialog = new CommonOpenFileDialog { IsFolderPicker = true })
{
return dialog.ShowDialog() == CommonFileDialogResult.Ok ? dialog.FileName : null;
}
}
开发者ID:JLignell,项目名称:MP3Downloader,代码行数:7,代码来源:DialogService.cs
示例4: ChooseDataPath
private void ChooseDataPath()
{
var dialog = new CommonOpenFileDialog
{
IsFolderPicker = true,
InitialDirectory = Settings.Default.DataPath
};
var result = dialog.ShowDialog();
if (result == CommonFileDialogResult.Ok)
{
var particleDir = Path.Combine(dialog.FileName, "art", "meshes", "Particle");
if (!Directory.Exists(particleDir))
{
MessageBox.Show("The chosen data directory does not seem to be valid.\n"
+ "Couldn't find subdirectory art\\meshes\\Particle.",
"Invalid Data Directory");
return;
}
Settings.Default.DataPath = dialog.FileName;
Settings.Default.Save();
PreviewControl.DataPath = dialog.FileName;
}
}
开发者ID:ema29,项目名称:TemplePlus,代码行数:25,代码来源:MainWindow.xaml.cs
示例5: Button_Click_1
private void Button_Click_1(object sender, RoutedEventArgs e)
{
//var dialog = new System.Windows.Forms.FolderBrowserDialog();
//System.Windows.Forms.DialogResult result = dialog.ShowDialog();
//// Configure open file dialog box
//Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
//dlg.FileName = "Document"; // Default file name
//dlg.DefaultExt = ".txt"; // Default file extension
//dlg.Filter = "Text documents (.txt)|*.txt"; // Filter files by extension
//// Show open file dialog box
//Nullable<bool> result = dlg.ShowDialog();
//// Process open file dialog box results
//if (result == true)
//{
// // Open document
// string filename = dlg.FileName;
//}
//Check to see if the user is >Vista
if (CommonFileDialog.IsPlatformSupported)
{
var dialog = new CommonOpenFileDialog();
dialog.IsFolderPicker = true;
CommonFileDialogResult result = dialog.ShowDialog();
if (result == CommonFileDialogResult.Ok)
{
dirName = dialog.FileName;
textbox.Text = dirName;
}
}
}
开发者ID:kevininspace,项目名称:PhotoContactSheetBackup,代码行数:34,代码来源:MainWindow.xaml.cs
示例6: BrowseForFolder
public static string BrowseForFolder(string startingPath)
{
string initialDirectory = _lastDirectory ?? startingPath;
string ret = null;
try
{
var cfd = new CommonOpenFileDialog
{
InitialDirectory = initialDirectory,
IsFolderPicker = true
};
if (cfd.ShowDialog() == CommonFileDialogResult.Ok)
{
ret = cfd.FileName;
}
}
catch (System.PlatformNotSupportedException)
{
var fd = new System.Windows.Forms.FolderBrowserDialog
{
SelectedPath = initialDirectory
};
if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
ret = fd.SelectedPath;
}
}
_lastDirectory = ret;
return ret;
}
开发者ID:Haacked,项目名称:SeeGit,代码行数:34,代码来源:WindowsExtensions.cs
示例7: onMenuSelected_SelectFileDownload
private void onMenuSelected_SelectFileDownload(object sender, EventArgs e)
{
var items = this.listView.SelectedItems;
IList<FileInfo> fileInfoList = new List<FileInfo>();
foreach (ListViewItem item in items) {
fileInfoList.Add((FileInfo)item.Tag);
}
CommonOpenFileDialog dialog = new CommonOpenFileDialog();
dialog.IsFolderPicker = true;
dialog.EnsureReadOnly = false;
dialog.Multiselect = false;
dialog.AllowNonFileSystemItems = false;
var result = dialog.ShowDialog();
if (result == CommonFileDialogResult.Ok) {
ProgressDialog progress = new ProgressDialog();
var context = TaskScheduler.FromCurrentSynchronizationContext();
Task task = Task.Factory.StartNew(() => {
string dest = dialog.FileName;
foreach (var fileInfo in fileInfoList) {
PullFile(dest, fileInfo);
}
});
task.ContinueWith(x => {
progress.Dispose();
RefreshFileList();
}, context);
progress.ShowDialog(this);
}
}
开发者ID:Kuchinashi,项目名称:AndroidExplorer,代码行数:29,代码来源:MainActivity.Events.Mouse.cs
示例8: browseSmfPath_Click
private void browseSmfPath_Click(object sender, EventArgs e)
{
// Get us a new FolderBrowserDialog
CommonOpenFileDialog fb = new CommonOpenFileDialog();
fb.IsFolderPicker = true;
fb.Title = "Please select the directory that your environment resides in.";
fb.EnsurePathExists = true;
CommonFileDialogResult rs = fb.ShowDialog();
if (rs == CommonFileDialogResult.Cancel)
return;
// Get the path.
string s = fb.FileName;
if (Directory.Exists(s))
{
smfPath.Text = s;
if (File.Exists(s + "/index.php"))
{
string contents = File.ReadAllText(s + "/index.php");
Match match = Regex.Match(contents, @"'SMF ([^']*)'");
if (match.Success)
dsmfver.Text = match.Groups[1].Value;
else
dsmfver.Text = "(unknown)";
}
else
dsmfver.Text = "(unknown)";
}
}
开发者ID:Yoshi2889,项目名称:ModManager,代码行数:32,代码来源:Options.cs
示例9: selectDirectory
// MainWindow newMain; // Global Declaration
//// Run directory processing on a new thread
//public async Task<string> getDirectory(MainWindow mainWindow)
//{
// newMain = mainWindow;
//}
///////////////////////////////////////////////////////
// Select Directory Button Handler
// - Gets full path including sub-directories
//
// - Uses string path = new DirButton().selectDirectory();
// - Output returns {string} path (selected in dialog)
///////////////////////////////////////////////////////
public string selectDirectory()
{
// Define new MainWindow object (for reference)
var mainWindow = ((MainWindow)System.Windows.Application.Current.MainWindow);
// Begin Windows Dialog .DLL Extension usage
var dlg = new CommonOpenFileDialog();
var currentDirectory = "";
dlg.Title = "Select Music Directory";
dlg.IsFolderPicker = true;
dlg.InitialDirectory = currentDirectory;
dlg.AddToMostRecentlyUsedList = false;
dlg.AllowNonFileSystemItems = false;
dlg.DefaultDirectory = currentDirectory;
dlg.EnsureFileExists = true;
dlg.EnsurePathExists = true;
dlg.EnsureReadOnly = false;
dlg.EnsureValidNames = true;
dlg.Multiselect = false;
dlg.ShowPlacesList = true;
if (dlg.ShowDialog() == CommonFileDialogResult.Ok)
{
string folder = dlg.FileName;
//mainWindow.FileText.Text = folder;
return folder;
}
else
{
return null;
}
}
开发者ID:no1redsfan,项目名称:WeListenPlayer,代码行数:47,代码来源:DirButton.cs
示例10: SelectDirectoryDialog
public string SelectDirectoryDialog(string defaultPath, string title = null)
{
var dlg = new CommonOpenFileDialog()
{
Title = "",
IsFolderPicker = true,
InitialDirectory = defaultPath,
AddToMostRecentlyUsedList = false,
AllowNonFileSystemItems = false,
DefaultDirectory = defaultPath,
EnsureFileExists = true,
EnsurePathExists = true,
EnsureReadOnly = false,
EnsureValidNames = true,
Multiselect = false,
ShowPlacesList = true
};
if (dlg.ShowDialog() == CommonFileDialogResult.Ok)
{
return dlg.FileName;
}
return null;
}
开发者ID:komaflash,项目名称:dump,代码行数:25,代码来源:DialogService.cs
示例11: FileOpenModalDialog
internal FileOpenModalDialog(IDispatcherService dispatcher)
: base(dispatcher)
{
Dialog = new CommonOpenFileDialog { EnsureFileExists = true };
Filters = new List<FileDialogFilter>();
FilePaths = new List<string>();
}
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:7,代码来源:FileOpenModalDialog.cs
示例12: SelectFiles
public void SelectFiles()
{
if (CommonFileDialog.IsPlatformSupported)
{
var commonOpenFileDialog = new CommonOpenFileDialog("Select the audio files that you want to link to the zune social")
{
Multiselect = true,
EnsureFileExists = true
};
commonOpenFileDialog.Filters.Add(new CommonFileDialogFilter("Audio Files", "*.mp3;*.wma;*.m4a"));
commonOpenFileDialog.Filters.Add(new CommonFileDialogFilter("MP3 Files", "*.mp3"));
commonOpenFileDialog.Filters.Add(new CommonFileDialogFilter("WMA Files", "*.wma"));
commonOpenFileDialog.Filters.Add(new CommonFileDialogFilter("Mpeg4 Files", "*.m4a"));
if (commonOpenFileDialog.ShowDialog() == CommonFileDialogResult.OK)
ReadFiles(commonOpenFileDialog.FileNames);
}
else
{
var ofd = new OpenFileDialog {
Multiselect = true,
Filter = "Audio files .mp3,.wma,.m4a |*.mp3;*.wma;*.m4a",
AutoUpgradeEnabled = true,
Title = "Select the audio files that you want to link to the zune social",
CheckFileExists = true
};
if (ofd.ShowDialog() == DialogResult.OK)
ReadFiles(ofd.FileNames);
}
}
开发者ID:leetreveil,项目名称:Zune-Social-Tagger,代码行数:32,代码来源:SelectAudioFilesViewModel.cs
示例13: btnOpen_Click
private void btnOpen_Click( object sender, RoutedEventArgs e )
{
CommonOpenFileDialog openDialog = new CommonOpenFileDialog();
openDialog.ShowPlacesList = true;
openDialog.Multiselect = false;
openDialog.IsFolderPicker = false;
openDialog.AddToMostRecentlyUsedList = true;
openDialog.Filters.Add( new CommonFileDialogFilter( "PNG images", "*.png" ) );
if ( openDialog.ShowDialog( this ) == CommonFileDialogResult.Ok ) {
soureFilePath = openDialog.FileName;
// get comment meta
using ( FileStream fileStream = new FileStream( soureFilePath, FileMode.Open, FileAccess.Read ) ) {
pngReader = new PngReader( fileStream );
// 参考自Hjg.Pngcs的SampleCustomChunk项目
// get last line: this forces loading all chunks
pngReader.ReadChunksOnly();
tblkComment.Text = pngReader.GetMetadata().GetTxtForKey( Key_SemanticInfo );
pngReader.End();
fileStream.Close();
}
image.BeginInit();
image.Source = new BitmapImage( new Uri( soureFilePath ) );
image.EndInit();
}
}
开发者ID:taurenshaman,项目名称:SemanticImage,代码行数:26,代码来源:MainView.xaml.cs
示例14: GetGameLocation
public static GameLocationInfo GetGameLocation(FFXIIIGamePart gamePart)
{
try
{
using (RegistryKey localMachine = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
using (RegistryKey registryKey = localMachine.OpenSubKey(GetSteamRegistyPath(gamePart)))
{
if (registryKey == null)
throw Exceptions.CreateException("Запись в реестре не обнаружена.");
GameLocationInfo result = new GameLocationInfo((string)registryKey.GetValue(GameLocationSteamRegistryProvider.SteamGamePathTag));
result.Validate();
return result;
}
}
catch
{
return Application.Current.Dispatcher.Invoke(() =>
{
using (CommonOpenFileDialog dlg = new CommonOpenFileDialog(String.Format("Укажите каталог Final Fantasy XIII-{0}...", (int)gamePart)))
{
dlg.IsFolderPicker = true;
if (dlg.ShowDialog() != CommonFileDialogResult.Ok)
throw new OperationCanceledException();
GameLocationInfo result = new GameLocationInfo(dlg.FileName);
result.Validate();
return result;
}
});
}
}
开发者ID:kidaa,项目名称:Pulse,代码行数:34,代码来源:PatcherService.cs
示例15: Run
public bool Run (AddFileDialogData data)
{
var parent = data.TransientFor ?? MessageService.RootWindow;
var dialog = new CommonOpenFileDialog ();
SelectFileDialogHandler.SetCommonFormProperties (data, dialog);
var buildActionCombo = new CommonFileDialogComboBox ();
var group = new CommonFileDialogGroupBox ("overridebuildaction", "Override build action:");
buildActionCombo.Items.Add (new CommonFileDialogComboBoxItem (GettextCatalog.GetString ("Default")));
foreach (var ba in data.BuildActions) {
if (ba == "--")
continue;
buildActionCombo.Items.Add (new CommonFileDialogComboBoxItem (ba));
}
buildActionCombo.SelectedIndex = 0;
group.Items.Add (buildActionCombo);
dialog.Controls.Add (group);
if (!GdkWin32.RunModalWin32Dialog (dialog, parent))
return false;
SelectFileDialogHandler.GetCommonFormProperties (data, dialog);
var idx = buildActionCombo.SelectedIndex;
if (idx > 0)
data.OverrideAction = buildActionCombo.Items [idx].Text;
return true;
}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:30,代码来源:AddFileDialogHandler.cs
示例16: SelectRepoButtonClick
private async void SelectRepoButtonClick(object sender, RoutedEventArgs e)
{
using (var dialog = new CommonOpenFileDialog())
{
dialog.IsFolderPicker = true;
if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
{
commandFactory = new CommandFactory(resultCommandMapper, dialog.FileName);
var statusCommand = commandFactory.GetCommand<StatusResult>();
statusCommand.Execute();
if (statusCommand.Result.ExecutionResult == ExecutionResult.NoRepository)
{
commandFactory = null;
MessageBox.Show("The selected file contains no git repository.", "Error!", MessageBoxButton.OK);
}
else
{
currentBranch.Text = "Current branch: " + statusCommand.Result.CurrentBranch;
}
await ListNormalCommits();
}
}
}
开发者ID:Thulur,项目名称:GitStatisticsAnalyzer,代码行数:26,代码来源:MainWindow.xaml.cs
示例17: FileOpenModalDialog
internal FileOpenModalDialog(Dispatcher dispatcher, Window parentWindow)
: base(dispatcher, parentWindow)
{
Dialog = new CommonOpenFileDialog { EnsureFileExists = true };
Filters = new List<FileDialogFilter>();
FilePaths = new List<string>();
}
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:7,代码来源:FileOpenModalDialog.cs
示例18: CmdSelectOutputFile_Click
// Browse to select output file.
private void CmdSelectOutputFile_Click(object sender, RoutedEventArgs e)
{
var dlg = new CommonOpenFileDialog();
dlg.Title = "Choose Entity Download File";
dlg.IsFolderPicker = false;
//dlg.InitialDirectory = currentDirectory;
dlg.AddToMostRecentlyUsedList = false;
dlg.AllowNonFileSystemItems = false;
//dlg.DefaultDirectory = currentDirectory;
dlg.EnsureFileExists = false;
dlg.EnsurePathExists = true;
dlg.EnsureReadOnly = false;
dlg.EnsureValidNames = true;
dlg.Multiselect = false;
dlg.ShowPlacesList = true;
dlg.Filters.Add(new CommonFileDialogFilter("CSV File (*.csv)", ".csv"));
dlg.Filters.Add(new CommonFileDialogFilter("JSON File (*.json)", ".json"));
dlg.Filters.Add(new CommonFileDialogFilter("XML File (*.xml)", ".xml"));
if (dlg.ShowDialog() == CommonFileDialogResult.Ok)
{
OutputFile.Focus();
OutputFile.Text = dlg.FileName;
}
}
开发者ID:jhasselkus,项目名称:AzureStorageExplorer,代码行数:29,代码来源:DownloadEntitiesDialog.xaml.cs
示例19: OpenFileDialogCustomizationClicked
private void OpenFileDialogCustomizationClicked(object sender, RoutedEventArgs e)
{
CommonOpenFileDialog openFileDialog = new CommonOpenFileDialog();
currentFileDialog = openFileDialog;
ApplyOpenDialogSettings(openFileDialog);
// set the 'allow multi-select' flag
openFileDialog.Multiselect = true;
openFileDialog.EnsureFileExists = true;
AddOpenFileDialogCustomControls(openFileDialog);
CommonFileDialogResult result = openFileDialog.ShowDialog();
if (result == CommonFileDialogResult.Ok)
{
string output = "";
foreach (string fileName in openFileDialog.FileNames)
{
output += fileName + Environment.NewLine;
}
output += Environment.NewLine + GetCustomControlValues();
MessageBox.Show(output, "Files Chosen", MessageBoxButton.OK, MessageBoxImage.Information );
}
}
开发者ID:Corillian,项目名称:Windows-API-Code-Pack-1.1,代码行数:28,代码来源:window1.xaml.cs
示例20: btnChooseKeyring_Click
private void btnChooseKeyring_Click(object sender, RoutedEventArgs e)
{
using (var dlg = new CommonOpenFileDialog())
{
dlg.Title = "Choose Keyring Folder";
dlg.IsFolderPicker = true;
dlg.AddToMostRecentlyUsedList = false;
dlg.AllowNonFileSystemItems = false;
dlg.EnsureFileExists = true;
dlg.EnsurePathExists = true;
dlg.EnsureReadOnly = false;
dlg.EnsureValidNames = true;
dlg.Multiselect = false;
dlg.ShowPlacesList = true;
var oldPath = keyringPath.Text;
if (File.Exists(oldPath))
{
dlg.InitialDirectory = System.IO.Path.GetDirectoryName(oldPath);
}
if (dlg.ShowDialog(this) == CommonFileDialogResult.Ok)
{
keyringPath.Text = dlg.FileName;
}
}
}
开发者ID:sdmon,项目名称:PgpSharp,代码行数:26,代码来源:MainWindow.xaml.cs
注:本文中的Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论