8 changed files
BExplorer/BetterExplorer | ||
MainWindow.xaml.cs | ||
Shell | ||
_Plugin Interfaces | ||
FileSystemListItem.cs | ||
IListItemEx.cs | ||
Extensions.cs | ||
ImageListEx.cs | ||
ShellItem.cs | ||
ShellTreeViewEx.cs | ||
ShellViewEx.cs | ||
MainWindow.xaml.cs
/BExplorer/BetterExplorer/MainWindow.xaml.cs+1/BExplorer/BetterExplorer/MainWindow.xaml.cs
Add comment 3410 #region On Navigated
Add comment 3411
Add comment 3412 void ShellListView_Navigated(object sender, NavigatedEventArgs e) {
Add comment 3413 Plus //return;
Add comment 3413 3414 this._ProgressTimer.Stop();
Add comment 3414 3415 this.btnCancelNavigation.Visibility = Visibility.Collapsed;
Add comment 3415 3416 this.btnGoNavigation.Visibility = Visibility.Visible;
FileSystemListItem.cs
/Shell/_Plugin Interfaces/FileSystemListItem.cs-97+391/Shell/_Plugin Interfaces/FileSystemListItem.cs
Displayed content is truncated due to maximum viewable content limit.
Add comment 1 Plus using System.Runtime.CompilerServices;
Add comment 2 Plus using System.IO;
Add comment 1 3 using BExplorer.Shell.Interop;
Add comment 2 4 using System;
Add comment 3 5 using System.Collections.Generic;
Add comment 7 9 using System.Windows.Media.Imaging;
Add comment 8 10 using ThumbnailGenerator;
Add comment 9 11 using Size = System.Drawing.Size;
Add comment 12 Plus using System.Text;
Add comment 13 Plus using System.Linq;
Add comment 14 Plus using System.Windows.Interop;
Add comment 10 15
Add comment 11 16 namespace BExplorer.Shell._Plugin_Interfaces {
Add comment 12 17
Add comment 24 29
Add comment 25 30 #region IListItemEx Members
Add comment 26 31
Add comment 32 Plus public IntPtr ParentPIDL { get; set; }
Add comment 33 Plus public IntPtr EnumPIDL { get; set; }
Add comment 27 34 /// <summary>The COM interface for this item</summary>
Add comment 28 Minus public IShellItem ComInterface => this._Item.ComInterface;
Add comment 35 Plus public IShellItem ComInterface => this.ParentPIDL == IntPtr.Zero ? Shell32.SHCreateItemFromIDList(this.EnumPIDL, typeof(IShellItem).GUID) : Shell32.SHCreateItemWithParent(this.ParentPIDL, null, this.EnumPIDL, typeof(IShellItem).GUID);
Add comment 29 36
Add comment 30 37 /// <summary>The text that represents the display name</summary>
Add comment 31 Minus public string DisplayName { get; set; }
Add comment 38 Plus public string DisplayName {
Add comment 39 Plus get {
Add comment 40 Plus return this.GetDisplayName(SIGDN.NORMALDISPLAY);
Add comment 41 Plus }
Add comment 42 Plus }
Add comment 32 43
Add comment 33 44 /// <summary>Does the current item need to be refreshed in the ShellListView</summary>
Add comment 34 45 public bool IsNeedRefreshing { get; set; }
Add comment 48 59 private IExtractIconPWFlags _IconType = IExtractIconPWFlags.GIL_PERCLASS;
Add comment 49 60
Add comment 50 61 public IExtractIconPWFlags IconType {
Add comment 51 Minus get { return this.IsParentSearchFolder ? IExtractIconPWFlags.GIL_PERINSTANCE : this._Item.GetIconType(); }
Add comment 62 Plus get { return this.IsParentSearchFolder ? IExtractIconPWFlags.GIL_PERINSTANCE : this.GetIconType(); }
Add comment 52 63 set { this._IconType = value; }
Add comment 53 64 }
Add comment 54 65
Add comment 55 Minus public IntPtr ILPidl => this._Item.ILPidl;
Add comment 66 Plus public IExtractIconPWFlags GetIconType() {
Add comment 67 Plus if (this.Extension == ".exe" || this.Extension == ".com" || this.Extension == ".bat" || this.Extension == ".msi")
Add comment 68 Plus return IExtractIconPWFlags.GIL_PERINSTANCE;
Add comment 56 69
Add comment 57 Minus public IntPtr PIDL { get; set; }
Add comment 70 Plus if (this.Parent == null)
Add comment 71 Plus return 0;
Add comment 58 72
Add comment 59 Minus public IntPtr AbsolutePidl => this._Item.AbsolutePidl;
Add comment 73 Plus if (this.IsFolder) {
Add comment 74 Plus IExtractIcon iextract = null;
Add comment 75 Plus IShellFolder ishellfolder = null;
Add comment 76 Plus StringBuilder str = null;
Add comment 77 Plus IntPtr result;
Add comment 60 78
Add comment 79 Plus try {
Add comment 80 Plus var guid = new Guid("000214fa-0000-0000-c000-000000000046");
Add comment 81 Plus uint res = 0;
Add comment 82 Plus ishellfolder = this.Parent.GetIShellFolder();
Add comment 83 Plus var pidls = new IntPtr[1] { Shell32.ILFindLastID(this.PIDL) };
Add comment 84 Plus //pidls[0] = Shell32.ILFindLastID(this.Pidl);
Add comment 85 Plus ishellfolder.GetUIObjectOf(
Add comment 86 Plus IntPtr.Zero,
Add comment 87 Plus 1,
Add comment 88 Plus pidls,
Add comment 89 Plus ref guid,
Add comment 90 Plus res,
Add comment 91 Plus out result
Add comment 92 Plus );
Add comment 93 Plus
Add comment 94 Plus if (result == IntPtr.Zero) {
Add comment 95 Plus pidls = null;
Add comment 96 Plus //Marshal.ReleaseComObject(ishellfolder);
Add comment 97 Plus return IExtractIconPWFlags.GIL_PERCLASS;
Add comment 98 Plus }
Add comment 99 Plus iextract = (IExtractIcon)Marshal.GetTypedObjectForIUnknown(result, typeof(IExtractIcon));
Add comment 100 Plus str = new StringBuilder(512);
Add comment 101 Plus int index = -1;
Add comment 102 Plus IExtractIconPWFlags flags;
Add comment 103 Plus iextract.GetIconLocation(IExtractIconUFlags.GIL_ASYNC, str, 512, out index, out flags);
Add comment 104 Plus pidls = null;
Add comment 105 Plus //Marshal.ReleaseComObject(ishellfolder);
Add comment 106 Plus //Marshal.ReleaseComObject(iextract);
Add comment 107 Plus ishellfolder = null;
Add comment 108 Plus iextract = null;
Add comment 109 Plus str = null;
Add comment 110 Plus return flags;
Add comment 111 Plus } catch (Exception) {
Add comment 112 Plus //if (ishellfolder != null)
Add comment 113 Plus //Marshal.ReleaseComObject(ishellfolder);
Add comment 114 Plus //if (iextract != null)
Add comment 115 Plus // Marshal.ReleaseComObject(iextract);
Add comment 116 Plus return 0;
Add comment 117 Plus }
Add comment 118 Plus } else {
Add comment 119 Plus return IExtractIconPWFlags.GIL_PERCLASS;
Add comment 120 Plus }
Add comment 121 Plus }
Add comment 122 Plus
Add comment 123 Plus public IntPtr ILPidl => Shell32.ILFindLastID(this.PIDL);
Add comment 124 Plus
Add comment 125 Plus public IntPtr PIDL {
Add comment 126 Plus get {
Add comment 127 Plus var comObject = this.ComInterface;
Add comment 128 Plus var result = comObject == null ? IntPtr.Zero : Shell32.SHGetIDListFromObject(comObject);
Add comment 129 Plus Marshal.FinalReleaseComObject(comObject);
Add comment 130 Plus return result;
Add comment 131 Plus }
Add comment 132 Plus }
Add comment 133 Plus
Add comment 134 Plus public IntPtr AbsolutePidl {
Add comment 135 Plus get {
Add comment 136 Plus uint attr;
Add comment 137 Plus IntPtr pidl;
Add comment 138 Plus Shell32.SHParseDisplayName(this.ParsingName, IntPtr.Zero, out pidl, 0, out attr);
Add comment 139 Plus return pidl;
Add comment 140 Plus }
Add comment 141 Plus }
Add comment 142 Plus
Add comment 61 143 /// <summary>Index of the ShieldedIcon</summary>
Add comment 62 144 public int ShieldedIconIndex { get; set; }
Add comment 63 145
Add comment 64 146 /// <summary>Is this item's icon loaded yet?</summary>
Add comment 65 147 public bool IsIconLoaded { get; set; }
Add comment 66 148
Add comment 67 Minus public string ParsingName { get; set; }
Add comment 149 Plus public string ParsingName {
Add comment 150 Plus get {
Add comment 151 Plus return this.GetDisplayName(SIGDN.DESKTOPABSOLUTEPARSING);
Add comment 152 Plus }
Add comment 153 Plus }
Add comment 68 154
Add comment 69 155 /// <summary>The file system extension for this item</summary>
Add comment 70 Minus public string Extension { get; set; }
Add comment 156 Plus public string Extension {
Add comment 157 Plus get {
Add comment 158 Plus return Path.GetExtension(this.ParsingName);
Add comment 159 Plus }
Add comment 160 Plus }
Add comment 71 161
Add comment 72 162 /// <summary>The file system path</summary>
Add comment 73 Minus public string FileSystemPath { get; set; }
Add comment 163 Plus public string FileSystemPath {
Add comment 164 Plus get {
Add comment 165 Plus return this.GetDisplayName(SIGDN.FILESYSPATH);
Add comment 166 Plus }
Add comment 167 Plus }
Add comment 74 168
Add comment 75 169 /// <summary>
Add comment 76 170 /// Returns true if folder can be browsed
Add comment 77 171 /// </summary>
Add comment 78 Minus public bool IsBrowsable => this._Item.IsBrowsable;
Add comment 172 Plus public bool IsBrowsable => this.COM_Attribute_Check(SFGAO.BROWSABLE);
Add comment 173 Plus
Add comment 174 Plus [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
Add comment 175 Plus private bool COM_Attribute_Check(SFGAO Check) {
Add comment 176 Plus var comObject = this.ComInterface;
Add comment 177 Plus SFGAO sfgao;
Add comment 178 Plus comObject.GetAttributes(Check, out sfgao);
Add comment 179 Plus Marshal.FinalReleaseComObject(comObject);
Add comment 180 Plus return (sfgao & Check) != 0;
Add comment 181 Plus }
Add comment 79 182
Add comment 80 183 /// <summary>Gets or sets a value indicating whether this is a folder </summary>
Add comment 81 Minus public bool IsFolder { get; set; }
Add comment 184 Plus public bool IsFolder {
Add comment 185 Plus get {
Add comment 186 Plus var comObject = this.ComInterface;
Add comment 187 Plus SFGAO sfgao;
Add comment 188 Plus comObject.GetAttributes(SFGAO.FOLDER, out sfgao);
Add comment 189 Plus SFGAO sfgao2;
Add comment 190 Plus comObject.GetAttributes(SFGAO.STREAM, out sfgao2);
Add comment 191 Plus Marshal.FinalReleaseComObject(comObject);
Add comment 192 Plus return sfgao != 0 && sfgao2 == 0;
Add comment 193 Plus }
Add comment 194 Plus }
Add comment 82 195
Add comment 83 196 /// <summary>Does this have folders?</summary>
Add comment 84 Minus public bool HasSubFolders => this._Item.HasSubFolders;
Add comment 197 Plus public bool HasSubFolders => this.COM_Attribute_Check(SFGAO.HASSUBFOLDER);
Add comment 85 198
Add comment 86 199 /// <summary>Is this item normally hidden?</summary>
Add comment 87 Minus public bool IsHidden { get; set; }
Add comment 200 Plus public bool IsHidden => this.COM_Attribute_Check(SFGAO.HIDDEN);
Add comment 88 201
Add comment 89 Minus public bool IsFileSystem { get; set; }
Add comment 202 Plus public bool IsFileSystem => this.COM_Attribute_Check(SFGAO.FILESYSTEM);
Add comment 90 203
Add comment 91 Minus public bool IsNetworkPath { get; set; }
Add comment 204 Plus public bool IsNetworkPath => Shell32.PathIsNetworkPath(this.ParsingName);
Add comment 92 205
Add comment 93 206 /// <summary>Is current item represent a system drive?</summary>
Add comment 94 Minus public bool IsDrive { get; set; }
Add comment 207 Plus public bool IsDrive {
Add comment 208 Plus get {
Add comment 209 Plus try {
Add comment 210 Plus return Directory.GetLogicalDrives().Contains(this.ParsingName) && Kernel32.GetDriveType(this.ParsingName) != DriveType.Network;
Add comment 211 Plus } catch {
Add comment 212 Plus return false;
Add comment 213 Plus }
Add comment 214 Plus }
Add comment 215 Plus }
Add comment 95 216
Add comment 96 Minus public bool IsShared { get; set; }
Add comment 217 Plus public bool IsShared => this.COM_Attribute_Check(SFGAO.SHARE);
Add comment 97 218
Add comment 98 219 /// <summary>Is the parent a search folder?</summary>
Add comment 99 220 public bool IsParentSearchFolder { get; set; }
Add comment 104 225
Add comment 105 226 public IShellFolder IFolder { get; set; }
Add comment 106 227
Add comment 107 Minus private void Initialize_Helper(ShellItem folder, IntPtr lvHandle, int index) {
Add comment 108 Minus this.DisplayName = folder.DisplayName;
Add comment 109 Minus this.ParsingName = folder.ParsingName;
Add comment 110 Minus this.ItemIndex = index;
Add comment 111 Minus this.PIDL = folder.Pidl;
Add comment 112 Minus //this.IFolder = folder.GetIShellFolder();
Add comment 228 Plus private void Initialize_Helper(IntPtr folder, IntPtr lvHandle, int index) {
Add comment 229 Plus this.ParentPIDL = IntPtr.Zero;
Add comment 230 Plus this.EnumPIDL = folder;
Add comment 231 Plus //this.ComInterface = Shell32.SHCreateItemFromIDList(this.EnumPIDL, typeof(IShellItem).GUID);
Add comment 113 232 this.ParentHandle = lvHandle;
Add comment 114 Minus this.IsFileSystem = folder.IsFileSystem;
Add comment 115 Minus this.IsNetworkPath = folder.IsNetworkPath;
Add comment 116 Minus this.Extension = folder.Extension;
Add comment 117 Minus this.IsDrive = folder.IsDrive;
Add comment 118 Minus this.IsHidden = folder.IsHidden;
Add comment 233 Plus
Add comment 119 234 this.OverlayIconIndex = -1;
Add comment 120 235 this.ShieldedIconIndex = -1;
Add comment 121 Minus this.IsShared = folder.IsShared;
Add comment 122 Minus //this.IconType = folder.IconType;
Add comment 123 Minus this.IsFolder = folder.IsFolder;
Add comment 124 Minus this.IsSearchFolder = folder.IsSearchFolder;
Add comment 125 Minus this._Item = folder;
Add comment 236 Plus
Add comment 126 237 //this._IconType = folder.GetIconType();
Add comment 127 238 }
Add comment 128 239
Add comment 129 Minus private void Initialize_Helper2(ShellItem parent, IntPtr pidl, IntPtr lvHandle, int index) {
Add comment 130 Minus var folder = new ShellItem(parent, pidl);
Add comment 131 Minus this.DisplayName = folder.DisplayName;
Add comment 132 Minus this.ParsingName = folder.ParsingName;
Add comment 133 Minus this.ItemIndex = index;
Add comment 134 Minus this.PIDL = folder.Pidl;
Add comment 240 Plus private void Initialize_Helper2(IntPtr parent, IntPtr pidl, IntPtr lvHandle, int index) {
Add comment 241 Plus this.ParentPIDL = parent;
Add comment 242 Plus this.EnumPIDL = pidl;
Add comment 243 Plus //this.ComInterface = Shell32.SHCreateItemWithParent(this.ParentPIDL, null, this.EnumPIDL, typeof(IShellItem).GUID);
Add comment 135 244 this.ParentHandle = lvHandle;
Add comment 136 Minus this.IsFileSystem = folder.IsFileSystem;
Add comment 137 Minus this.IsNetworkPath = folder.IsNetworkPath;
Add comment 138 Minus this.Extension = folder.Extension;
Add comment 139 Minus this.IsDrive = folder.IsDrive;
Add comment 140 Minus this.IsHidden = folder.IsHidden;
Add comment 245 Plus
Add comment 141 246 this.OverlayIconIndex = -1;
Add comment 142 247 this.ShieldedIconIndex = -1;
Add comment 143 Minus this.IsShared = folder.IsShared;
Add comment 144 Minus //this.IconType = folder.IconType;
Add comment 145 Minus this.IsFolder = folder.IsFolder;
Add comment 146 Minus this.IsSearchFolder = folder.IsSearchFolder;
Add comment 147 Minus this._Item = folder;
Add comment 148 Minus //this._IconType = folder.GetIconType();
Add comment 149 248 }
Add comment 150 249
Add comment 151 250 public void Initialize(IntPtr lvHandle, IntPtr pidl, int index) {
Add comment 152 Minus Initialize_Helper(new ShellItem(pidl), lvHandle, index);
Add comment 251 Plus Initialize_Helper(pidl, lvHandle, index);
Add comment 153 252 }
Add comment 154 253
Add comment 155 Minus public void InitializeWithParent(ShellItem parent, IntPtr lvHandle, IntPtr pidl, int index) {
Add comment 254 Plus public void InitializeWithParent(IntPtr parent, IntPtr lvHandle, IntPtr pidl, int index) {
Add comment 156 255 Initialize_Helper2(parent, pidl, lvHandle, index);
Add comment 157 256 }
Add comment 158 257
Add comment 159 258 public void InitializeWithShellItem(ShellSearchFolder item, IntPtr lvHandle, int index) {
Add comment 160 Minus Initialize_Helper(item, lvHandle, index);
Add comment 259 Plus Initialize_Helper(item.Pidl, lvHandle, index);
Add comment 161 260 this.searchFolder = item;
Add comment 162 261 }
Add comment 163 262
Add comment 176 275 }
Add comment 177 276
Add comment 178 277 public void Initialize(IntPtr lvHandle, string path, int index) {
Add comment 179 Minus var item = new ShellItem(path);
Add comment 180 Minus this.DisplayName = item.DisplayName;
Add comment 181 Minus this.ParsingName = item.ParsingName;
Add comment 182 Minus this.ItemIndex = index;
Add comment 278 Plus this.ParentPIDL = IntPtr.Zero;
Add comment 279 Plus this.EnumPIDL = Shell32.SHGetIDListFromObject(Shell32.SHCreateItemFromParsingName(path, IntPtr.Zero, typeof(IShellItem).GUID));
Add comment 280 Plus
Add comment 183 281 this.ParentHandle = lvHandle;
Add comment 184 Minus this.IsFileSystem = item.IsFileSystem;
Add comment 185 Minus this.IsNetworkPath = item.IsNetworkPath;
Add comment 186 Minus this.Extension = item.Extension;
Add comment 187 Minus this.IsDrive = item.IsDrive;
Add comment 188 Minus this.IsHidden = item.IsHidden;
Add comment 282 Plus
Add comment 189 283 this.OverlayIconIndex = -1;
Add comment 190 284 this.ShieldedIconIndex = -1;
Add comment 191 Minus this.PIDL = item.Pidl;
Add comment 192 Minus //this.IFolder = item.GetIShellFolder();
Add comment 193 Minus //this.HasSubFolders = item.HasSubFolders;
Add comment 194 Minus this.IsShared = item.IsShared;
Add comment 195 Minus //this.IconType = item.IconType;
Add comment 196 Minus this.IsFolder = item.IsFolder;
Add comment 197 Minus this.IsSearchFolder = item.IsSearchFolder;
Add comment 198 Minus this._Item = item;
Add comment 199 Minus this._IconType = item.GetIconType();
Add comment 200 285 //item.Dispose();
Add comment 201 286 } //TODO: Find out why this does nothing with the ShellViewItem that it creates
Add comment 202 287
Add comment 250 335
Add comment 251 336 while (enumId.Next(1, out pidl, out count) == HResult.S_OK) {
Add comment 252 337 var fsi = new FileSystemListItem();
Add comment 253 Minus fsi.InitializeWithParent(parentItem, this.ParentHandle, pidl, i++);
Add comment 338 Plus fsi.InitializeWithParent(this.PIDL, this.ParentHandle, pidl, i++);
Add comment 254 339 fsiList.Add(fsi);
Add comment 255 340 Shell32.ILFree(pidl);
Add comment 256 341 //if (this.IsSearchFolder)
Add comment 276 361
Add comment 277 362 public Size IconSize { get; set; }
Add comment 278 363
Add comment 364 Plus public IEnumerable<IntPtr> GetItemsForCount(Boolean isEnumHidden) {
Add comment 365 Plus IShellFolder folder = this.GetIShellFolder();
Add comment 366 Plus if (folder == null)
Add comment 367 Plus yield return IntPtr.Zero;
Add comment 368 Plus HResult navRes;
Add comment 369 Plus SHCONTF flags = SHCONTF.FOLDERS | SHCONTF.FASTITEMS |
Add comment 370 Plus SHCONTF.NONFOLDERS | SHCONTF.ENABLE_ASYNC | SHCONTF.INIT_ON_FIRST_NEXT;
Add comment 371 Plus if (isEnumHidden) {
Add comment 372 Plus flags = SHCONTF.FOLDERS | SHCONTF.INCLUDEHIDDEN | SHCONTF.INCLUDESUPERHIDDEN | SHCONTF.FASTITEMS |
Add comment 373 Plus SHCONTF.NONFOLDERS | SHCONTF.ENABLE_ASYNC | SHCONTF.INIT_ON_FIRST_NEXT;
Add comment 374 Plus }
Add comment 375 Plus IEnumIDList enumId = ShellItem.GetIEnumIDList(folder, flags, out navRes);
Add comment 376 Plus this.NavigationStatus = navRes;
Add comment 377 Plus uint count;
Add comment 378 Plus IntPtr pidl;
Add comment 379 Plus
Add comment 380 Plus if (enumId == null) {
Add comment 381 Plus yield break;
Add comment 382 Plus }
Add comment 383 Plus
Add comment 384 Plus HResult result = enumId.Next(1, out pidl, out count);
Add comment 385 Plus var i = 0;
Add comment 386 Plus //var parentItem = new ShellItem(this._Item.Pidl); //this._Item;//this.IsSearchFolder ? this._Item : new ShellItem(this.ParsingName.ToShellParsingName());
Add comment 387 Plus while (result == HResult.S_OK) {
Add comment 388 Plus
Add comment 389 Plus yield return pidl;
Add comment 390 Plus Shell32.ILFree(pidl);
Add comment 391 Plus result = enumId.Next(1, out pidl, out count);
Add comment 392 Plus }
Add comment 393 Plus
Add comment 394 Plus if (result != HResult.S_FALSE) {
Add comment 395 Plus //Marshal.ThrowExceptionForHR((int)result);
Add comment 396 Plus }
Add comment 397 Plus
Add comment 398 Plus //parentItem.Dispose();
Add comment 399 Plus yield break;
Add comment 400 Plus }
Add comment 401 Plus
Add comment 279 402 public IEnumerator<IListItemEx> GetEnumerator() {
Add comment 280 403 IShellFolder folder = this.GetIShellFolder();
Add comment 281 Minus if (folder == null) yield return null;
Add comment 404 Plus if (folder == null)
Add comment 405 Plus yield return null;
Add comment 282 406 HResult navRes;
Add comment 283 407 IEnumIDList enumId = ShellItem.GetIEnumIDList(folder, SHCONTF.FOLDERS | SHCONTF.INCLUDEHIDDEN | SHCONTF.INCLUDESUPERHIDDEN | SHCONTF.FASTITEMS |
Add comment 284 408 SHCONTF.NONFOLDERS | SHCONTF.ENABLE_ASYNC | SHCONTF.INIT_ON_FIRST_NEXT, out navRes);
Add comment 296 420 while (result == HResult.S_OK) {
Add comment 297 421 var fsi = new FileSystemListItem();
Add comment 298 422 try {
Add comment 299 Minus fsi.InitializeWithParent(this._Item, this.ParentHandle, pidl, i++);
Add comment 423 Plus fsi.InitializeWithParent(this.PIDL, this.ParentHandle, pidl, i++);
Add comment 300 424 } catch {
Add comment 301 425 continue;
Add comment 302 426 }
Add comment 303 427 fsi.IsParentSearchFolder = this.IsSearchFolder;
Add comment 304 428 yield return fsi;
Add comment 305 Minus Shell32.ILFree(pidl);
Add comment 429 Plus //Shell32.ILFree(pidl);
Add comment 306 430 result = enumId.Next(1, out pidl, out count);
Add comment 307 431 }
Add comment 308 432
Add comment 317 441 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => GetEnumerator();
Add comment 318 442
Add comment 319 443 //public PropVariant GetPropertyValue(PROPERTYKEY pkey, Type type) => this._Item.GetPropertyValue(pkey, type);
Add comment 320 Minus public PropVariant GetPropertyValue(PROPERTYKEY pkey, Type type) => this._Item.GetPropertyValue(pkey);
Add comment 444 Plus public PropVariant GetPropertyValue(PROPERTYKEY pkey, Type type) {
Add comment 445 Plus var pvar = new PropVariant();
Add comment 446 Plus var comObject = this.ComInterface;
Add comment 447 Plus var isi2 = (IShellItem2) comObject;
Add comment 448 Plus if (isi2 == null) {
Add comment 449 Plus return PropVariant.FromObject(null);
Add comment 450 Plus }
Add comment 321 451
Add comment 452 Plus isi2.GetProperty(ref pkey, pvar);
Add comment 453 Plus Marshal.ReleaseComObject(comObject);
Add comment 454 Plus return pvar;
Add comment 455 Plus }
Add comment 456 Plus
Add comment 322 457 public System.Drawing.Bitmap Thumbnail(int size, ShellThumbnailFormatOption format, ShellThumbnailRetrievalOption source) =>
Add comment 323 Minus this._Item.GetShellThumbnail(size, format, source);
Add comment 458 Plus this._Item?.GetShellThumbnail(size, format, source);
Add comment 324 459
Add comment 325 460 public BitmapSource ThumbnailSource(int size, ShellThumbnailFormatOption format, ShellThumbnailRetrievalOption source) {
Add comment 326 461 //if (this.IsSearchFolder)
Add comment 327 462 // this._Item.ComInterface = this.searchFolder.m_SearchComInterface;
Add comment 463 Plus //if (this._Item == null)
Add comment 464 Plus // return null;
Add comment 465 Plus //this._Item.Thumbnail.CurrentSize = new System.Windows.Size(size, size);
Add comment 466 Plus //this._Item.Thumbnail.RetrievalOption = source;
Add comment 467 Plus //this._Item.Thumbnail.FormatOption = format;
Add comment 468 Plus //return this._Item.Thumbnail.BitmapSource;
Add comment 469 Plus IntPtr hBitmap = this.GetHBitmap(size, format == ShellThumbnailFormatOption.ThumbnailOnly, source == ShellThumbnailRetrievalOption.Default, format == ShellThumbnailFormatOption.Default);
Add comment 328 470
Add comment 329 Minus this._Item.Thumbnail.CurrentSize = new System.Windows.Size(size, size);
Add comment 330 Minus this._Item.Thumbnail.RetrievalOption = source;
Add comment 331 Minus this._Item.Thumbnail.FormatOption = format;
Add comment 332 Minus return this._Item.Thumbnail.BitmapSource;
Add comment 471 Plus // return a System.Media.Imaging.BitmapSource
Add comment 472 Plus // Use interop to create a BitmapSource from hBitmap.
Add comment 473 Plus if (hBitmap != IntPtr.Zero) {
Add comment 474 Plus BitmapSource returnValue = Imaging.CreateBitmapSourceFromHBitmap(
Add comment 475 Plus hBitmap,
Add comment 476 Plus IntPtr.Zero,
Add comment 477 Plus System.Windows.Int32Rect.Empty,
Add comment 478 Plus BitmapSizeOptions.FromEmptyOptions()).Clone();
Add comment 479 Plus
Add comment 480 Plus // delete HBitmap to avoid memory leaks
Add comment 481 Plus Gdi32.DeleteObject(hBitmap);
Add comment 482 Plus return returnValue;
Add comment 333 483 }
Add comment 334 484
Add comment 485 Plus return null;
Add comment 486 Plus }
Add comment 487 Plus
Add comment 335 488 /// <summary>Is the current item a search folder?</summary>
Add comment 336 Minus public bool IsSearchFolder { get; set; }
Add comment 489 Plus public bool IsSearchFolder {
Add comment 490 Plus get {
Add comment 491 Plus try {
Add comment 492 Plus return (!ParsingName.StartsWith("::") && !IsFileSystem && !ParsingName.StartsWith(@"\\") && !ParsingName.Contains(":\\")) || ParsingName.EndsWith(".search-ms");
Add comment 493 Plus } catch {
Add comment 494 Plus return false;
Add comment 495 Plus }
Add comment 496 Plus }
Add comment 497 Plus }
Add comment 337 498
Add comment 338 499 /// <summary>The logical parent for this item</summary>
Add comment 339 500 public IListItemEx Parent {
Add comment 340 501 get {
Add comment 341 Minus if (this.IsSearchFolder || this._Item.Parent == null) return null;
Add comment 342 Minus
Add comment 502 Plus IShellItem item;
Add comment 503 Plus var comObject = this.ComInterface;
Add comment 504 Plus HResult result = comObject.GetParent(out item);
Add comment 505 Plus Marshal.ReleaseComObject(comObject);
Add comment 506 Plus if (result == HResult.S_OK) {
Add comment 343 507 var parent = new FileSystemListItem();
Add comment 344 Minus parent.Initialize(this.ParentHandle, this._Item.Parent.Pidl, 0);
Add comment 508 Plus parent.Initialize(this.ParentHandle, Shell32.SHGetIDListFromObject(item), 0);
Add comment 345 509 return parent;
Add comment 510 Plus } else if (result == HResult.MK_E_NOOBJECT) {
Add comment 511 Plus return null;
Add comment 512 Plus } else {
Add comment 513 Plus Marshal.ThrowExceptionForHR((int)result);
Add comment 514 Plus return null;
Add comment 346 515 }
Add comment 347 516 }
Add comment 517 Plus }
Add comment 348 518
Add comment 349 Minus public IShellFolder GetIShellFolder() => this._Item.GetIShellFolder();
Add comment 519 Plus public IShellFolder GetIShellFolder() {
Add comment 520 Plus IntPtr res;
Add comment 521 Plus try {
Add comment 522 Plus var comObject = this.ComInterface;
Add comment 523 Plus comObject.BindToHandler(IntPtr.Zero, BHID.SFObject, typeof(IShellFolder).GUID, out res); //HResult result =
Add comment 524 Plus var iShellFolder = (IShellFolder)Marshal.GetTypedObjectForIUnknown(res, typeof(IShellFolder));
Add comment 525 Plus Marshal.ReleaseComObject(comObject);
Add comment 526 Plus return iShellFolder;
Add comment 527 Plus } catch {
Add comment 528 Plus return null;
Add comment 529 Plus }
Add comment 530 Plus }
Add comment 350 531
Add comment 351 Minus public bool IsLink => this._Item.IsLink;
IListItemEx.cs
/Shell/_Plugin Interfaces/IListItemEx.cs-14+21/Shell/_Plugin Interfaces/IListItemEx.cs
Add comment 10
Add comment 11 public interface IListItemEx : IEnumerable<IListItemEx>, IDisposable, IEquatable<IListItemEx>, IEqualityComparer<IListItemEx> {
Add comment 12
Add comment 13 Plus IntPtr ParentPIDL { get; set; }
Add comment 14 Plus
Add comment 15 Plus IntPtr EnumPIDL { get; set; }
Add comment 16 Plus
Add comment 17 Plus IExtractIconPWFlags GetIconType();
Add comment 18 Plus
Add comment 13 19 /// <summary>The COM interface for this item</summary>
Add comment 14 20 IShellItem ComInterface { get; }
Add comment 15 21
Add comment 17 23 IListItemEx Parent { get; }
Add comment 18 24
Add comment 19 25 /// <summary>The text that represents the display name</summary>
Add comment 20 Minus String DisplayName { get; set; }
Add comment 26 Plus String DisplayName { get; }
Add comment 21 27
Add comment 22 28 /// <summary>The file system extension for this item</summary>
Add comment 23 Minus String Extension { get; set; }
Add comment 29 Plus String Extension { get; }
Add comment 24 30
Add comment 25 31 /// <summary>The file system path</summary>
Add comment 26 Minus String FileSystemPath { get; set; }
Add comment 32 Plus String FileSystemPath { get; }
Add comment 27 33
Add comment 28 34 Int32 ItemIndex { get; set; }
Add comment 29 35
Add comment 59 65
Add comment 60 66 IntPtr ILPidl { get; }
Add comment 61 67
Add comment 62 Minus IntPtr PIDL { get; set; }
Add comment 68 Plus IntPtr PIDL { get; }
Add comment 63 69
Add comment 64 70 /// <summary>Not Used</summary>
Add comment 65 71 IShellFolder IFolder { get; set; } //TODO: Use this property or delete it
Add comment 70 76 /// <summary>Is this item's icon loaded yet?</summary>
Add comment 71 77 Boolean IsIconLoaded { get; set; }
Add comment 72 78
Add comment 73 Minus Boolean IsFileSystem { get; set; }
Add comment 79 Plus Boolean IsFileSystem { get; }
Add comment 74 80
Add comment 75 Minus Boolean IsNetworkPath { get; set; }
Add comment 81 Plus Boolean IsNetworkPath { get; }
Add comment 76 82
Add comment 77 83 /// <summary>Is current item represent a system drive?</summary>
Add comment 78 Minus Boolean IsDrive { get; set; }
Add comment 84 Plus Boolean IsDrive { get; }
Add comment 79 85
Add comment 80 86 /// <summary>Is the current item a search folder?</summary>
Add comment 81 Minus Boolean IsSearchFolder { get; set; }
Add comment 87 Plus Boolean IsSearchFolder { get; }
Add comment 82 88
Add comment 83 89 /// <summary>Implemented but never used</summary>
Add comment 84 90 Bitmap Thumbnail(Int32 size, ShellThumbnailFormatOption format, ShellThumbnailRetrievalOption source);
Add comment 89 95 /// <summary>Implemented but never used</summary>
Add comment 90 96 BitmapSource BitmapSource { get; }
Add comment 91 97
Add comment 92 Minus String ParsingName { get; set; }
Add comment 98 Plus String ParsingName { get; }
Add comment 93 99
Add comment 94 100 Boolean IsBrowsable { get; }
Add comment 95 101
Add comment 96 102 /// <summary>Is this a folder?</summary>
Add comment 97 Minus Boolean IsFolder { get; set; }
Add comment 103 Plus Boolean IsFolder { get; }
Add comment 98 104
Add comment 99 105 /// <summary>Does this have folders?</summary>
Add comment 100 106 Boolean HasSubFolders { get; }
Add comment 101 107
Add comment 102 108 /// <summary>Is this item normally hidden?</summary>
Add comment 103 Minus Boolean IsHidden { get; set; }
Add comment 109 Plus Boolean IsHidden { get; }
Add comment 104 110
Add comment 105 111 Boolean IsLink { get; }
Add comment 106 112
Add comment 107 Minus Boolean IsShared { get; set; }
Add comment 113 Plus Boolean IsShared { get; }
Add comment 108 114
Add comment 109 115 /// <summary>We should remove this and use this.Parent.IsSearchFolder</summary>
Add comment 110 116 Boolean IsParentSearchFolder { get; set; }
Add comment 117 123
Add comment 118 124 void Initialize(IntPtr lvHandle, IntPtr pidl);
Add comment 119 125
Add comment 120 Minus void InitializeWithParent(ShellItem parent, IntPtr lvHandle, IntPtr pidl, int index);
Add comment 126 Plus void InitializeWithParent(IntPtr parent, IntPtr lvHandle, IntPtr pidl, int index);
Add comment 121 127
Add comment 122 128 IListItemEx Clone(Boolean isHardCloning = false);
Add comment 123 129
Add comment 131 137 /// <param name="isEnumHidden">Should we include the hidden items?</param>
Add comment 132 138 /// <returns></returns>
Add comment 133 139 IListItemEx[] GetSubItems(Boolean isEnumHidden);
Add comment 140 Plus IEnumerable<IntPtr> GetItemsForCount(Boolean isEnumHidden);
Add comment 134 141
Add comment 135 142 IShellFolder GetIShellFolder();
Add comment 136 143
Add comment 149 156
Add comment 150 157 HResult NavigationStatus { get; set; }
Add comment 151 158
Add comment 152 Minus IntPtr GetHBitmap(int iconSize, bool isThumbnail, bool isForce = false);
Add comment 159 Plus IntPtr GetHBitmap(int iconSize, bool isThumbnail, bool isForce = false, bool isBoth = false);
Add comment 153 160
Add comment 154 161 Boolean RefreshThumb(int iconSize, out WTS_CACHEFLAGS flags);
Add comment 155 162
Add comment 699 return false;
Add comment 700 }
Add comment 701 else {
Add comment 702 Minus return checkedItem?.Parent?.Equals(currentFolder) == true;
Add comment 702 Plus return checkedItem?.Parent?.ParsingName == currentFolder.ParsingName;
Add comment 703 Plus }
Add comment 704 Plus }
Add comment 705 Plus
Add comment 706 Plus public static IOrderedEnumerable<IListItemEx> SetSortCollumn(this IEnumerable<IListItemEx> items, ShellView view, Boolean isReorder, Collumns column, SortOrder order, Boolean reverseOrder = true) {
Add comment 707 Plus if (column == null) {
Add comment 708 Plus column = view.Collumns.FirstOrDefault();
Add comment 709 Plus }
Add comment 710 Plus
Add comment 711 Plus try {
Add comment 712 Plus IOrderedEnumerable<IListItemEx> result = null;
Add comment 713 Plus var itemsArray = items;
Add comment 714 Plus //var selectedItems = this.SelectedItems.ToArray();
Add comment 715 Plus if (column.ID == view.LastSortedColumnId && reverseOrder) {
Add comment 716 Plus // Reverse the current sort direction for this column.
Add comment 717 Plus view.LastSortOrder = view.LastSortOrder == SortOrder.Ascending ? SortOrder.Descending : SortOrder.Ascending;
Add comment 718 Plus } else {
Add comment 719 Plus // Set the column number that is to be sorted; default to ascending.
Add comment 720 Plus view.LastSortedColumnId = column.ID;
Add comment 721 Plus view.LastSortOrder = order;
Add comment 722 Plus }
Add comment 723 Plus
Add comment 724 Plus if (isReorder) {
Add comment 725 Plus var itemsQuery = itemsArray.Where(w => view.ShowHidden || !w.IsHidden).OrderByDescending(o => o.IsFolder);
Add comment 726 Plus if (column.CollumnType != typeof(String)) {
Add comment 727 Plus if (order == SortOrder.Ascending) {
Add comment 728 Plus result = itemsQuery.ThenBy(o => o.GetPropertyValue(column.pkey, typeof(String)).Value ?? "1");
Add comment 729 Plus } else {
Add comment 730 Plus result = itemsQuery.ThenByDescending(o => o.GetPropertyValue(column.pkey, typeof(String)).Value ?? "1");
Add comment 731 Plus }
Add comment 732 Plus } else {
Add comment 733 Plus if (order == SortOrder.Ascending) {
Add comment 734 Plus result = itemsQuery.ThenBy(o => o.GetPropertyValue(column.pkey, typeof(String)).Value == null ? "1" : o.GetPropertyValue(column.pkey, typeof(String)).Value.ToString(), NaturalStringComparer.Default);
Add comment 735 Plus } else {
Add comment 736 Plus result = itemsQuery.ThenByDescending(o => o.GetPropertyValue(column.pkey, typeof(String)).Value == null ? "1" : o.GetPropertyValue(column.pkey, typeof(String)).Value.ToString(),
Add comment 737 Plus NaturalStringComparer.Default);
Add comment 738 Plus }
Add comment 739 Plus }
Add comment 740 Plus
Add comment 741 Plus var i = 0;
Add comment 742 Plus }
Add comment 743 Plus
Add comment 744 Plus
Add comment 745 Plus var colIndexReal = view.Collumns.IndexOf(view.Collumns.FirstOrDefault(w => w.ID == view.LastSortedColumnId));
Add comment 746 Plus if (colIndexReal > -1) {
Add comment 747 Plus User32.SendMessage(view.LVHandle, MSG.LVM_SETSELECTEDCOLUMN, colIndexReal, 0);
Add comment 748 Plus view.SetSortIcon(colIndexReal, order);
Add comment 749 Plus } else {
Add comment 750 Plus User32.SendMessage(view.LVHandle, MSG.LVM_SETSELECTEDCOLUMN, -1, 0);
Add comment 751 Plus }
Add comment 752 Plus
Add comment 753 Plus //if (!this.IsRenameInProgress) {
Add comment 754 Plus // this.SelectItems(selectedItems);
Add comment 755 Plus //}
Add comment 756 Plus return result;
Add comment 757 Plus } catch {
Add comment 758 Plus return null;
Add comment 703 759 }
Add comment 704 760 }
Add comment 705 761 }
Add comment 309 else
Add comment 310 this._Large.DrawIcon(hdc, this._SharedIconIndex, new Point(iconBounds.Right - 30, iconBounds.Bottom - 32));
Add comment 311 }
Add comment 312 Minus var badge = this.GetBadgeForPath(sho.ParsingName);
Add comment 312 Plus IListItemEx badge = this.GetBadgeForPath(sho.ParsingName);
Add comment 313 if (badge != null) {
Add comment 314 var badgeIco = badge.GetHBitmap(this._CurrentSize, false);
Add comment 315 Gdi32.ConvertPixelByPixel(badgeIco, out width, out height);
Add comment 387 this._Small.DrawIcon(hdc, this._SharedIconIndex, new Point(iconBounds.Right - 9, iconBounds.Bottom - 16));
Add comment 388 }
Add comment 389
Add comment 390 Minus var badge = this.GetBadgeForPath(sho.ParsingName);
Add comment 390 Plus IListItemEx badge = this.GetBadgeForPath(sho.ParsingName);
Add comment 391 if (badge != null) {
Add comment 392 var badgeIco = badge.GetHBitmap(16, false);
Add comment 393 Gdi32.ConvertPixelByPixel(badgeIco, out width, out height);
Add comment 457 Int32 overlayIndex = 0;
Add comment 458 this._Small.GetIconIndexWithOverlay(sho.PIDL, out overlayIndex);
Add comment 459 shoTemp.OverlayIconIndex = overlayIndex;
Add comment 460 Minus if (sho.IsFolder && sho.IsShared) shoTemp.IsShared = true;
Add comment 460 Plus //if (sho.IsFolder && sho.IsShared) shoTemp.IsShared = true;
Add comment 461 if (overlayIndex > 0) {
Add comment 462 if (!this._RedrawQueue.Contains(index))
Add comment 463 this._RedrawQueue.Enqueue(index);
Add comment 477 var sho = this._ShellViewEx.Items[index];
Add comment 478 if (!sho.IsIconLoaded) {
Add comment 479 try {
Add comment 480 Minus var temp = FileSystemListItem.ToFileSystemItem(sho.ParentHandle, sho.ParsingName.ToShellParsingName());
Add comment 481 Minus var icon = temp.GetHBitmap(this._CurrentSize, false, true);
Add comment 480 Plus //var temp = FileSystemListItem.ToFileSystemItem(sho.ParentHandle, sho.ParsingName.ToShellParsingName());
Add comment 481 Plus var icon = sho.GetHBitmap(this._CurrentSize, false, true);
Add comment 482 var shieldOverlay = 0;
Add comment 483
Add comment 484 if (sho.ShieldedIconIndex == -1) {
Add comment 485 Minus if ((temp.GetShield() & IExtractIconPWFlags.GIL_SHIELD) != 0) shieldOverlay = this._ShieldIconIndex;
Add comment 485 Plus if ((sho.GetShield() & IExtractIconPWFlags.GIL_SHIELD) != 0) shieldOverlay = this._ShieldIconIndex;
Add comment 486 sho.ShieldedIconIndex = shieldOverlay;
Add comment 487 }
Add comment 488
Add comment 535 private void _RedrawingThreadRun() {
Add comment 536 while (true) {
Add comment 537 ResetEvent?.WaitOne();
Add comment 538 Minus Application.DoEvents();
Add comment 538 Plus //Application.DoEvents();
Add comment 539 var index = this._RedrawQueue.Dequeue();
Add comment 540 if (User32.SendMessage(this._ShellViewEx.LVHandle, Interop.MSG.LVM_ISITEMVISIBLE, index, 0) == IntPtr.Zero) continue;
Add comment 541 this._ShellViewEx.RedrawItem(index);
Add comment 871 }
Add comment 872
Add comment 873 public static IEnumIDList GetIEnumIDList(IShellFolder folder, SHCONTF flags, out HResult navResult) {
Add comment 874 Plus navResult = HResult.S_OK;
Add comment 875 Plus if (folder == null) return null;
Add comment 874 876 IEnumIDList result;
Add comment 875 877 var res = folder.EnumObjects(IsCareForMessageHandle ? MessageHandle : IntPtr.Zero, flags, out result);
Add comment 876 878 navResult = res;