本文整理汇总了C#中IFileDialog.SetOkButtonLabel方法的典型用法代码示例。如果您正苦于以下问题:C# IFileDialog.SetOkButtonLabel方法的具体用法?C# IFileDialog.SetOkButtonLabel怎么用?C# IFileDialog.SetOkButtonLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFileDialog
的用法示例。
在下文中一共展示了IFileDialog.SetOkButtonLabel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyNativeSettings
private void ApplyNativeSettings(IFileDialog dialog)
{
Debug.Assert(dialog != null, "No dialog instance to configure");
if (parentWindow == IntPtr.Zero)
{
if (System.Windows.Application.Current != null && System.Windows.Application.Current.MainWindow != null)
parentWindow = (new WindowInteropHelper(System.Windows.Application.Current.MainWindow)).Handle;
else if (System.Windows.Forms.Application.OpenForms.Count > 0)
parentWindow = System.Windows.Forms.Application.OpenForms[0].Handle;
}
Guid guid = new Guid(ShellIIDGuid.IShellItem2);
// Apply option bitflags.
dialog.SetOptions(CalculateNativeDialogOptionFlags());
// Other property sets.
if (title != null)
dialog.SetTitle(title);
if (okButtonLabel != null)
dialog.SetOkButtonLabel(okButtonLabel);
if (initialDirectoryShellContainer != null)
{
dialog.SetFolder(((ShellObject)initialDirectoryShellContainer).NativeShellItem);
}
if (defaultDirectoryShellContainer != null)
{
dialog.SetDefaultFolder(((ShellObject)defaultDirectoryShellContainer).NativeShellItem);
}
if (!String.IsNullOrEmpty(initialDirectory))
{
// Create a native shellitem from our path
IShellItem2 initialDirectoryShellItem;
ShellNativeMethods.SHCreateItemFromParsingName(initialDirectory, IntPtr.Zero, ref guid, out initialDirectoryShellItem);
// If we get a real shell item back,
// then use that as the initial folder - otherwise,
// we'll allow the dialog to revert to the default folder.
// (OR should we fail loudly?)
if (initialDirectoryShellItem != null)
dialog.SetFolder(initialDirectoryShellItem);
}
if (!string.IsNullOrEmpty(defaultDirectory))
{
// Create a native shellitem from our path
IShellItem2 defaultDirectoryShellItem;
ShellNativeMethods.SHCreateItemFromParsingName(defaultDirectory, IntPtr.Zero, ref guid, out defaultDirectoryShellItem);
// If we get a real shell item back,
// then use that as the initial folder - otherwise,
// we'll allow the dialog to revert to the default folder.
// (OR should we fail loudly?)
if (defaultDirectoryShellItem != null)
dialog.SetDefaultFolder(defaultDirectoryShellItem);
}
// Apply file type filters, if available.
if (filters.Count > 0 && !filterSet)
{
dialog.SetFileTypes(
(uint)filters.Count,
filters.GetAllFilterSpecs());
filterSet = true;
SyncFileTypeComboToDefaultExtension(dialog);
}
if (cookieIdentifier != Guid.Empty)
dialog.SetClientGuid(ref cookieIdentifier);
// Set the default extension
if (!string.IsNullOrEmpty(DefaultExtension))
dialog.SetDefaultExtension(DefaultExtension);
// Set the default filename
dialog.SetFileName(DefaultFileName);
}