6 changed files
BExplorer/BetterExplorer | ||
Properties | ||
AssemblyInfo.cs | ||
MainWindow.xaml.cs | ||
Shell | ||
Interop | ||
ShellThumbnail.cs | ||
Extensions.cs | ||
ShellTreeViewEx.cs | ||
ShellViewEx.cs | ||
AssemblyInfo.cs
/BExplorer/BetterExplorer/Properties/AssemblyInfo.cs-2+2/BExplorer/BetterExplorer/Properties/AssemblyInfo.cs
Add comment 51 // You can specify all the values or you can default the Build and Revision Numbers
Add comment 52 // by using the '*' as shown below:
Add comment 53 // [assembly: AssemblyVersion("1.0.*")]
Add comment 54 Minus [assembly: AssemblyVersion("2.5.18136.1157")]
Add comment 55 Minus [assembly: AssemblyFileVersion("2.5.18136.1157")]
Add comment 54 Plus [assembly: AssemblyVersion("2.5.18156.0903")]
Add comment 55 Plus [assembly: AssemblyFileVersion("2.5.18156.0903")]
Add comment 56 [assembly: AssemblyInformationalVersion("2.5.4.18085.0732.62.1 RC5")]
Add comment 57
MainWindow.xaml.cs
/BExplorer/BetterExplorer/MainWindow.xaml.cs-11+30/BExplorer/BetterExplorer/MainWindow.xaml.cs
Add comment 1280 private void SetUpFavoritesMenu() {
Add comment 1281 this.Dispatcher.BeginInvoke(DispatcherPriority.Render, (ThreadStart)(() => {
Add comment 1282 this.btnFavorites.Visibility = Visibility.Visible;
Add comment 1283 Plus var favoritesItem = BExplorer.Shell.Utilities.WindowsVersion == WindowsVersions.Windows10
Add comment 1284 Plus ? FileSystemListItem.ToFileSystemItem(IntPtr.Zero, "shell:::{679f85cb-0220-4080-b29b-5540cc05aab6}")
Add comment 1285 Plus : FileSystemListItem.ToFileSystemItem(IntPtr.Zero, ((ShellItem)KnownFolders.Links).Pidl);
Add comment 1283 1286
Add comment 1284 Minus var OpenFavorites = new MenuItem() { Header = "Open Favorites" };
Add comment 1285 Minus var Path = ((ShellItem)KnownFolders.Links).FileSystemPath;
Add comment 1286 Minus OpenFavorites.Click += (x, y) => Process.Start(Path);
Add comment 1287 Plus var openFavorites = new MenuItem() { Header = "Open Favorites" };
Add comment 1288 Plus openFavorites.Click += (x, y) => this.tcMain.NewTab(favoritesItem, true);
Add comment 1287 1289
Add comment 1288 Minus this.btnFavorites.Items.Add(OpenFavorites);
Add comment 1290 Plus this.btnFavorites.Items.Add(openFavorites);
Add comment 1289 1291 this.btnFavorites.Items.Add(new Separator());
Add comment 1290 1292
Add comment 1291 Minus foreach (ShellItem item in KnownFolders.Links.Where(w => !w.IsHidden)) {
Add comment 1292 Minus item.Thumbnail.FormatOption = ShellThumbnailFormatOption.IconOnly;
Add comment 1293 Minus item.Thumbnail.CurrentSize = new WIN.Size(16, 16);
Add comment 1294 Minus this.btnFavorites.Items.Add(Utilities.Build_MenuItem(item.GetDisplayName(SIGDN.NORMALDISPLAY), item, item.Thumbnail.BitmapSource, onClick: this.mif_Click));
Add comment 1293 Plus foreach (var item in favoritesItem.Where(w => !w.IsHidden && (w.IsFolder || w.IsLink)).OrderBy(o => o.DisplayName)) {
Add comment 1294 Plus if (item.IsLink) {
Add comment 1295 Plus var link = new ShellLink(item.ParsingName);
Add comment 1296 Plus var targetItem = FileSystemListItem.ToFileSystemItem(this._ShellListView.LVHandle, link.TargetPIDL);
Add comment 1297 Plus if (targetItem.IsFolder) {
Add comment 1298 Plus this.btnFavorites.Items.Add(Utilities.Build_MenuItem(item.GetDisplayName(SIGDN.NORMALDISPLAY), item, item.ThumbnailSource(16, ShellThumbnailFormatOption.IconOnly, ShellThumbnailRetrievalOption.Default), onClick: this.mif_Click));
Add comment 1299 Plus }
Add comment 1300 Plus
Add comment 1301 Plus targetItem.Dispose();
Add comment 1302 Plus link.Dispose();
Add comment 1303 Plus } else {
Add comment 1304 Plus this.btnFavorites.Items.Add(Utilities.Build_MenuItem(item.GetDisplayName(SIGDN.NORMALDISPLAY), item, item.ThumbnailSource(16, ShellThumbnailFormatOption.IconOnly, ShellThumbnailRetrievalOption.Default),
Add comment 1305 Plus onClick: this.mif_Click));
Add comment 1306 Plus }
Add comment 1295 1307 }
Add comment 1296 1308 }));
Add comment 1297 1309 }
Add comment 2100 2112 this._IsShouldRiseViewChanged = false;
Add comment 2101 2113 if (this._ShellListView == null)
Add comment 2102 2114 return;
Add comment 2103 Minus else if (sender == this.btnSbDetails)
Add comment 2115 Plus else if (sender == this.btnSbDetails) {
Add comment 2104 2116 this._ShellListView.View = ShellViewStyle.Details;
Add comment 2105 Minus else if (sender == this.btnSbIcons)
Add comment 2117 Plus } else if (sender == this.btnSbIcons) {
Add comment 2106 2118 this._ShellListView.View = ShellViewStyle.Medium;
Add comment 2107 Minus else if (sender == this.btnSbTiles)
Add comment 2119 Plus } else if (sender == this.btnSbTiles) {
Add comment 2108 2120 this._ShellListView.View = ShellViewStyle.Tile;
Add comment 2121 Plus }
Add comment 2122 Plus
Add comment 2109 2123 this._IsShouldRiseViewChanged = true;
Add comment 2110 2124 }
Add comment 2111 2125
Add comment 3742 3756 this.Dispatcher.BeginInvoke(DispatcherPriority.Background,
Add comment 3743 3757 (ThreadStart)(() => {
Add comment 3744 3758 this._IsShouldRiseViewChanged = false;
Add comment 3759 Plus if (e.ThumbnailSize <= 48 && e.CurrentView != ShellViewStyle.Medium) {
Add comment 3760 Plus this.zoomSlider.IsEnabled = false;
Add comment 3761 Plus } else {
Add comment 3745 3762 this.zoomSlider.Value = e.ThumbnailSize;
Add comment 3763 Plus this.zoomSlider.IsEnabled = true;
Add comment 3764 Plus }
Add comment 3746 3765
Add comment 3747 3766 this.btnAutosizeColls.IsEnabled = e.CurrentView == ShellViewStyle.Details;
Add comment 3748 3767 this.btnSbTiles.IsChecked = e.CurrentView == ShellViewStyle.Tile;
Add comment 5 using System.Windows.Interop;
Add comment 6 using System.Windows.Media.Imaging;
Add comment 7
Add comment 8 Minus namespace BExplorer.Shell.Interop
Add comment 9 Minus {
Add comment 8 Plus namespace BExplorer.Shell.Interop {
Add comment 10 9
Add comment 11 10 /// <summary>
Add comment 12 11 /// Represents a thumbnail or an icon for a ShellObject.
Add comment 13 12 /// </summary>
Add comment 14 Minus public class ShellThumbnail : IDisposable
Add comment 15 Minus {
Add comment 13 Plus public class ShellThumbnail : IDisposable {
Add comment 16 14
Add comment 17 15 #region Private Members
Add comment 18 16
Add comment 47 45 /// <remarks>If the size specified is larger than the maximum size of 1024x1024 for thumbnails and 256x256 for icons,
Add comment 48 46 /// an <see cref="System.ArgumentOutOfRangeException"/> is thrown.
Add comment 49 47 /// </remarks>
Add comment 50 Minus public System.Windows.Size CurrentSize
Add comment 51 Minus {
Add comment 52 Minus get { return currentSize; }
Add comment 53 Minus set
Add comment 54 Minus {
Add comment 48 Plus public System.Windows.Size CurrentSize {
Add comment 49 Plus get { return this.currentSize; }
Add comment 50 Plus set {
Add comment 55 51 // Check for 0; negative number check not required as System.Windows.Size only allows positive numbers.
Add comment 56 Minus if (value.Height == 0 || value.Width == 0)
Add comment 57 Minus {
Add comment 58 Minus throw new System.ArgumentOutOfRangeException("value", "Thumbnail is null");
Add comment 52 Plus if (value.Height == 0 || value.Width == 0) {
Add comment 53 Plus throw new ArgumentOutOfRangeException("value", "Thumbnail is null");
Add comment 59 54 }
Add comment 60 55
Add comment 61 Minus System.Windows.Size size = (FormatOption == ShellThumbnailFormatOption.IconOnly) ? DefaultIconSize.Maximum : DefaultThumbnailSize.Maximum;
Add comment 56 Plus System.Windows.Size size = (this.FormatOption == ShellThumbnailFormatOption.IconOnly) ? DefaultIconSize.Maximum : DefaultThumbnailSize.Maximum;
Add comment 62 57
Add comment 63 Minus if (value.Height > size.Height || value.Width > size.Width)
Add comment 64 Minus {
Add comment 65 Minus throw new System.ArgumentOutOfRangeException("value", "Wrong Size!");
Add comment 58 Plus if (value.Height > size.Height || value.Width > size.Width) {
Add comment 59 Plus throw new ArgumentOutOfRangeException("value", "Wrong Size!");
Add comment 66 60 }
Add comment 67 61
Add comment 68 Minus currentSize = value;
Add comment 62 Plus this.currentSize = value;
Add comment 69 63 }
Add comment 70 64 }
Add comment 71 65
Add comment 73 67 /// Gets the thumbnail or icon image in <see cref="System.Drawing.Bitmap"/> format.
Add comment 74 68 /// Null is returned if the ShellObject does not have a thumbnail or icon image.
Add comment 75 69 /// </summary>
Add comment 76 Minus public Bitmap Bitmap => GetBitmap(CurrentSize);
Add comment 70 Plus public Bitmap Bitmap => this.GetBitmap(this.CurrentSize);
Add comment 77 71
Add comment 78 72 /// <summary>
Add comment 79 73 /// Gets the thumbnail or icon image in <see cref="System.Windows.Media.Imaging.BitmapSource"/> format.
Add comment 80 74 /// Null is returned if the ShellObject does not have a thumbnail or icon image.
Add comment 81 75 /// </summary>
Add comment 82 Minus public BitmapSource BitmapSource => GetBitmapSource(CurrentSize);
Add comment 76 Plus public BitmapSource BitmapSource => this.GetBitmapSource(this.CurrentSize);
Add comment 83 77
Add comment 84 78 /// <summary>
Add comment 85 79 /// Gets the thumbnail or icon in small size and <see cref="System.Windows.Media.Imaging.BitmapSource"/> format.
Add comment 86 80 /// </summary>
Add comment 87 Minus public BitmapSource SmallBitmapSource => GetBitmapSource(DefaultIconSize.Small, DefaultThumbnailSize.Small);
Add comment 81 Plus public BitmapSource SmallBitmapSource => this.GetBitmapSource(DefaultIconSize.Small, DefaultThumbnailSize.Small);
Add comment 88 82
Add comment 89 83 /// <summary>
Add comment 90 84 /// Gets or sets a value that determines if the current retrieval option is cache or extract, cache only, or from memory only.
Add comment 96 90 /// Gets or sets a value that determines if the current format option is thumbnail or icon, thumbnail only, or icon only.
Add comment 97 91 /// The default is thumbnail or icon.
Add comment 98 92 /// </summary>
Add comment 99 Minus public ShellThumbnailFormatOption FormatOption
Add comment 100 Minus {
Add comment 101 Minus get { return formatOption; }
Add comment 102 Minus set
Add comment 103 Minus {
Add comment 104 Minus formatOption = value;
Add comment 93 Plus public ShellThumbnailFormatOption FormatOption {
Add comment 94 Plus get => this.formatOption;
Add comment 95 Plus set {
Add comment 96 Plus this.formatOption = value;
Add comment 105 97
Add comment 106 98 // Do a similar check as we did in CurrentSize property setter,
Add comment 107 99 // If our mode is IconOnly, then our max is defined by DefaultIconSize.Maximum. We should make sure
Add comment 108 100 // our CurrentSize is within this max range
Add comment 109 Minus if (FormatOption == ShellThumbnailFormatOption.IconOnly
Add comment 110 Minus && (CurrentSize.Height > DefaultIconSize.Maximum.Height || CurrentSize.Width > DefaultIconSize.Maximum.Width))
Add comment 111 Minus {
Add comment 112 Minus CurrentSize = DefaultIconSize.Maximum;
Add comment 101 Plus if (this.FormatOption == ShellThumbnailFormatOption.IconOnly
Add comment 102 Plus && (this.CurrentSize.Height > DefaultIconSize.Maximum.Height || this.CurrentSize.Width > DefaultIconSize.Maximum.Width)) {
Add comment 103 Plus this.CurrentSize = DefaultIconSize.Maximum;
Add comment 113 104 }
Add comment 114 105 }
Add comment 115 Minus
Add comment 116 106 }
Add comment 117 107
Add comment 118 108 /// <summary>
Add comment 119 Minus /// Gets or sets a value that determines if the user can manually stretch the returned image.
Add comment 109 Plus /// Gets or sets a value indicating whether the user can manually stretch the returned image.
Add comment 120 110 /// The default value is false.
Add comment 121 111 /// </summary>
Add comment 122 112 /// <remarks>
Add comment 131 121
Add comment 132 122 #region Constructors
Add comment 133 123
Add comment 134 Minus public void Dispose()
Add comment 135 Minus {
Add comment 136 Minus if (shellItemNative != null)
Add comment 137 Minus {
Add comment 138 Minus Marshal.FinalReleaseComObject(shellItemNative);
Add comment 139 Minus shellItemNative = null;
Add comment 124 Plus public void Dispose() {
Add comment 125 Plus if (this.shellItemNative != null) {
Add comment 126 Plus Marshal.FinalReleaseComObject(this.shellItemNative);
Add comment 127 Plus this.shellItemNative = null;
Add comment 140 128 }
Add comment 141 129 }
Add comment 142 130 /// <summary>
Add comment 143 131 /// Internal constructor that takes in a parent ShellObject.
Add comment 144 132 /// </summary>
Add comment 145 133 /// <param name="shellObject"></param>
Add comment 146 Minus internal ShellThumbnail(ShellItem shellObject)
Add comment 147 Minus {
Add comment 148 Minus if (shellObject != null && shellObject.ComInterface != null)
Add comment 149 Minus {
Add comment 150 Minus _Item = shellObject;
Add comment 151 Minus shellItemNative = shellObject.ComInterface;
Add comment 152 Minus if (ThumbnailCache == null)
Add comment 153 Minus {
Add comment 134 Plus internal ShellThumbnail(ShellItem shellObject) {
Add comment 135 Plus if (shellObject != null && shellObject.ComInterface != null) {
Add comment 136 Plus this._Item = shellObject;
Add comment 137 Plus this.shellItemNative = shellObject.ComInterface;
Add comment 138 Plus if (ThumbnailCache == null) {
Add comment 154 139 Guid IID_IUnknown = new Guid("00000000-0000-0000-C000-000000000046");
Add comment 155 140 Guid CLSID_LocalThumbnailCache = new Guid("50EF4544-AC9F-4A8E-B21B-8A26180DB13F");
Add comment 156 141
Add comment 166 151
Add comment 167 152 #region Private Methods
Add comment 168 153
Add comment 169 Minus private SIIGBF CalculateFlags()
Add comment 170 Minus {
Add comment 154 Plus private SIIGBF CalculateFlags() {
Add comment 171 155 SIIGBF flags = 0x0000;
Add comment 172 156
Add comment 173 Minus if (AllowBiggerSize)
Add comment 174 Minus {
Add comment 157 Plus if (this.AllowBiggerSize) {
Add comment 175 158 flags |= SIIGBF.BiggerSizeOk;
Add comment 176 159 }
Add comment 177 160
Add comment 178 Minus if (FormatOption != ShellThumbnailFormatOption.IconOnly)
Add comment 179 Minus {
Add comment 180 Minus if (RetrievalOption == ShellThumbnailRetrievalOption.CacheOnly)
Add comment 181 Minus {
Add comment 161 Plus if (this.FormatOption != ShellThumbnailFormatOption.IconOnly) {
Add comment 162 Plus if (this.RetrievalOption == ShellThumbnailRetrievalOption.CacheOnly) {
Add comment 182 163 flags |= SIIGBF.InCacheOnly;
Add comment 183 Minus }
Add comment 184 Minus else if (RetrievalOption == ShellThumbnailRetrievalOption.MemoryOnly)
Add comment 185 Minus {
Add comment 164 Plus } else if (this.RetrievalOption == ShellThumbnailRetrievalOption.MemoryOnly) {
Add comment 186 165 flags |= SIIGBF.MemoryOnly;
Add comment 187 166 }
Add comment 188 167 }
Add comment 189 168
Add comment 190 Minus if (FormatOption == ShellThumbnailFormatOption.IconOnly)
Add comment 191 Minus {
Add comment 169 Plus if (this.FormatOption == ShellThumbnailFormatOption.IconOnly) {
Add comment 192 170 flags |= SIIGBF.IconOnly;
Add comment 193 Minus }
Add comment 194 Minus else if (FormatOption == ShellThumbnailFormatOption.ThumbnailOnly)
Add comment 195 Minus {
Add comment 171 Plus } else if (this.FormatOption == ShellThumbnailFormatOption.ThumbnailOnly) {
Add comment 196 172 flags |= SIIGBF.ThumbnailOnly;
Add comment 197 173 }
Add comment 198 174
Add comment 199 175 return flags;
Add comment 200 176 }
Add comment 201 177
Add comment 202 Minus public IntPtr GetHBitmap(System.Windows.Size size, Boolean isCopyItem = false)
Add comment 203 Minus {
Add comment 204 Minus if (shellItemNative == null) return IntPtr.Zero;
Add comment 178 Plus public IntPtr GetHBitmap(System.Windows.Size size, Boolean isCopyItem = false) {
Add comment 179 Plus if (this.shellItemNative == null)
Add comment 180 Plus return IntPtr.Zero;
Add comment 205 181 // Create a size structure to pass to the native method
Add comment 206 182 var nativeSIZE = new Size() { Width = Convert.ToInt32(size.Width), Height = Convert.ToInt32(size.Height) };
Add comment 207 183 var nativeItem = isCopyItem && !this._Item.IsSearchFolder && this._Item.DisplayName != "Search.search-ms"
Add comment 208 184 ? new ShellItem(this._Item.CachedParsingName.ToShellParsingName()).ComInterface
Add comment 209 Minus : shellItemNative;
Add comment 185 Plus : this.shellItemNative;
Add comment 210 186
Add comment 211 187 // Use IShellItemImageFactory to get an icon
Add comment 212 188 // Options passed in: Resize to fit
Add comment 213 189 IntPtr hbitmap = IntPtr.Zero;
Add comment 214 Minus HResult hr = ((IShellItemImageFactory)nativeItem).GetImage(nativeSIZE, CalculateFlags(), out hbitmap);
Add comment 190 Plus HResult hr = ((IShellItemImageFactory)nativeItem).GetImage(nativeSIZE, this.CalculateFlags(), out hbitmap);
Add comment 215 191 return hr == HResult.S_OK ? hbitmap : IntPtr.Zero;
Add comment 216 192 }
Add comment 217 193
Add comment 218 Minus public static bool IsAlphaBitmap(Bitmap bmp, out BitmapData bmpData)
Add comment 219 Minus {
Add comment 194 Plus public static bool IsAlphaBitmap(Bitmap bmp, out BitmapData bmpData) {
Add comment 220 195 var bmBounds = new Rectangle(0, 0, bmp.Width, bmp.Height);
Add comment 221 196 bmpData = bmp.LockBits(bmBounds, ImageLockMode.ReadOnly, bmp.PixelFormat);
Add comment 222 197
Add comment 223 Minus try
Add comment 224 Minus {
Add comment 198 Plus try {
Add comment 225 199 byte[] bytes = new byte[bmpData.Height * bmpData.Stride];
Add comment 226 200 Marshal.Copy(bmpData.Scan0, bytes, 0, bytes.Length);
Add comment 227 201 for (var p = 3; p < bytes.Length; p += 4) {
Add comment 228 Minus if (bytes[p] != 255) return true;
Add comment 229 Minus }
Add comment 202 Plus if (bytes[p] != 255)
Add comment 203 Plus return true;
Add comment 230 204 }
Add comment 231 Minus finally
Add comment 232 Minus {
Add comment 205 Plus } finally {
Add comment 233 206 bmp.UnlockBits(bmpData);
Add comment 234 207 }
Add comment 235 208
Add comment 236 209 return false;
Add comment 237 210 }
Add comment 238 211
Add comment 239 Minus private Bitmap GetBitmap(System.Windows.Size size)
Add comment 240 Minus {
Add comment 241 Minus IntPtr hBitmap = GetHBitmap(size);
Add comment 212 Plus private Bitmap GetBitmap(System.Windows.Size size) {
Add comment 213 Plus IntPtr hBitmap = this.GetHBitmap(size);
Add comment 242 214
Add comment 243 215 // return a System.Drawing.Bitmap from the hBitmap
Add comment 244 216 Bitmap returnValue = null;
Add comment 245 217 if (hBitmap != IntPtr.Zero)
Add comment 246 Minus returnValue = GetBitmapFromHBitmap(hBitmap);
Add comment 218 Plus returnValue = this.GetBitmapFromHBitmap(hBitmap);
Add comment 247 219
Add comment 248 220 // delete HBitmap to avoid memory leaks
Add comment 249 221 Gdi32.DeleteObject(hBitmap);
Add comment 251 223 return returnValue;
Add comment 252 224 }
Add comment 253 225
Add comment 254 Minus private BitmapSource GetBitmapSource(System.Windows.Size iconOnlySize, System.Windows.Size thumbnailSize)
Add comment 255 Minus {
Add comment 256 Minus if (thumbnailSize == DefaultThumbnailSize.Small)
Add comment 257 Minus {
Add comment 258 Minus FormatOption = ShellThumbnailFormatOption.IconOnly;
Add comment 259 Minus RetrievalOption = ShellThumbnailRetrievalOption.Default;
Add comment 226 Plus private BitmapSource GetBitmapSource(System.Windows.Size iconOnlySize, System.Windows.Size thumbnailSize) {
Add comment 227 Plus if (thumbnailSize == DefaultThumbnailSize.Small) {
Add comment 228 Plus this.FormatOption = ShellThumbnailFormatOption.IconOnly;
Add comment 229 Plus this.RetrievalOption = ShellThumbnailRetrievalOption.Default;
Add comment 260 230 }
Add comment 261 Minus return GetBitmapSource((FormatOption == ShellThumbnailFormatOption.IconOnly ? iconOnlySize : thumbnailSize), thumbnailSize == DefaultThumbnailSize.Small && !this._Item.IsSearchFolder);
Add comment 231 Plus return this.GetBitmapSource((this.FormatOption == ShellThumbnailFormatOption.IconOnly ? iconOnlySize : thumbnailSize), thumbnailSize == DefaultThumbnailSize.Small && !this._Item.IsSearchFolder);
Add comment 262 232 }
Add comment 263 233
Add comment 264 Minus private BitmapSource GetBitmapSource(System.Windows.Size size, Boolean isCopyItem = false)
Add comment 265 Minus {
Add comment 234 Plus private BitmapSource GetBitmapSource(System.Windows.Size size, Boolean isCopyItem = false) {
Add comment 266 235 //FIXME: fix the cache retrieval options
Add comment 267 236 //RetrievalOption = ShellThumbnailRetrievalOption.Default;
Add comment 268 Minus IntPtr hBitmap = GetHBitmap(size, isCopyItem);
Add comment 237 Plus IntPtr hBitmap = this.GetHBitmap(size, isCopyItem);
Add comment 269 238
Add comment 270 239 // return a System.Media.Imaging.BitmapSource
Add comment 271 240 // Use interop to create a BitmapSource from hBitmap.
Add comment 272 Minus if (hBitmap != IntPtr.Zero)
Add comment 273 Minus {
Add comment 241 Plus if (hBitmap != IntPtr.Zero) {
Add comment 274 242 BitmapSource returnValue = Imaging.CreateBitmapSourceFromHBitmap(
Add comment 275 243 hBitmap,
Add comment 276 244 IntPtr.Zero,
Add comment 285 253 return null;
Add comment 286 254 }
Add comment 287 255
Add comment 288 Minus private static Bitmap GetlAlphaBitmapFromBitmapData(BitmapData bmpData)
Add comment 289 Minus {
Add comment 256 Plus private static Bitmap GetlAlphaBitmapFromBitmapData(BitmapData bmpData) {
Add comment 290 257 Bitmap b = new Bitmap(
Add comment 291 258 bmpData.Width,
Add comment 292 259 bmpData.Height,
Add comment 298 265 #endregion
Add comment 299 266
Add comment 300 267 #region Public Methods
Add comment 301 Minus public Boolean RefreshThumbnail(uint iconSize, out WTS_CACHEFLAGS flags)
Add comment 302 Minus {
Add comment 268 Plus public Boolean RefreshThumbnail(uint iconSize, out WTS_CACHEFLAGS flags) {
Add comment 303 269
Add comment 304 270 ISharedBitmap bmp = null;
Add comment 305 271 WTS_CACHEFLAGS cacheFlags = WTS_CACHEFLAGS.WTS_DEFAULT;
Add comment 306 272 WTS_THUMBNAILID thumbId = new WTS_THUMBNAILID();
Add comment 307 273 Boolean result = false;
Add comment 308 Minus try
Add comment 309 Minus {
Add comment 310 Minus if (ThumbnailCache.GetThumbnail(this.shellItemNative, iconSize, WTS_FLAGS.WTS_FORCEEXTRACTION | WTS_FLAGS.WTS_SCALETOREQUESTEDSIZE, out bmp, cacheFlags, thumbId) != HResult.WTS_E_FAILEDEXTRACTION)
Add comment 311 Minus {
Add comment 274 Plus try {
Add comment 275 Plus if (ThumbnailCache.GetThumbnail(this.shellItemNative, iconSize, WTS_FLAGS.WTS_FORCEEXTRACTION | WTS_FLAGS.WTS_SCALETOREQUESTEDSIZE, out bmp, cacheFlags, thumbId) != HResult.WTS_E_FAILEDEXTRACTION) {
Add comment 312 276 result = true;
Add comment 313 277 }
Add comment 314 Minus }
Add comment 315 Minus finally
Add comment 316 Minus {
Add comment 317 Minus if (bmp != null) Marshal.ReleaseComObject(bmp);
Add comment 278 Plus } finally {
Add comment 279 Plus if (bmp != null)
Add comment 280 Plus Marshal.ReleaseComObject(bmp);
Add comment 318 281 }
Add comment 319 282 flags = cacheFlags;
Add comment 320 283 return result;
Add comment 321 284 }
Add comment 322 Minus public HResult ExtractAndDrawThumbnail(IntPtr hdc, uint iconSize, out WTS_CACHEFLAGS flags, User32.RECT iconBounds, out bool retrieved, bool isHidden, bool isRefresh = false)
Add comment 323 Minus {
Add comment 285 Plus public HResult ExtractAndDrawThumbnail(IntPtr hdc, uint iconSize, out WTS_CACHEFLAGS flags, User32.RECT iconBounds, out bool retrieved, bool isHidden, bool isRefresh = false) {
Add comment 324 286 HResult res = HResult.S_OK;
Add comment 325 287 ISharedBitmap bmp = null;
Add comment 326 288 flags = WTS_CACHEFLAGS.WTS_DEFAULT;
Add comment 327 289 WTS_THUMBNAILID thumbId = new WTS_THUMBNAILID();
Add comment 328 Minus try
Add comment 329 Minus {
Add comment 290 Plus try {
Add comment 330 291 retrieved = false;
Add comment 331 292 res = ThumbnailCache.GetThumbnail(this._Item.ComInterface, iconSize, isRefresh ? (WTS_FLAGS.WTS_FORCEEXTRACTION | WTS_FLAGS.WTS_SCALETOREQUESTEDSIZE) : (WTS_FLAGS.WTS_INCACHEONLY | WTS_FLAGS.WTS_SCALETOREQUESTEDSIZE), out bmp, flags, thumbId);
Add comment 332 293 IntPtr hBitmap = IntPtr.Zero;
Add comment 333 Minus if (bmp != null)
Add comment 334 Minus {
Add comment 294 Plus if (bmp != null) {
Add comment 335 295 bmp.GetSharedBitmap(out hBitmap);
Add comment 336 296 retrieved = true;
Add comment 337 297
Add comment 341 301 Gdi32.NativeDraw(hdc, hBitmap, iconBounds.Left + (iconBounds.Right - iconBounds.Left - width) / 2, iconBounds.Top + (iconBounds.Bottom - iconBounds.Top - height) / 2, width, height, isHidden);
Add comment 342 302 Gdi32.DeleteObject(hBitmap);
Add comment 343 303 }
Add comment 344 Minus }
Add comment 345 Minus finally
Add comment 346 Minus {
Add comment 347 Minus if (bmp != null) Marshal.ReleaseComObject(bmp);
Add comment 304 Plus } finally {
Add comment 305 Plus if (bmp != null)
Add comment 306 Plus Marshal.ReleaseComObject(bmp);
Add comment 348 307 }
Add comment 349 308 return res;
Add comment 350 309 }
Add comment 351 310
Add comment 352 Minus public Bitmap GetBitmapFromHBitmap(IntPtr nativeHBitmap)
Add comment 353 Minus {
Add comment 354 Minus Bitmap bmp = Bitmap.FromHbitmap(nativeHBitmap);
Add comment 311 Plus public Bitmap GetBitmapFromHBitmap(IntPtr nativeHBitmap) {
Add comment 312 Plus Bitmap bmp = Image.FromHbitmap(nativeHBitmap);
Add comment 355 313
Add comment 356 Minus if (Bitmap.GetPixelFormatSize(bmp.PixelFormat) < 32) return bmp;
Add comment 314 Plus if (Image.GetPixelFormatSize(bmp.PixelFormat) < 32)
Add comment 315 Plus return bmp;
Add comment 357 316
Add comment 358 317 BitmapData bmpData;
Add comment 359 318
Add comment 360 Minus if (IsAlphaBitmap(bmp, out bmpData))
Add comment 361 Minus {
Add comment 319 Plus if (IsAlphaBitmap(bmp, out bmpData)) {
Add comment 362 320 Bitmap resBmp = GetlAlphaBitmapFromBitmapData(bmpData);
Add comment 363 321 bmpData = null;
Add comment 364 322 return resBmp;
Add comment 603 return shellItemArray;
Add comment 604 }
Add comment 605
Add comment 606 Minus public static System.Windows.DragDropEffects ToDropEffect(this IDataObject dataObject) {
Add comment 606 Plus public static System.Windows.DragDropEffects GetDropEffect(this IDataObject dataObject) {
Add comment 607 var dragDropEffect = System.Windows.DragDropEffects.Copy;
Add comment 608 if (dataObject.GetDataPresent("Preferred DropEffect")) {
Add comment 609 object data = dataObject.GetData("Preferred DropEffect", true);
Add comment 78 this.CheckedFroChilds.Clear();
Add comment 79 var favoritesItem = Utilities.WindowsVersion == WindowsVersions.Windows10
Add comment 80 ? FileSystemListItem.ToFileSystemItem(IntPtr.Zero, "shell:::{679f85cb-0220-4080-b29b-5540cc05aab6}")
Add comment 81 Minus : FileSystemListItem.ToFileSystemItem(IntPtr.Zero, ((ShellItem)KnownFolders.Favorites).Pidl);
Add comment 81 Plus : FileSystemListItem.ToFileSystemItem(IntPtr.Zero, ((ShellItem)KnownFolders.Links).Pidl);
Add comment 82 var favoritesRoot = new TreeNode(favoritesItem.DisplayName);
Add comment 83 favoritesRoot.Tag = favoritesItem;
Add comment 84 favoritesRoot.ImageIndex = favoritesItem.GetSystemImageListIndex(favoritesItem.PIDL, ShellIconType.SmallIcon, ShellIconFlags.OpenIcon);
Add comment 608 IShellItemArray items = null;
Add comment 609 if (dataObject.GetDataPresent("FileDrop")) {
Add comment 610 // TODO: Fix FileDorp option
Add comment 611 Minus // items = ((F.DataObject)dataObject).GetFileDropList().OfType<String>().Select(s => FileSystemListItem.ToFileSystemItem(IntPtr.Zero, s.ToShellParsingName()).ComInterface).ToArray();
Add comment 611 Plus //items = ((String[])dataObject.GetData("FileDrop")).Select(s => ShellItem.ToShellParsingName(s).ComInterface).ToArray();
Add comment 612 Plus //items = ((F.DataObject)dataObject).GetFileDropList().OfType<String>().Select(s => FileSystemListItem.ToFileSystemItem(IntPtr.Zero, s.ToShellParsingName()).ComInterface).ToArray();
Add comment 613 Plus } else if (dataObject.GetDataPresent("Shell IDList Array")) {
Add comment 614 Plus items = dataObject.ToShellItemArray();
Add comment 612 615 } else {
Add comment 613 Minus items = dataObject.ToShellItemArray();
Add comment 616 Plus return;
Add comment 614 617 }
Add comment 615 618
Add comment 616 619 try {
Add comment 617 620 var fo = new IIFileOperation(handle);
Add comment 618 Minus if (dataObject.ToDropEffect() == System.Windows.DragDropEffects.Copy) {
Add comment 621 Plus if (dataObject.GetDropEffect() == System.Windows.DragDropEffects.Copy) {
Add comment 619 622 fo.CopyItems(items, selectedItem);
Add comment 620 623 } else {
Add comment 621 624 fo.MoveItems(items, selectedItem);
Add comment 622 625 }
Add comment 623 626
Add comment 624 627 fo.PerformOperations();
Add comment 625 Minus } catch (SecurityException) {
Add comment 626 Minus throw;
Add comment 627 Minus }
Add comment 628 Plus } catch { }
Add comment 628 629 });
Add comment 629 630
Add comment 630 631 thread.SetApartmentState(ApartmentState.STA);