更新整理
This commit is contained in:
@@ -12,12 +12,12 @@ namespace WPFluent.Controls
|
||||
private Fos GetDialogOptions()
|
||||
{
|
||||
Fos options = Fos.Pickfolders;
|
||||
if(Multiselect)
|
||||
if (Multiselect)
|
||||
{
|
||||
options |= Fos.Allowmultiselect;
|
||||
}
|
||||
|
||||
if(!AllowNonStoragePlaces)
|
||||
if (!AllowNonStoragePlaces)
|
||||
{
|
||||
options |= Fos.Forcefilesystem;
|
||||
}
|
||||
@@ -31,7 +31,8 @@ namespace WPFluent.Controls
|
||||
try
|
||||
{
|
||||
item.GetDisplayName(Sigdn.Filesyspath, out path);
|
||||
} catch(ArgumentException ex) when (ex.HResult == -2147024809)
|
||||
}
|
||||
catch (ArgumentException ex) when (ex.HResult == -2147024809)
|
||||
{
|
||||
path = null;
|
||||
}
|
||||
@@ -40,7 +41,7 @@ namespace WPFluent.Controls
|
||||
private void SetDialogResults(IFileOpenDialog dialog)
|
||||
{
|
||||
IShellItem item;
|
||||
if(!Multiselect)
|
||||
if (!Multiselect)
|
||||
{
|
||||
dialog.GetResult(out item);
|
||||
string path, value;
|
||||
@@ -61,7 +62,7 @@ namespace WPFluent.Controls
|
||||
SelectedPaths = new string[count];
|
||||
SelectedElementNames = new string[count];
|
||||
|
||||
for(uint i = 0; i < count; ++i)
|
||||
for (uint i = 0; i < count; ++i)
|
||||
{
|
||||
items.GetItemAt(i, out item);
|
||||
string path, value;
|
||||
@@ -78,11 +79,11 @@ namespace WPFluent.Controls
|
||||
private void SetInitialFolder(IFileOpenDialog dialog)
|
||||
{
|
||||
IShellItem item;
|
||||
if(!string.IsNullOrEmpty(SelectedPath))
|
||||
if (!string.IsNullOrEmpty(SelectedPath))
|
||||
{
|
||||
IntPtr idl;
|
||||
uint atts = 0;
|
||||
if(NativeMethods.SHILCreateFromPath(SelectedPath, out idl, ref atts) == 0 &&
|
||||
if (NativeMethods.SHILCreateFromPath(SelectedPath, out idl, ref atts) == 0 &&
|
||||
NativeMethods.SHCreateShellItem(IntPtr.Zero, IntPtr.Zero, idl, out item) == 0)
|
||||
{
|
||||
dialog.SetFolder(item);
|
||||
@@ -101,7 +102,7 @@ namespace WPFluent.Controls
|
||||
|
||||
public bool ShowDialog(IntPtr owner)
|
||||
{
|
||||
if(Environment.OSVersion.Version.Major < 6)
|
||||
if (Environment.OSVersion.Version.Major < 6)
|
||||
{
|
||||
throw new InvalidOperationException("对话框需要至少在Visia系统以上才能使用");
|
||||
}
|
||||
@@ -112,7 +113,7 @@ namespace WPFluent.Controls
|
||||
SetInitialFolder(dialog);
|
||||
SetOptions(dialog);
|
||||
|
||||
if(dialog.Show(owner) != 0)
|
||||
if (dialog.Show(owner) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -120,7 +121,8 @@ namespace WPFluent.Controls
|
||||
SetDialogResults(dialog);
|
||||
|
||||
return true;
|
||||
} finally
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.ReleaseComObject(dialog);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user