本文整理汇总了C#中IFileDialog.SetClientGuid方法的典型用法代码示例。如果您正苦于以下问题:C# IFileDialog.SetClientGuid方法的具体用法?C# IFileDialog.SetClientGuid怎么用?C# IFileDialog.SetClientGuid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFileDialog
的用法示例。
在下文中一共展示了IFileDialog.SetClientGuid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 (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);
}
示例2: ApplyNativeSettings
private void ApplyNativeSettings(IFileDialog dialog)
{
Debug.Assert(dialog != null, "No dialog instance to configure");
if (parentWindow == null)
parentWindow = Helpers.GetDefaultOwnerWindow();
// Apply option bitflags.
dialog.SetOptions(CalculateNativeDialogOptionFlags());
// Other property sets.
dialog.SetTitle(title);
if (!String.IsNullOrEmpty(initialDirectory))
{
IShellItem initialDirectoryShellItem = Helpers.GetShellItemFromPath(initialDirectory);
// 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);
}
// Apply file type filters, if available.
if (filters.Count > 0)
{
dialog.SetFileTypes(
(uint)filters.Count,
filters.GetAllFilterSpecs());
SyncFileTypeComboToDefaultExtension(dialog);
}
if (usageIdentifier != Guid.Empty)
dialog.SetClientGuid(ref usageIdentifier);
}
开发者ID:dbremner,项目名称:J.-River-Media-Center-Windows-7-Shell-Integration,代码行数:38,代码来源:commonfiledialog.cs