本文整理汇总了C#中Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog类的典型用法代码示例。如果您正苦于以下问题:C# CommonOpenFileDialog类的具体用法?C# CommonOpenFileDialog怎么用?C# CommonOpenFileDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommonOpenFileDialog类属于Microsoft.WindowsAPICodePack.Dialogs命名空间,在下文中一共展示了CommonOpenFileDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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;
}
示例3: ShowFolderBrowserDialog
public string ShowFolderBrowserDialog()
{
using (CommonOpenFileDialog dialog = new CommonOpenFileDialog { IsFolderPicker = true })
{
return dialog.ShowDialog() == CommonFileDialogResult.Ok ? dialog.FileName : null;
}
}
示例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;
}
}
示例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;
}
}
}
示例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;
}
示例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);
}
}
示例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)";
}
}
示例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;
}
}
示例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;
}
示例11: FileOpenModalDialog
internal FileOpenModalDialog(IDispatcherService dispatcher)
: base(dispatcher)
{
Dialog = new CommonOpenFileDialog { EnsureFileExists = true };
Filters = new List<FileDialogFilter>();
FilePaths = new List<string>();
}
示例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);
}
}
示例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();
}
}
示例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;
}
});
}
}
示例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;
}