本文整理汇总了C#中IFileDialog.Show方法的典型用法代码示例。如果您正苦于以下问题:C# IFileDialog.Show方法的具体用法?C# IFileDialog.Show怎么用?C# IFileDialog.Show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFileDialog
的用法示例。
在下文中一共展示了IFileDialog.Show方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowDialog
public CommonFileDialogResult ShowDialog()
{
CommonFileDialogResult result;
try
{
// Fetch derived native dialog (i.e. Save or Open)
InitializeNativeFileDialog();
nativeDialog = GetNativeFileDialog();
// Process custom controls, and validate overall state
ProcessControls();
ValidateCurrentDialogState();
// Apply outer properties to native dialog instance
ApplyNativeSettings(nativeDialog);
InitializeEventSink(nativeDialog);
// Show dialog
showState = NativeDialogShowState.Showing;
int hresult = nativeDialog.Show(GetHandleFromWindow(parentWindow));
showState = NativeDialogShowState.Closed;
// Create return information
if (ErrorHelper.Matches(hresult, Win32ErrorCode.ERROR_CANCELLED))
{
canceled = true;
fileNames.Clear();
}
else
{
canceled = false;
// Populate filenames - though only if user didn't cancel
PopulateWithFileNames(fileNames);
}
result = new CommonFileDialogResult(canceled.Value);
}
finally
{
CleanUpNativeFileDialog();
}
return result;
}
示例2: ShowDialog
/// <summary>
/// Displays the dialog.
/// </summary>
/// <returns>A <see cref="Microsoft.SDK.Samples.VistaBridge.Library.CommonFileDialogResult"/> object.</returns>
public CommonFileDialogResult ShowDialog()
{
CommonFileDialogResult result;
try
{
// Fetch derived native dialog (i.e. Save or Open).
InitializeNativeFileDialog();
nativeDialog = GetNativeFileDialog();
// Apply outer properties to native dialog instance.
ApplyNativeSettings(nativeDialog);
InitializeEventSink(nativeDialog);
// Clear user data if Reset has been called
// since the last show.
if (resetSelections)
{
resetSelections = false;
}
// Show dialog.
showState = NativeDialogShowState.Showing;
int hresult = nativeDialog.Show(
CommonFileDialog.GetHandleFromWindow(parentWindow));
showState = NativeDialogShowState.Closed;
// Create return information.
if (ErrorHelper.Matches(hresult,
Win32ErrorCode.ERROR_CANCELLED))
{
canceled = true;
fileNames.Clear();
}
else
{
canceled = false;
// Populate filenames if user didn't cancel.
PopulateWithFileNames(fileNames);
}
result = new CommonFileDialogResult(canceled.Value);
}
finally
{
CleanUpNativeFileDialog();
}
return result;
}
开发者ID:dbremner,项目名称:J.-River-Media-Center-Windows-7-Shell-Integration,代码行数:53,代码来源:commonfiledialog.cs
示例3: ShowDialog
/// <summary>
/// Displays the dialog.
/// </summary>
/// <returns>A <see cref="CommonFileDialogResult"/> object.</returns>
public CommonFileDialogResult ShowDialog()
{
CommonFileDialogResult result;
// Fetch derived native dialog (i.e. Save or Open).
InitializeNativeFileDialog();
nativeDialog = GetNativeFileDialog();
// Apply outer properties to native dialog instance.
ApplyNativeSettings(nativeDialog);
InitializeEventSink(nativeDialog);
// Clear user data if Reset has been called
// since the last show.
if (resetSelections)
{
resetSelections = false;
}
// Show dialog.
showState = DialogShowState.Showing;
int hresult = nativeDialog.Show(parentWindow);
showState = DialogShowState.Closed;
// Create return information.
if (CoreErrorHelper.Matches(hresult, (int)HResult.Win32ErrorCanceled))
{
canceled = true;
result = CommonFileDialogResult.Cancel;
filenames.Clear();
}
else
{
canceled = false;
result = CommonFileDialogResult.Ok;
// Populate filenames if user didn't cancel.
PopulateWithFileNames(filenames);
// Populate the actual IShellItems
PopulateWithIShellItems(items);
}
return result;
}
示例4: ShowDialog
public bool? ShowDialog()
{
bool? result = null;
try
{
// Fetch derived native dialog (i.e. Save or Open)
InitializeNativeFileDialog();
nativeDialog = GetNativeFileDialog();
// Process custom controls, and validate overall state
ProcessControls();
ValidateCurrentDialogState();
// Apply outer properties to native dialog instance
ApplyNativeSettings(nativeDialog);
// Show dialog
showState = NativeDialogShowState.Showing;
int hresult = nativeDialog.Show(GetHandleFromWindow(parentWindow));
showState = NativeDialogShowState.Closed;
// Create return information
if (ErrorHelper.Matches(hresult, Win32ErrorCode.ERROR_CANCELLED))
{
canceled = true;
fileNames.Clear();
}
else
{
canceled = false;
// Populate filenames - though only if user didn't cancel
PopulateWithFileNames(fileNames);
}
result = !canceled.Value;
}
catch
{
//If Vista Style dialog is unavailable, fall back to Windows Forms
System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();
dialog.SelectedPath = fileName;
dialog.ShowNewFolderButton = true;
dialog.Description = this.Title;
result = (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK);
if (result.HasValue && result.Value)
{
canceled = false;
fileNames.Clear();
fileNames.Add(dialog.SelectedPath);
}
else
{
fileNames.Clear();
canceled = true;
}
}
finally
{
CleanUpNativeFileDialog();
showState = NativeDialogShowState.Closed;
}
return result;
}