160 changed files
Shell1 | ||
_Plugin Interfaces | ||
FileSystemListItem.cs | ||
IListItemEx.cs | ||
VirtualFilesystemItem.cs | ||
Custom ContextMenus Remove Soon | ||
FilterMenu_Strings.cs | ||
FileOperation | ||
AsyncUnbuffCopy.cs | ||
CollisionDialog.xaml | ||
CollisionDialog.xaml.cs | ||
CollisionItem.cs | ||
DeleteNotificationDialog.xaml | ||
DeleteNotificationDialog.xaml.cs | ||
FileOperation.xaml | ||
FileOperation.xaml.cs | ||
FileOperationDialog.xaml | ||
FileOperationDialog.xaml.cs | ||
IIFileOperation.cs | ||
Groups | ||
ListViewGroupEx.cs | ||
LVGROUP.cs | ||
Interop | ||
BHID.cs | ||
ComCtl32.cs | ||
ComReleaser.cs | ||
Constants.cs | ||
CredUI.cs | ||
DefaultIconSize.cs | ||
Enums.cs | ||
EnumUnknownClass.cs | ||
FileIcon.cs | ||
FileOperationFlags.cs | ||
Gdi32.cs | ||
Helpers.cs | ||
HResult.cs | ||
IColumnProvider.cs | ||
IconReference.cs | ||
IContextMenu.cs | ||
IDropSource.cs | ||
IEnumIDList.cs | ||
IExtractIcon.cs | ||
IFileDialog.cs | ||
IFileOperation.cs | ||
IFileOperationProgressSink.cs | ||
IFileSystemBindData.cs | ||
IListView.cs | ||
INativeShellLibrary.cs | ||
IOperationsProgressDialog.cs | ||
IQueryInfo.cs | ||
ISearch.cs | ||
IServiceProvider.cs | ||
IShellBrowser.cs | ||
IShellFolder.cs | ||
IShellItem.cs | ||
IShellItem2.cs | ||
IShellItemArray.cs | ||
IShellLibrary.cs | ||
IShellView.cs | ||
IThumbnail.cs | ||
IThumbnailCache.cs | ||
IVisualProperties.cs | ||
Kernel32.cs | ||
KnownFoldersCOM.cs | ||
NativePoint.cs | ||
NativeWindowListener.cs | ||
Ole32.cs | ||
PropertySystemNativeMethods.cs | ||
PropVariant.cs | ||
PropVariantNativeMethods.cs | ||
Shell32.cs | ||
ShellItemArray.cs | ||
ShellItemImpl.cs | ||
ShellLink.cs | ||
ShellNotifications.cs | ||
ShellThumbnail.cs | ||
ShlWapi.cs | ||
User32.cs | ||
UxTheme.cs | ||
Wallpaper.cs | ||
WIC.zip | ||
WindowsThumbnailProvider.cs | ||
KnownFolders | ||
DefinitionOptions.cs | ||
FileSystemKnownFolder.cs | ||
FolderCategory.cs | ||
FolderProperties.cs | ||
FoldersIdentifiers.cs | ||
FolderTypes.cs | ||
IKnownFolder.cs | ||
KnownFolderHelper.cs | ||
KnownFolders.cs | ||
KnownFolderSettings.cs | ||
NonFileSystemKnownFolder.cs | ||
RedirectionCapabilities.cs | ||
Properties | ||
Annotations.cs | ||
AssemblyInfo.cs | ||
Resources.Designer.cs | ||
Resources.resx | ||
Resources | ||
Back.bmp | ||
Forward.bmp | ||
NewFolder.bmp | ||
Up.bmp | ||
Views.bmp | ||
VirtualGroups | ||
IOwnerDataCallback.cs | ||
VirtualGrouping.cs | ||
WindowsSearch | ||
SearchCondition.cs | ||
SearchConditionFactory.cs | ||
ShellSearchFolder.cs | ||
x64 | ||
SQLite.Interop.dll | ||
x86 | ||
SQLite.Interop.dll | ||
.upgrade-assistant | ||
app.config | ||
AssociationItem.cs | ||
Collumns.cs | ||
Defaults.cs | ||
DragDropHelper.cs | ||
Extensions.cs | ||
FileFilterComboBox.cs | ||
FileNameComboBox.cs | ||
FilesystemTreeViewItem.cs | ||
FilterItem.cs | ||
FolderSelectDialog.cs | ||
FolderSettings.cs | ||
GlobalSuppressions.cs | ||
ImageListEx.cs | ||
JunctionPoint.cs | ||
LeftMarginMultiplierConverter.cs | ||
ListViewEditor.cs | ||
LVItemColor.cs | ||
NavigationLog.cs | ||
ObjectToSeparatorBooleanConverter.cs | ||
ObservableCollectionEx.cs | ||
QueueEx.cs | ||
Reflector.cs | ||
Settings.sqlite | ||
Shell.csproj | ||
Shell.ruleset | ||
ShellComboBox.cs | ||
ShellContextMenu.cs | ||
ShellItem.cs | ||
ShellItemEqualityComparer.cs | ||
ShellLibrary.cs | ||
ShellNotificationListener.cs | ||
ShellTreeView.xaml | ||
ShellTreeView.xaml.cs | ||
ShellTreeViewEx.cs | ||
ShellTreeViewEx.Designer.cs | ||
ShellViewControl.xaml | ||
ShellViewControl.xaml.cs | ||
ShellViewEx.cs | ||
ShellViewEx.Designer.cs | ||
ShellViewEx.resx | ||
SyncQueue.cs | ||
SysImageList.cs | ||
SystemImageList.cs | ||
ThreadSafeListWithLock.cs | ||
ToolTip.xaml | ||
ToolTip.xaml.cs | ||
TooltipDataTemplateSelector.cs | ||
TreeViewBase.cs | ||
TreeViewHelper.cs | ||
TreeViewItemBehaviour.cs | ||
Utilities.cs | ||
video_addorner_wide.png | ||
video_addorner.png | ||
WindowActivator.cs | ||
FileSystemListItem.cs
/Shell1/_Plugin Interfaces/FileSystemListItem.cs-771/Shell1/_Plugin Interfaces/FileSystemListItem.cs
Displayed content is truncated due to maximum viewable content limit.
Add comment 1 Minus using System.Runtime.CompilerServices;
Add comment 2 Minus using System.IO;
Add comment 3 Minus using BExplorer.Shell.Interop;
Add comment 4 Minus using System;
Add comment 5 Minus using System.Collections.Generic;
Add comment 6 Minus using System.Runtime.InteropServices;
Add comment 7 Minus using System.Threading;
Add comment 8 Minus using System.Threading.Tasks;
Add comment 9 Minus using System.Windows.Media.Imaging;
Add comment 10 Minus using ThumbnailGenerator;
Add comment 11 Minus using Size = System.Drawing.Size;
Add comment 12 Minus using System.Text;
Add comment 13 Minus using System.Linq;
Add comment 14 Minus using System.Windows.Interop;
Add comment 15 Minus
Add comment 16 Minus namespace BExplorer.Shell._Plugin_Interfaces {
Add comment 17 Minus using System.Drawing;
Add comment 18 Minus using System.Windows.Media;
Add comment 19 Minus
Add comment 20 Minus /// <summary>
Add comment 21 Minus /// A representation of items on a standard physical/local file system
Add comment 22 Minus /// </summary>
Add comment 23 Minus public class FileSystemListItem : IListItemEx {
Add comment 24 Minus
Add comment 25 Minus #region Private Members
Add comment 26 Minus
Add comment 27 Minus /// <summary>The real item that is a wrapper for</summary>
Add comment 28 Minus private ShellItem _Item { get; set; }
Add comment 29 Minus
Add comment 30 Minus #endregion Private Members
Add comment 31 Minus
Add comment 32 Minus #region IListItemEx Members
Add comment 33 Minus
Add comment 34 Minus public IntPtr ParentPIDL { get; set; }
Add comment 35 Minus public IntPtr EnumPIDL { get; set; }
Add comment 36 Minus
Add comment 37 Minus /// <summary>The COM interface for this item</summary>
Add comment 38 Minus public IShellItem ComInterface => this.ParentPIDL == IntPtr.Zero
Add comment 39 Minus ? Shell32.SHCreateItemFromIDList(this.EnumPIDL, typeof(IShellItem).GUID)
Add comment 40 Minus : Shell32.SHCreateItemWithParent(this.ParentPIDL, null, this.EnumPIDL, typeof(IShellItem).GUID);
Add comment 41 Minus
Add comment 42 Minus /// <summary>The text that represents the display name</summary>
Add comment 43 Minus public String DisplayName {
Add comment 44 Minus get { return this.GetDisplayName(SIGDN.NORMALDISPLAY); }
Add comment 45 Minus }
Add comment 46 Minus
Add comment 47 Minus /// <summary>Does the current item need to be refreshed in the ShellListView</summary>
Add comment 48 Minus public Boolean IsNeedRefreshing { get; set; }
Add comment 49 Minus
Add comment 50 Minus /// <summary>Assigned values but never used</summary>
Add comment 51 Minus public Boolean IsInvalid { get; set; }
Add comment 52 Minus
Add comment 53 Minus public Boolean IsProcessed { get; set; }
Add comment 54 Minus
Add comment 55 Minus /// <summary>Changes how the item gets loaded</summary>
Add comment 56 Minus public Boolean IsOnlyLowQuality { get; set; }
Add comment 57 Minus
Add comment 58 Minus public Boolean IsThumbnailLoaded { get; set; }
Add comment 59 Minus
Add comment 60 Minus public Boolean IsInitialised { get; set; }
Add comment 61 Minus
Add comment 62 Minus public Int32 OverlayIconIndex { get; set; }
Add comment 63 Minus
Add comment 64 Minus private IExtractIconPWFlags _IconType = IExtractIconPWFlags.GIL_PERCLASS;
Add comment 65 Minus
Add comment 66 Minus public IExtractIconPWFlags IconType {
Add comment 67 Minus get { return this.GetIconType(); }
Add comment 68 Minus set { this._IconType = value; }
Add comment 69 Minus }
Add comment 70 Minus
Add comment 71 Minus public IExtractIconPWFlags GetIconType() {
Add comment 72 Minus if (this.IsFolder) {
Add comment 73 Minus IExtractIcon iextract = null;
Add comment 74 Minus IShellFolder ishellfolder = null;
Add comment 75 Minus StringBuilder str = null;
Add comment 76 Minus IntPtr result;
Add comment 77 Minus
Add comment 78 Minus try {
Add comment 79 Minus var guid = new Guid("000214fa-0000-0000-c000-000000000046");
Add comment 80 Minus UInt32 res = 0;
Add comment 81 Minus ishellfolder = this.Parent.GetIShellFolder();
Add comment 82 Minus var pidls = new IntPtr[1] { Shell32.ILFindLastID(this.PIDL) };
Add comment 83 Minus
Add comment 84 Minus ishellfolder.GetUIObjectOf(IntPtr.Zero, 1, pidls, ref guid, res, out result);
Add comment 85 Minus
Add comment 86 Minus if (result == IntPtr.Zero) {
Add comment 87 Minus pidls = null;
Add comment 88 Minus return IExtractIconPWFlags.GIL_PERCLASS;
Add comment 89 Minus }
Add comment 90 Minus iextract = (IExtractIcon)Marshal.GetTypedObjectForIUnknown(result, typeof(IExtractIcon));
Add comment 91 Minus str = new StringBuilder(512);
Add comment 92 Minus var index = -1;
Add comment 93 Minus IExtractIconPWFlags flags;
Add comment 94 Minus iextract.GetIconLocation(IExtractIconUFlags.GIL_ASYNC, str, 512, out index, out flags);
Add comment 95 Minus Marshal.ReleaseComObject(ishellfolder);
Add comment 96 Minus Marshal.ReleaseComObject(iextract);
Add comment 97 Minus return flags;
Add comment 98 Minus } catch (Exception) {
Add comment 99 Minus return 0;
Add comment 100 Minus }
Add comment 101 Minus } else {
Add comment 102 Minus var value = this.GetPropertyValue(SystemProperties.PerceivedType, typeof(PerceivedType))?.Value;
Add comment 103 Minus if (value != null) {
Add comment 104 Minus var perceivedType = (PerceivedType)value;
Add comment 105 Minus if (perceivedType == PerceivedType.Application) {
Add comment 106 Minus return IExtractIconPWFlags.GIL_PERINSTANCE;
Add comment 107 Minus } else {
Add comment 108 Minus return IExtractIconPWFlags.GIL_PERCLASS;
Add comment 109 Minus }
Add comment 110 Minus }
Add comment 111 Minus }
Add comment 112 Minus return IExtractIconPWFlags.GIL_PERCLASS;
Add comment 113 Minus //if (this.Extension.ToLowerInvariant() == ".exe" || this.Extension.ToLowerInvariant() == ".com" || this.Extension.ToLowerInvariant() == ".bat" || this.Extension.ToLowerInvariant() == ".msi" || this.Extension.ToLowerInvariant() == ".jar") {
Add comment 114 Minus // return IExtractIconPWFlags.GIL_PERINSTANCE;
Add comment 115 Minus //}
Add comment 116 Minus ////return IExtractIconPWFlags.GIL_PERCLASS;
Add comment 117 Minus //if (this.Parent == null) {
Add comment 118 Minus // return 0;
Add comment 119 Minus //}
Add comment 120 Minus
Add comment 121 Minus ////if (this.IsFolder) {
Add comment 122 Minus // IExtractIcon iextract = null;
Add comment 123 Minus // IShellFolder ishellfolder = null;
Add comment 124 Minus // StringBuilder str = null;
Add comment 125 Minus // IntPtr result;
Add comment 126 Minus
Add comment 127 Minus // try {
Add comment 128 Minus // var guid = new Guid("000214fa-0000-0000-c000-000000000046");
Add comment 129 Minus // uint res = 0;
Add comment 130 Minus // ishellfolder = this.Parent.GetIShellFolder();
Add comment 131 Minus // var pidls = new IntPtr[1] { Shell32.ILFindLastID(this.PIDL) };
Add comment 132 Minus
Add comment 133 Minus // ishellfolder.GetUIObjectOf(IntPtr.Zero, 1, pidls, ref guid, res, out result);
Add comment 134 Minus
Add comment 135 Minus // if (result == IntPtr.Zero) {
Add comment 136 Minus // pidls = null;
Add comment 137 Minus // return IExtractIconPWFlags.GIL_PERCLASS;
Add comment 138 Minus // }
Add comment 139 Minus // iextract = (IExtractIcon)Marshal.GetTypedObjectForIUnknown(result, typeof(IExtractIcon));
Add comment 140 Minus // str = new StringBuilder(512);
Add comment 141 Minus // var index = -1;
Add comment 142 Minus // IExtractIconPWFlags flags;
Add comment 143 Minus // iextract.GetIconLocation(IExtractIconUFlags.GIL_ASYNC, str, 512, out index, out flags);
Add comment 144 Minus // return flags;
Add comment 145 Minus // } catch (Exception) {
Add comment 146 Minus // return 0;
Add comment 147 Minus // }
Add comment 148 Minus ////} else {
Add comment 149 Minus //// return IExtractIconPWFlags.GIL_PERCLASS;
Add comment 150 Minus ////}
Add comment 151 Minus }
Add comment 152 Minus
Add comment 153 Minus public IntPtr ILPidl => Shell32.ILFindLastID(this.PIDL);
Add comment 154 Minus
Add comment 155 Minus public IntPtr PIDL {
Add comment 156 Minus get {
Add comment 157 Minus var comObject = this.ComInterface;
Add comment 158 Minus var result = comObject == null ? IntPtr.Zero : Shell32.SHGetIDListFromObject(comObject);
Add comment 159 Minus Marshal.FinalReleaseComObject(comObject);
Add comment 160 Minus return result;
Add comment 161 Minus }
Add comment 162 Minus }
Add comment 163 Minus
Add comment 164 Minus public IntPtr AbsolutePidl {
Add comment 165 Minus get {
Add comment 166 Minus UInt32 attr;
Add comment 167 Minus IntPtr pidl;
Add comment 168 Minus Shell32.SHParseDisplayName(this.ParsingName, IntPtr.Zero, out pidl, 0, out attr);
Add comment 169 Minus return pidl;
Add comment 170 Minus }
Add comment 171 Minus }
Add comment 172 Minus
Add comment 173 Minus /// <summary>Index of the ShieldedIcon</summary>
Add comment 174 Minus public Int32 ShieldedIconIndex { get; set; }
Add comment 175 Minus
Add comment 176 Minus /// <summary>Is this item's icon loaded yet?</summary>
Add comment 177 Minus public Boolean IsIconLoaded { get; set; }
Add comment 178 Minus
Add comment 179 Minus public String ParsingName {
Add comment 180 Minus get { return this.GetDisplayName(SIGDN.DESKTOPABSOLUTEPARSING); }
Add comment 181 Minus }
Add comment 182 Minus
Add comment 183 Minus /// <summary>The file system extension for this item</summary>
Add comment 184 Minus public String Extension => Path.GetExtension(this.ParsingName);
Add comment 185 Minus
Add comment 186 Minus /// <summary>The file system path</summary>
Add comment 187 Minus public String FileSystemPath => this.GetDisplayName(SIGDN.FILESYSPATH);
Add comment 188 Minus
Add comment 189 Minus /// <summary>
Add comment 190 Minus /// Returns true if folder can be browsed
Add comment 191 Minus /// </summary>
Add comment 192 Minus public Boolean IsBrowsable => this.COM_Attribute_Check(SFGAO.BROWSABLE);
Add comment 193 Minus
Add comment 194 Minus [MethodImpl(MethodImplOptions.AggressiveInlining)]
Add comment 195 Minus private Boolean COM_Attribute_Check(SFGAO Check) {
Add comment 196 Minus var comObject = this.ComInterface;
Add comment 197 Minus SFGAO sfgao;
Add comment 198 Minus comObject.GetAttributes(Check, out sfgao);
Add comment 199 Minus Marshal.FinalReleaseComObject(comObject);
Add comment 200 Minus this.Dispose();
Add comment 201 Minus return (sfgao & Check) != 0;
Add comment 202 Minus }
Add comment 203 Minus
Add comment 204 Minus /// <summary>Gets a value indicating whether this is a folder </summary>
Add comment 205 Minus public Boolean IsFolder {
Add comment 206 Minus get {
Add comment 207 Minus var comObject = this.ComInterface;
Add comment 208 Minus SFGAO sfgao;
Add comment 209 Minus comObject.GetAttributes(SFGAO.FOLDER, out sfgao);
Add comment 210 Minus SFGAO sfgao2;
Add comment 211 Minus comObject.GetAttributes(SFGAO.STREAM, out sfgao2);
Add comment 212 Minus Marshal.FinalReleaseComObject(comObject);
Add comment 213 Minus return sfgao != 0 && sfgao2 == 0;
Add comment 214 Minus }
Add comment 215 Minus }
Add comment 216 Minus
Add comment 217 Minus /// <summary>Does this have folders?</summary>
Add comment 218 Minus public Boolean HasSubFolders => this.COM_Attribute_Check(SFGAO.HASSUBFOLDER);
Add comment 219 Minus
Add comment 220 Minus /// <summary>Is this item normally hidden?</summary>
Add comment 221 Minus public Boolean IsHidden => this.COM_Attribute_Check(SFGAO.HIDDEN);
Add comment 222 Minus
Add comment 223 Minus public Boolean IsFileSystem => this.COM_Attribute_Check(SFGAO.FILESYSTEM);
Add comment 224 Minus
Add comment 225 Minus public Boolean IsNetworkPath => Shell32.PathIsNetworkPath(this.ParsingName);
Add comment 226 Minus
Add comment 227 Minus /// <summary>Is current item represent a system drive?</summary>
Add comment 228 Minus public Boolean IsDrive {
Add comment 229 Minus get {
Add comment 230 Minus try {
Add comment 231 Minus return Directory.GetLogicalDrives().Contains(this.ParsingName) && Kernel32.GetDriveType(this.ParsingName) != DriveType.Network;
Add comment 232 Minus } catch {
Add comment 233 Minus return false;
Add comment 234 Minus }
Add comment 235 Minus }
Add comment 236 Minus }
Add comment 237 Minus
Add comment 238 Minus public Boolean IsShared => this.COM_Attribute_Check(SFGAO.SHARE);
Add comment 239 Minus
Add comment 240 Minus public Boolean IsSlow => this.COM_Attribute_Check(SFGAO.ISSLOW);
Add comment 241 Minus
Add comment 242 Minus /// <summary>Is the parent a search folder?</summary>
Add comment 243 Minus public Boolean IsParentSearchFolder { get; set; }
Add comment 244 Minus
Add comment 245 Minus public Int32 GroupIndex { get; set; }
Add comment 246 Minus
Add comment 247 Minus public Int32 RCWThread { get; set; }
Add comment 248 Minus
Add comment 249 Minus public IShellFolder IFolder { get; set; }
Add comment 250 Minus
Add comment 251 Minus private void Initialize_Helper(IntPtr folder, IntPtr lvHandle, Int32 index) {
Add comment 252 Minus this.ParentPIDL = IntPtr.Zero;
Add comment 253 Minus this.EnumPIDL = folder;
Add comment 254 Minus //this.ParentHandle = lvHandle;
Add comment 255 Minus this.OverlayIconIndex = -1;
Add comment 256 Minus this.ShieldedIconIndex = -1;
Add comment 257 Minus }
Add comment 258 Minus
Add comment 259 Minus private void Initialize_Helper2(IntPtr parent, IntPtr pidl, IntPtr lvHandle, Int32 index) {
Add comment 260 Minus this.ParentPIDL = parent;
Add comment 261 Minus this.EnumPIDL = pidl;
Add comment 262 Minus //this.ParentHandle = lvHandle;
Add comment 263 Minus this.OverlayIconIndex = -1;
Add comment 264 Minus this.ShieldedIconIndex = -1;
Add comment 265 Minus }
Add comment 266 Minus
Add comment 267 Minus public void Initialize(IntPtr lvHandle, IntPtr pidl, Int32 index) {
Add comment 268 Minus this.Initialize_Helper(pidl, lvHandle, index);
Add comment 269 Minus }
Add comment 270 Minus
Add comment 271 Minus public void InitializeWithParent(IntPtr parent, IntPtr lvHandle, IntPtr pidl, Int32 index) {
Add comment 272 Minus this.Initialize_Helper2(parent, pidl, lvHandle, index);
Add comment 273 Minus }
Add comment 274 Minus
Add comment 275 Minus public void InitializeWithShellItem(ShellSearchFolder item, IntPtr lvHandle, Int32 index) {
Add comment 276 Minus this.Initialize_Helper(item.Pidl, lvHandle, index);
Add comment 277 Minus this.searchFolder = item;
Add comment 278 Minus }
Add comment 279 Minus
Add comment 280 Minus public ShellSearchFolder searchFolder { get; set; }
Add comment 281 Minus
Add comment 282 Minus public Dictionary<PROPERTYKEY, Object> ColumnValues { get; set; }
Add comment 283 Minus
Add comment 284 Minus public Int32 ItemIndex { get; set; }
Add comment 285 Minus
Add comment 286 Minus public IntPtr ParentHandle { get; set; }
Add comment 287 Minus
Add comment 288 Minus public static IListItemEx InitializeWithIShellItem(IntPtr lvHandle, IShellItem item) {
Add comment 289 Minus var fsItem = new FileSystemListItem();
Add comment 290 Minus fsItem.Initialize(lvHandle, Shell32.SHGetIDListFromObject(item), 0);
Add comment 291 Minus return fsItem;
Add comment 292 Minus }
Add comment 293 Minus
Add comment 294 Minus public void Initialize(IntPtr lvHandle, String path, Int32 index) {
Add comment 295 Minus var shellItem = Shell32.SHCreateItemFromParsingName(path, IntPtr.Zero, typeof(IShellItem).GUID);
Add comment 296 Minus this.ParentPIDL = IntPtr.Zero;
Add comment 297 Minus this.EnumPIDL = Shell32.SHGetIDListFromObject(shellItem);
Add comment 298 Minus Marshal.ReleaseComObject(shellItem);
Add comment 299 Minus //this.ParentHandle = lvHandle;
Add comment 300 Minus
Add comment 301 Minus this.OverlayIconIndex = -1;
Add comment 302 Minus this.ShieldedIconIndex = -1;
Add comment 303 Minus }
Add comment 304 Minus
Add comment 305 Minus public void Initialize(IntPtr lvHandle, String path) {
Add comment 306 Minus throw new NotImplementedException();
Add comment 307 Minus }
Add comment 308 Minus
Add comment 309 Minus public void Initialize(IntPtr lvHandle, IntPtr pidl) {
Add comment 310 Minus throw new NotImplementedException();
Add comment 311 Minus }
Add comment 312 Minus
Add comment 313 Minus public FileSystemListItem() {
Add comment 314 Minus this.GroupIndex = -1;
Add comment 315 Minus this.ItemIndex = -1;
Add comment 316 Minus this.IconIndex = -1;
Add comment 317 Minus this.ColumnValues = new Dictionary<PROPERTYKEY, Object>();
Add comment 318 Minus }
Add comment 319 Minus
Add comment 320 Minus public HResult NavigationStatus { get; set; }
Add comment 321 Minus
Add comment 322 Minus public Size IconSize { get; set; }
Add comment 323 Minus
Add comment 324 Minus public IEnumerable<IntPtr> GetItemsForCount(Boolean isEnumHidden) {
Add comment 325 Minus var folder = this.GetIShellFolder();
Add comment 326 Minus if (folder == null) {
Add comment 327 Minus yield return IntPtr.Zero;
Add comment 328 Minus }
Add comment 329 Minus
Add comment 330 Minus HResult navRes;
Add comment 331 Minus var flags = SHCONTF.FOLDERS | SHCONTF.FASTITEMS | SHCONTF.NONFOLDERS | SHCONTF.ENABLE_ASYNC | SHCONTF.INIT_ON_FIRST_NEXT;
Add comment 332 Minus if (isEnumHidden) {
Add comment 333 Minus flags = SHCONTF.FOLDERS | SHCONTF.INCLUDEHIDDEN | SHCONTF.INCLUDESUPERHIDDEN | SHCONTF.FASTITEMS | SHCONTF.NONFOLDERS | SHCONTF.ENABLE_ASYNC | SHCONTF.INIT_ON_FIRST_NEXT;
Add comment 334 Minus }
Add comment 335 Minus var enumId = ShellItem.GetIEnumIDList(folder, flags, out navRes);
Add comment 336 Minus this.NavigationStatus = navRes;
Add comment 337 Minus UInt32 count;
Add comment 338 Minus IntPtr pidl;
Add comment 339 Minus
Add comment 340 Minus if (enumId == null) {
Add comment 341 Minus yield break;
Add comment 342 Minus }
Add comment 343 Minus
Add comment 344 Minus var result = enumId.Next(1, out pidl, out count);
Add comment 345 Minus while (result == HResult.S_OK) {
Add comment 346 Minus yield return pidl;
Add comment 347 Minus Shell32.ILFree(pidl);
Add comment 348 Minus result = enumId.Next(1, out pidl, out count);
Add comment 349 Minus }
Add comment 350 Minus
Add comment 351 Minus if (folder != null) {
Add comment 352 Minus Marshal.ReleaseComObject(folder);
Add comment 353 Minus }
Add comment 354 Minus if (result != HResult.S_FALSE) {
Add comment 355 Minus //Marshal.ThrowExceptionForHR((int)result);
Add comment 356 Minus }
Add comment 357 Minus yield break;
Add comment 358 Minus }
Add comment 359 Minus
Add comment 360 Minus public IEnumerable<IListItemEx> GetContents(Boolean isEnumHidden, Boolean isFlatList = false) {
Add comment 361 Minus var folder = this.GetIShellFolder();
Add comment 362 Minus if (folder == null) {
Add comment 363 Minus yield return null;
Add comment 364 Minus }
Add comment 365 Minus
Add comment 366 Minus HResult navRes;
Add comment 367 Minus var flags = SHCONTF.FOLDERS | SHCONTF.NONFOLDERS | SHCONTF.CHECKING_FOR_CHILDREN | SHCONTF.ENABLE_ASYNC;
Add comment 368 Minus if (isEnumHidden) {
Add comment 369 Minus flags = SHCONTF.FOLDERS | SHCONTF.INCLUDEHIDDEN | SHCONTF.INCLUDESUPERHIDDEN | SHCONTF.NONFOLDERS | SHCONTF.CHECKING_FOR_CHILDREN | SHCONTF.ENABLE_ASYNC;
Add comment 370 Minus }
Add comment 371 Minus
Add comment 372 Minus //if (isFlatList) {
Add comment 373 Minus // flags = SHCONTF.NONFOLDERS | SHCONTF.CHECKING_FOR_CHILDREN | SHCONTF.ENABLE_ASYNC | SHCONTF.SFLATLIST | SHCONTF.NAVIGATION_ENUM;
Add comment 374 Minus //}
Add comment 375 Minus
Add comment 376 Minus var enumId = ShellItem.GetIEnumIDList(folder, flags, out navRes);
Add comment 377 Minus this.NavigationStatus = navRes;
Add comment 378 Minus UInt32 count;
Add comment 379 Minus IntPtr pidl;
Add comment 380 Minus if (enumId == null) {
Add comment 381 Minus yield break;
Add comment 382 Minus }
Add comment 383 Minus
Add comment 384 Minus var result = enumId.Next(1, out pidl, out count);
Add comment 385 Minus var i = 0;
Add comment 386 Minus while (result == HResult.S_OK) {
Add comment 387 Minus //var sb = new StringBuilder(512);
Add comment 388 Minus //Shell32.SHGetPathFromIDList(pidl, sb);
Add comment 389 Minus //var ext = Path.GetExtension(sb.ToString());
Add comment 390 Minus var fsi = new FileSystemListItem();
Add comment 391 Minus try {
Add comment 392 Minus fsi.InitializeWithParent(this.PIDL, this.ParentHandle, pidl, i++);
Add comment 393 Minus } catch {
Add comment 394 Minus continue;
Add comment 395 Minus }
Add comment 396 Minus if (fsi.IsFolder && isFlatList) {
Add comment 397 Minus foreach (var child in fsi.GetContents(true, true)) {
Add comment 398 Minus yield return child;
Add comment 399 Minus }
Add comment 400 Minus }
Add comment 401 Minus fsi.IsParentSearchFolder = this.IsSearchFolder;
Add comment 402 Minus fsi.Dispose();
Add comment 403 Minus yield return fsi;
Add comment 404 Minus //Shell32.ILFree(pidl);
Add comment 405 Minus result = enumId.Next(1, out pidl, out count);
Add comment 406 Minus }
Add comment 407 Minus
Add comment 408 Minus if (folder != null) {
Add comment 409 Minus Marshal.ReleaseComObject(folder);
Add comment 410 Minus }
Add comment 411 Minus
Add comment 412 Minus if (result != HResult.S_FALSE) {
Add comment 413 Minus //Marshal.ThrowExceptionForHR((int)result);
Add comment 414 Minus }
Add comment 415 Minus
Add comment 416 Minus //parentItem.Dispose();
Add comment 417 Minus yield break;
Add comment 418 Minus }
Add comment 419 Minus
Add comment 420 Minus public IEnumerator<IListItemEx> GetEnumerator() {
Add comment 421 Minus var folder = this.GetIShellFolder();
Add comment 422 Minus if (folder == null) {
Add comment 423 Minus yield return null;
Add comment 424 Minus }
Add comment 425 Minus
Add comment 426 Minus HResult navRes;
Add comment 427 Minus var flags = SHCONTF.FOLDERS | SHCONTF.INCLUDEHIDDEN | SHCONTF.INCLUDESUPERHIDDEN | SHCONTF.FASTITEMS | SHCONTF.NONFOLDERS | SHCONTF.ENABLE_ASYNC | SHCONTF.INIT_ON_FIRST_NEXT;
Add comment 428 Minus var enumId = ShellItem.GetIEnumIDList(folder, flags, out navRes);
Add comment 429 Minus this.NavigationStatus = navRes;
Add comment 430 Minus UInt32 count;
Add comment 431 Minus IntPtr pidl;
Add comment 432 Minus
Add comment 433 Minus if (enumId == null) {
Add comment 434 Minus yield break;
Add comment 435 Minus }
Add comment 436 Minus
Add comment 437 Minus var result = enumId.Next(1, out pidl, out count);
Add comment 438 Minus var i = 0;
Add comment 439 Minus while (result == HResult.S_OK) {
Add comment 440 Minus var fsi = new FileSystemListItem();
Add comment 441 Minus try {
Add comment 442 Minus fsi.InitializeWithParent(this.PIDL, this.ParentHandle, pidl, i++);
Add comment 443 Minus } catch {
Add comment 444 Minus continue;
Add comment 445 Minus }
Add comment 446 Minus
Add comment 447 Minus fsi.IsParentSearchFolder = this.IsSearchFolder;
Add comment 448 Minus fsi.Dispose();
Add comment 449 Minus yield return fsi;
Add comment 450 Minus result = enumId.Next(1, out pidl, out count);
Add comment 451 Minus }
Add comment 452 Minus
Add comment 453 Minus if (folder != null) {
Add comment 454 Minus Marshal.ReleaseComObject(folder);
Add comment 455 Minus }
Add comment 456 Minus
Add comment 457 Minus if (result != HResult.S_FALSE) {
Add comment 458 Minus //Marshal.ThrowExceptionForHR((int)result);
Add comment 459 Minus }
Add comment 460 Minus yield break;
Add comment 461 Minus }
Add comment 462 Minus
Add comment 463 Minus System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => this.GetEnumerator();
Add comment 464 Minus
Add comment 465 Minus public PropVariant GetPropertyValue(PROPERTYKEY pkey, Type type) {
Add comment 466 Minus var pvar = new PropVariant();
Add comment 467 Minus var comObject = this.ComInterface;
Add comment 468 Minus var isi2 = (IShellItem2)comObject;
Add comment 469 Minus if (isi2 == null) {
Add comment 470 Minus return PropVariant.FromObject(null);
Add comment 471 Minus }
Add comment 472 Minus
Add comment 473 Minus isi2.GetProperty(ref pkey, pvar);
Add comment 474 Minus Marshal.ReleaseComObject(comObject);
Add comment 475 Minus this.Dispose();
Add comment 476 Minus return pvar;
Add comment 477 Minus }
Add comment 478 Minus
Add comment 479 Minus public System.Drawing.Bitmap Thumbnail(Int32 size, ShellThumbnailFormatOption format, ShellThumbnailRetrievalOption source) => this._Item?.GetShellThumbnail(size, format, source);
Add comment 480 Minus
Add comment 481 Minus public BitmapSource ThumbnailBitmapSource => this.ThumbnailSource(16, ShellThumbnailFormatOption.IconOnly, ShellThumbnailRetrievalOption.Default);
Add comment 482 Minus
Add comment 483 Minus public BitmapSource ThumbnailSource(Int32 size, ShellThumbnailFormatOption format, ShellThumbnailRetrievalOption source) {
Add comment 484 Minus var hBitmap = this.GetHBitmap(size, format == ShellThumbnailFormatOption.ThumbnailOnly, source == ShellThumbnailRetrievalOption.Default, format == ShellThumbnailFormatOption.Default);
Add comment 485 Minus
Add comment 486 Minus // return a System.Media.Imaging.BitmapSource
Add comment 487 Minus // Use interop to create a BitmapSource from hBitmap.
Add comment 488 Minus if (hBitmap == IntPtr.Zero) {
Add comment 489 Minus return null;
Add comment 490 Minus }
Add comment 491 Minus
Add comment 492 Minus var returnValue = Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()).Clone();
Add comment 493 Minus //returnValue.Freeze();
Add comment 494 Minus // delete HBitmap to avoid memory leaks
Add comment 495 Minus Gdi32.DeleteObject(hBitmap);
Add comment 496 Minus this.Dispose();
Add comment 497 Minus return returnValue;
Add comment 498 Minus }
Add comment 499 Minus
IListItemEx.cs
/Shell1/_Plugin Interfaces/IListItemEx.cs-177/Shell1/_Plugin Interfaces/IListItemEx.cs
Add comment 1 Minus using System;
Add comment 2 Minus using System.Collections.Generic;
Add comment 3 Minus using System.Drawing;
Add comment 4 Minus using System.IO;
Add comment 5 Minus using System.Windows.Media.Imaging;
Add comment 6 Minus using BExplorer.Shell.Interop;
Add comment 7 Minus using Size = System.Drawing.Size;
Add comment 8 Minus
Add comment 9 Minus namespace BExplorer.Shell._Plugin_Interfaces {
Add comment 10 Minus
Add comment 11 Minus public interface IListItemEx : IEnumerable<IListItemEx>, IEquatable<IListItemEx>, IEqualityComparer<IListItemEx> {
Add comment 12 Minus
Add comment 13 Minus IntPtr ParentPIDL { get; set; }
Add comment 14 Minus
Add comment 15 Minus IntPtr EnumPIDL { get; set; }
Add comment 16 Minus
Add comment 17 Minus IExtractIconPWFlags GetIconType();
Add comment 18 Minus
Add comment 19 Minus /// <summary>The COM interface for this item</summary>
Add comment 20 Minus IShellItem ComInterface { get; }
Add comment 21 Minus
Add comment 22 Minus /// <summary>The logical parent for this item</summary>
Add comment 23 Minus IListItemEx Parent { get; }
Add comment 24 Minus
Add comment 25 Minus /// <summary>The text that represents the display name</summary>
Add comment 26 Minus String DisplayName { get; }
Add comment 27 Minus
Add comment 28 Minus /// <summary>The file system extension for this item</summary>
Add comment 29 Minus String Extension { get; }
Add comment 30 Minus
Add comment 31 Minus /// <summary>The file system path</summary>
Add comment 32 Minus String FileSystemPath { get; }
Add comment 33 Minus
Add comment 34 Minus Int32 ItemIndex { get; set; }
Add comment 35 Minus
Add comment 36 Minus /// <summary>I think we can remove this and just use this.Parent.PIDL. This property's role is confusing because of how its used</summary>
Add comment 37 Minus IntPtr ParentHandle { get; set; }
Add comment 38 Minus
Add comment 39 Minus /// <summary>Does the current item need to be refreshed in the ShellListView</summary>
Add comment 40 Minus Boolean IsNeedRefreshing { get; set; }
Add comment 41 Minus
Add comment 42 Minus /// <summary>Assigned values but never used</summary>
Add comment 43 Minus Boolean IsInvalid { get; set; }
Add comment 44 Minus
Add comment 45 Minus Boolean IsProcessed { get; set; }
Add comment 46 Minus
Add comment 47 Minus
Add comment 48 Minus /// <summary>Changes how the item gets loaded</summary>
Add comment 49 Minus Boolean IsOnlyLowQuality { get; set; }
Add comment 50 Minus
Add comment 51 Minus
Add comment 52 Minus Boolean IsThumbnailLoaded { get; set; }
Add comment 53 Minus
Add comment 54 Minus /// <summary>Set but never used</summary>
Add comment 55 Minus Boolean IsInitialised { get; set; } //TODO: Use this property or delete it
Add comment 56 Minus
Add comment 57 Minus /// <summary>The Index of the Icon (Double Check)</summary>
Add comment 58 Minus Int32 OverlayIconIndex { get; set; }
Add comment 59 Minus
Add comment 60 Minus Int32 GroupIndex { get; set; }
Add comment 61 Minus
Add comment 62 Minus /// <summary>Set but never used</summary>
Add comment 63 Minus Int32 IconIndex { get; set; } //TODO: Use this property or delete it
Add comment 64 Minus
Add comment 65 Minus Size IconSize { get; set; }
Add comment 66 Minus
Add comment 67 Minus IExtractIconPWFlags IconType { get; set; }
Add comment 68 Minus
Add comment 69 Minus IntPtr ILPidl { get; }
Add comment 70 Minus
Add comment 71 Minus IntPtr PIDL { get; }
Add comment 72 Minus
Add comment 73 Minus /// <summary>Not Used</summary>
Add comment 74 Minus IShellFolder IFolder { get; set; } //TODO: Use this property or delete it
Add comment 75 Minus
Add comment 76 Minus /// <summary>Index of the ShieldedIcon</summary>
Add comment 77 Minus Int32 ShieldedIconIndex { get; set; }
Add comment 78 Minus
Add comment 79 Minus /// <summary>Is this item's icon loaded yet?</summary>
Add comment 80 Minus Boolean IsIconLoaded { get; set; }
Add comment 81 Minus
Add comment 82 Minus Boolean IsFileSystem { get; }
Add comment 83 Minus
Add comment 84 Minus Boolean IsNetworkPath { get; }
Add comment 85 Minus
Add comment 86 Minus /// <summary>Is current item represent a system drive?</summary>
Add comment 87 Minus Boolean IsDrive { get; }
Add comment 88 Minus
Add comment 89 Minus /// <summary>Is the current item a search folder?</summary>
Add comment 90 Minus Boolean IsSearchFolder { get; }
Add comment 91 Minus
Add comment 92 Minus /// <summary>Implemented but never used</summary>
Add comment 93 Minus Bitmap Thumbnail(Int32 size, ShellThumbnailFormatOption format, ShellThumbnailRetrievalOption source);
Add comment 94 Minus
Add comment 95 Minus /// <summary>Gets the item's BitmapSource</summary>
Add comment 96 Minus BitmapSource ThumbnailSource(Int32 size, ShellThumbnailFormatOption format, ShellThumbnailRetrievalOption source);
Add comment 97 Minus
Add comment 98 Minus /// <summary>Implemented but never used</summary>
Add comment 99 Minus BitmapSource BitmapSource { get; }
Add comment 100 Minus
Add comment 101 Minus String ParsingName { get; }
Add comment 102 Minus
Add comment 103 Minus Boolean IsBrowsable { get; }
Add comment 104 Minus
Add comment 105 Minus /// <summary>Is this a folder?</summary>
Add comment 106 Minus Boolean IsFolder { get; }
Add comment 107 Minus
Add comment 108 Minus /// <summary>Does this have folders?</summary>
Add comment 109 Minus Boolean HasSubFolders { get; }
Add comment 110 Minus
Add comment 111 Minus /// <summary>Is this item normally hidden?</summary>
Add comment 112 Minus Boolean IsHidden { get; }
Add comment 113 Minus
Add comment 114 Minus Boolean IsLink { get; }
Add comment 115 Minus
Add comment 116 Minus Boolean IsShared { get; }
Add comment 117 Minus Boolean IsSlow { get; }
Add comment 118 Minus
Add comment 119 Minus /// <summary>We should remove this and use this.Parent.IsSearchFolder</summary>
Add comment 120 Minus Boolean IsParentSearchFolder { get; set; }
Add comment 121 Minus
Add comment 122 Minus void Initialize(IntPtr lvHandle, String path);
Add comment 123 Minus
Add comment 124 Minus void Initialize(IntPtr lvHandle, String path, Int32 index);
Add comment 125 Minus
Add comment 126 Minus void Initialize(IntPtr lvHandle, IntPtr pidl, int index);
Add comment 127 Minus
Add comment 128 Minus void Initialize(IntPtr lvHandle, IntPtr pidl);
Add comment 129 Minus
Add comment 130 Minus void InitializeWithParent(IntPtr parent, IntPtr lvHandle, IntPtr pidl, int index);
Add comment 131 Minus
Add comment 132 Minus IListItemEx Clone(Boolean isHardCloning = false);
Add comment 133 Minus
Add comment 134 Minus PropVariant GetPropertyValue(PROPERTYKEY pkey, Type type);
Add comment 135 Minus
Add comment 136 Minus Dictionary<PROPERTYKEY, Object> ColumnValues { get; set; }
Add comment 137 Minus
Add comment 138 Minus IEnumerable<IntPtr> GetItemsForCount(Boolean isEnumHidden);
Add comment 139 Minus
Add comment 140 Minus IEnumerable<IListItemEx> GetContents(Boolean isEnumHidden, Boolean isFlatList = false);
Add comment 141 Minus
Add comment 142 Minus IShellFolder GetIShellFolder();
Add comment 143 Minus
Add comment 144 Minus String ToolTipText { get; }
Add comment 145 Minus
Add comment 146 Minus IntPtr AbsolutePidl { get; }
Add comment 147 Minus
Add comment 148 Minus /// <summary>Returns drive information</summary>
Add comment 149 Minus DriveInfo GetDriveInfo();
Add comment 150 Minus
Add comment 151 Minus Boolean IsRCWSet { get; set; }
Add comment 152 Minus
Add comment 153 Minus Int32 RCWThread { get; set; }
Add comment 154 Minus
Add comment 155 Minus HResult ExtractAndDrawThumbnail(IntPtr hdc, uint iconSize, out WTS_CACHEFLAGS flags, User32.RECT iconBounds, out bool retrieved, bool isHidden, bool isRefresh = false); //TODO: Use or Delete
Add comment 156 Minus
Add comment 157 Minus HResult NavigationStatus { get; set; }
Add comment 158 Minus
Add comment 159 Minus IntPtr GetHBitmap(int iconSize, bool isThumbnail, bool isForce = false, bool isBoth = false);
Add comment 160 Minus
Add comment 161 Minus Boolean RefreshThumb(int iconSize, out WTS_CACHEFLAGS flags);
Add comment 162 Minus
Add comment 163 Minus String GetDisplayName(SIGDN type);
Add comment 164 Minus
Add comment 165 Minus IExtractIconPWFlags GetShield();
Add comment 166 Minus
Add comment 167 Minus int GetSystemImageListIndex(IntPtr pidl, ShellIconType type, ShellIconFlags flags);
Add comment 168 Minus
Add comment 169 Minus int GetUniqueID();
Add comment 170 Minus
Add comment 171 Minus int[] cColumns { get; set; }
Add comment 172 Minus
Add comment 173 Minus void Dispose();
Add comment 174 Minus
Add comment 175 Minus }
Add comment 176 Minus }
Add comment 177 Minus
VirtualFilesystemItem.cs
/Shell1/_Plugin Interfaces/VirtualFilesystemItem.cs-257/Shell1/_Plugin Interfaces/VirtualFilesystemItem.cs
Add comment 1 Minus using System;
Add comment 2 Minus using System.Collections;
Add comment 3 Minus using System.Collections.Generic;
Add comment 4 Minus using System.Drawing;
Add comment 5 Minus using System.IO;
Add comment 6 Minus using System.Runtime.InteropServices;
Add comment 7 Minus using System.Runtime.InteropServices.ComTypes;
Add comment 8 Minus using System.Windows.Media.Imaging;
Add comment 9 Minus using BExplorer.Shell.Interop;
Add comment 10 Minus
Add comment 11 Minus namespace BExplorer.Shell._Plugin_Interfaces {
Add comment 12 Minus
Add comment 13 Minus public class VirtualFilesystemItem : IListItemEx, IFileSystemBindData, IDisposable {
Add comment 14 Minus protected WIN32_FIND_DATA _fd;
Add comment 15 Minus
Add comment 16 Minus //private VirtualFilesystemItem(ref WIN32_FIND_DATA pfd) { _fd = pfd; }
Add comment 17 Minus
Add comment 18 Minus public VirtualFilesystemItem(String path, System.IO.FileAttributes attributes) {
Add comment 19 Minus this._fd = new WIN32_FIND_DATA() {
Add comment 20 Minus dwFileAttributes = (uint)attributes
Add comment 21 Minus };
Add comment 22 Minus
Add comment 23 Minus this.CreateSimplePidl(path);
Add comment 24 Minus }
Add comment 25 Minus
Add comment 26 Minus public void GetFileData([MarshalAs(UnmanagedType.Struct), Out] out WIN32_FIND_DATA pdf) {
Add comment 27 Minus pdf = _fd;
Add comment 28 Minus }
Add comment 29 Minus
Add comment 30 Minus public void SetFileData([In, MarshalAs(UnmanagedType.Struct)] ref WIN32_FIND_DATA pfd) {
Add comment 31 Minus _fd = pfd;
Add comment 32 Minus }
Add comment 33 Minus
Add comment 34 Minus void CreateBindCtx(out IBindCtx pbc) {
Add comment 35 Minus System.Runtime.InteropServices.ComTypes.BIND_OPTS bo = new System.Runtime.InteropServices.ComTypes.BIND_OPTS() {
Add comment 36 Minus cbStruct = Marshal.SizeOf(typeof(System.Runtime.InteropServices.ComTypes.BIND_OPTS)),
Add comment 37 Minus dwTickCountDeadline = 0,
Add comment 38 Minus grfFlags = 0,
Add comment 39 Minus grfMode = Shell32.STGM_CREATE
Add comment 40 Minus };
Add comment 41 Minus try {
Add comment 42 Minus Ole32.CreateBindCtx(0, out pbc);
Add comment 43 Minus pbc.SetBindOptions(ref bo);
Add comment 44 Minus pbc.RegisterObjectParam(Shell32.STR_FILE_SYS_BIND_DATA, this);
Add comment 45 Minus } catch {
Add comment 46 Minus pbc = null;
Add comment 47 Minus throw;
Add comment 48 Minus }
Add comment 49 Minus }
Add comment 50 Minus
Add comment 51 Minus void CreateSimplePidl(string path) {
Add comment 52 Minus IBindCtx pbc;
Add comment 53 Minus IntPtr ppidl = IntPtr.Zero;
Add comment 54 Minus uint sfgao;
Add comment 55 Minus this.CreateBindCtx(out pbc);
Add comment 56 Minus Shell32.SHParseDisplayName(path, pbc, out ppidl, 0, out sfgao);
Add comment 57 Minus this.EnumPIDL = ppidl;
Add comment 58 Minus }
Add comment 59 Minus
Add comment 60 Minus public IShellFolder GetParent(ref IntPtr pidl) {
Add comment 61 Minus Guid iid = typeof(IShellFolder).GUID;
Add comment 62 Minus IShellFolder ppv;
Add comment 63 Minus Shell32.SHBindToParent(this.EnumPIDL, ref iid, out ppv, out pidl);
Add comment 64 Minus return ppv;
Add comment 65 Minus }
Add comment 66 Minus
Add comment 67 Minus bool _disposed = false;
Add comment 68 Minus public IntPtr ParentPIDL { get; set; }
Add comment 69 Minus public IntPtr EnumPIDL { get; set; }
Add comment 70 Minus public IExtractIconPWFlags GetIconType() {
Add comment 71 Minus throw new NotImplementedException();
Add comment 72 Minus }
Add comment 73 Minus
Add comment 74 Minus public IShellItem ComInterface {
Add comment 75 Minus get {
Add comment 76 Minus object item = null;
Add comment 77 Minus Guid iid = typeof(IShellItem).GUID;
Add comment 78 Minus Shell32.SHCreateItemFromIDList(this.EnumPIDL, ref iid, out item);
Add comment 79 Minus return (IShellItem)item;
Add comment 80 Minus }
Add comment 81 Minus }
Add comment 82 Minus
Add comment 83 Minus public IListItemEx Parent {
Add comment 84 Minus get {
Add comment 85 Minus Guid iid = typeof(IShellFolder).GUID;
Add comment 86 Minus IntPtr pidl = IntPtr.Zero;
Add comment 87 Minus IShellFolder ppv;
Add comment 88 Minus Shell32.SHBindToParent(this.EnumPIDL, ref iid, out ppv, out pidl);
Add comment 89 Minus this.ParentPIDL = pidl;
Add comment 90 Minus var parent = new FileSystemListItem();
Add comment 91 Minus parent.Initialize(IntPtr.Zero, pidl);
Add comment 92 Minus return parent;
Add comment 93 Minus }
Add comment 94 Minus }
Add comment 95 Minus
Add comment 96 Minus public String DisplayName { get; }
Add comment 97 Minus public String Extension { get; }
Add comment 98 Minus public String FileSystemPath { get; }
Add comment 99 Minus public Int32 ItemIndex { get; set; }
Add comment 100 Minus public IntPtr ParentHandle { get; set; }
Add comment 101 Minus public Boolean IsNeedRefreshing { get; set; }
Add comment 102 Minus public Boolean IsInvalid { get; set; }
Add comment 103 Minus public Boolean IsProcessed { get; set; }
Add comment 104 Minus public Boolean IsOnlyLowQuality { get; set; }
Add comment 105 Minus public Boolean IsThumbnailLoaded { get; set; }
Add comment 106 Minus public Boolean IsInitialised { get; set; }
Add comment 107 Minus public Int32 OverlayIconIndex { get; set; }
Add comment 108 Minus public Int32 GroupIndex { get; set; }
Add comment 109 Minus public Int32 IconIndex { get; set; }
Add comment 110 Minus public System.Drawing.Size IconSize { get; set; }
Add comment 111 Minus public IExtractIconPWFlags IconType { get; set; }
Add comment 112 Minus public IntPtr ILPidl { get; }
Add comment 113 Minus public IntPtr PIDL { get; }
Add comment 114 Minus public IShellFolder IFolder { get; set; }
Add comment 115 Minus public Int32 ShieldedIconIndex { get; set; }
Add comment 116 Minus public Boolean IsIconLoaded { get; set; }
Add comment 117 Minus public Boolean IsFileSystem { get; }
Add comment 118 Minus public Boolean IsNetworkPath { get; }
Add comment 119 Minus public Boolean IsDrive { get; }
Add comment 120 Minus public Boolean IsSearchFolder { get; }
Add comment 121 Minus public Bitmap Thumbnail(Int32 size, ShellThumbnailFormatOption format, ShellThumbnailRetrievalOption source) {
Add comment 122 Minus throw new NotImplementedException();
Add comment 123 Minus }
Add comment 124 Minus
Add comment 125 Minus public BitmapSource ThumbnailSource(Int32 size, ShellThumbnailFormatOption format, ShellThumbnailRetrievalOption source) {
Add comment 126 Minus throw new NotImplementedException();
Add comment 127 Minus }
Add comment 128 Minus
Add comment 129 Minus public BitmapSource BitmapSource { get; }
Add comment 130 Minus public String ParsingName { get; }
Add comment 131 Minus public Boolean IsBrowsable { get; }
Add comment 132 Minus public Boolean IsFolder { get; }
Add comment 133 Minus public Boolean HasSubFolders { get; }
Add comment 134 Minus public Boolean IsHidden { get; }
Add comment 135 Minus public Boolean IsLink { get; }
Add comment 136 Minus public Boolean IsShared { get; }
Add comment 137 Minus public Boolean IsSlow { get; }
Add comment 138 Minus public Boolean IsParentSearchFolder { get; set; }
Add comment 139 Minus public void Initialize(IntPtr lvHandle, String path) {
Add comment 140 Minus throw new NotImplementedException();
Add comment 141 Minus }
Add comment 142 Minus
Add comment 143 Minus public void Initialize(IntPtr lvHandle, String path, Int32 index) {
Add comment 144 Minus throw new NotImplementedException();
Add comment 145 Minus }
Add comment 146 Minus
Add comment 147 Minus public void Initialize(IntPtr lvHandle, IntPtr pidl, Int32 index) {
Add comment 148 Minus throw new NotImplementedException();
Add comment 149 Minus }
Add comment 150 Minus
Add comment 151 Minus public void Initialize(IntPtr lvHandle, IntPtr pidl) {
Add comment 152 Minus throw new NotImplementedException();
Add comment 153 Minus }
Add comment 154 Minus
Add comment 155 Minus public void InitializeWithParent(IntPtr parent, IntPtr lvHandle, IntPtr pidl, Int32 index) {
Add comment 156 Minus throw new NotImplementedException();
Add comment 157 Minus }
Add comment 158 Minus
Add comment 159 Minus public IListItemEx Clone(Boolean isHardCloning = false) {
Add comment 160 Minus throw new NotImplementedException();
Add comment 161 Minus }
Add comment 162 Minus
Add comment 163 Minus public PropVariant GetPropertyValue(PROPERTYKEY pkey, Type type) {
Add comment 164 Minus throw new NotImplementedException();
Add comment 165 Minus }
Add comment 166 Minus
Add comment 167 Minus public Dictionary<PROPERTYKEY, Object> ColumnValues { get; set; }
Add comment 168 Minus public IEnumerable<IntPtr> GetItemsForCount(Boolean isEnumHidden) {
Add comment 169 Minus throw new NotImplementedException();
Add comment 170 Minus }
Add comment 171 Minus
Add comment 172 Minus public IEnumerable<IListItemEx> GetContents(Boolean isEnumHidden, Boolean isFlatList = false) {
Add comment 173 Minus throw new NotImplementedException();
Add comment 174 Minus }
Add comment 175 Minus
Add comment 176 Minus public IShellFolder GetIShellFolder() {
Add comment 177 Minus throw new NotImplementedException();
Add comment 178 Minus }
Add comment 179 Minus
Add comment 180 Minus public String ToolTipText { get; }
Add comment 181 Minus public IntPtr AbsolutePidl { get; }
Add comment 182 Minus public DriveInfo GetDriveInfo() {
Add comment 183 Minus throw new NotImplementedException();
Add comment 184 Minus }
Add comment 185 Minus
Add comment 186 Minus public Boolean IsRCWSet { get; set; }
Add comment 187 Minus public Int32 RCWThread { get; set; }
Add comment 188 Minus
Add comment 189 Minus public HResult ExtractAndDrawThumbnail(IntPtr hdc, UInt32 iconSize, out WTS_CACHEFLAGS flags, User32.RECT iconBounds,
Add comment 190 Minus out Boolean retrieved, Boolean isHidden, Boolean isRefresh = false) {
Add comment 191 Minus throw new NotImplementedException();
Add comment 192 Minus }
Add comment 193 Minus
Add comment 194 Minus public HResult NavigationStatus { get; set; }
Add comment 195 Minus public IntPtr GetHBitmap(Int32 iconSize, Boolean isThumbnail, Boolean isForce = false, Boolean isBoth = false) {
Add comment 196 Minus throw new NotImplementedException();
Add comment 197 Minus }
Add comment 198 Minus
Add comment 199 Minus public Boolean RefreshThumb(Int32 iconSize, out WTS_CACHEFLAGS flags) {
Add comment 200 Minus throw new NotImplementedException();
Add comment 201 Minus }
Add comment 202 Minus
Add comment 203 Minus public String GetDisplayName(SIGDN type) {
Add comment 204 Minus throw new NotImplementedException();
Add comment 205 Minus }
Add comment 206 Minus
Add comment 207 Minus public IExtractIconPWFlags GetShield() {
Add comment 208 Minus throw new NotImplementedException();
Add comment 209 Minus }
Add comment 210 Minus
Add comment 211 Minus public Int32 GetSystemImageListIndex(IntPtr pidl, ShellIconType type, ShellIconFlags flags) {
Add comment 212 Minus throw new NotImplementedException();
Add comment 213 Minus }
Add comment 214 Minus
Add comment 215 Minus public Int32 GetUniqueID() {
Add comment 216 Minus throw new NotImplementedException();
Add comment 217 Minus }
Add comment 218 Minus
Add comment 219 Minus public Int32[] cColumns { get; set; }
Add comment 220 Minus
Add comment 221 Minus public void Dispose() {
Add comment 222 Minus if (!_disposed) {
Add comment 223 Minus if (this.EnumPIDL != IntPtr.Zero) {
Add comment 224 Minus try {
Add comment 225 Minus Marshal.FreeCoTaskMem(this.EnumPIDL);
Add comment 226 Minus } catch { } finally {
Add comment 227 Minus this.EnumPIDL = IntPtr.Zero;
Add comment 228 Minus }
Add comment 229 Minus }
Add comment 230 Minus GC.SuppressFinalize(this);
Add comment 231 Minus }
Add comment 232 Minus _disposed = true;
Add comment 233 Minus }
Add comment 234 Minus
Add comment 235 Minus public IEnumerator<IListItemEx> GetEnumerator() {
Add comment 236 Minus throw new NotImplementedException();
Add comment 237 Minus }
Add comment 238 Minus
Add comment 239 Minus public Boolean Equals(IListItemEx other) {
Add comment 240 Minus throw new NotImplementedException();
Add comment 241 Minus }
Add comment 242 Minus
Add comment 243 Minus ~VirtualFilesystemItem() { Dispose(); }
Add comment 244 Minus IEnumerator IEnumerable.GetEnumerator() {
Add comment 245 Minus return this.GetEnumerator();
Add comment 246 Minus }
Add comment 247 Minus
Add comment 248 Minus public Boolean Equals(IListItemEx x, IListItemEx y) {
Add comment 249 Minus throw new NotImplementedException();
Add comment 250 Minus }
Add comment 251 Minus
Add comment 252 Minus public Int32 GetHashCode(IListItemEx obj) {
Add comment 253 Minus throw new NotImplementedException();
Add comment 254 Minus }
Add comment 255 Minus }
Add comment 256 Minus }
Add comment 257 Minus
FilterMenu_Strings.cs
/Shell1/Custom ContextMenus Remove Soon/FilterMenu_Strings.cs-70/Shell1/Custom ContextMenus Remove Soon/FilterMenu_Strings.cs
Add comment 1 Minus using System;
Add comment 2 Minus using System.Collections.Generic;
Add comment 3 Minus using System.Linq;
Add comment 4 Minus using System.Text;
Add comment 5 Minus using System.Threading.Tasks;
Add comment 6 Minus using System.Windows;
Add comment 7 Minus using System.Windows.Controls;
Add comment 8 Minus
Add comment 9 Minus namespace BExplorer.Shell {
Add comment 10 Minus public class FilterMenu_Strings : ContextMenu {
Add comment 11 Minus /// <summary>
Add comment 12 Minus /// Represents the changing of a CheckBox's check state
Add comment 13 Minus /// </summary>
Add comment 14 Minus /// <param name="sender">The sender.</param>
Add comment 15 Minus /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
Add comment 16 Minus /// <param name="IsChecked">if set to <c>true</c> [is checked].</param>
Add comment 17 Minus public delegate void CheckChanged(object sender, RoutedEventArgs e, bool IsChecked);
Add comment 18 Minus
Add comment 19 Minus /// <summary>Occurs when a CheckBox's check has been changed</summary>
Add comment 20 Minus public event CheckChanged OnCheckChanged;
Add comment 21 Minus
Add comment 22 Minus public void SetItems(params string[] Items) {
Add comment 23 Minus SetItems(Items.ToList());
Add comment 24 Minus }
Add comment 25 Minus
Add comment 26 Minus
Add comment 27 Minus /// <summary>
Add comment 28 Minus /// Sets the items.
Add comment 29 Minus /// </summary>
Add comment 30 Minus /// <param name="Items">The items you want to use.</param>
Add comment 31 Minus public void SetItems(IEnumerable<string> Items) {
Add comment 32 Minus this.Items.Clear();
Add comment 33 Minus foreach (var Item in Items) {
Add comment 34 Minus //this.Height += 25;
Add comment 35 Minus var CheckBox = new CheckBox();
Add comment 36 Minus CheckBox.Content = Item;
Add comment 37 Minus
Add comment 38 Minus CheckBox.Checked += CheckBox_Checked;
Add comment 39 Minus CheckBox.Unchecked += CheckBox_Unchecked;
Add comment 40 Minus
Add comment 41 Minus this.Items.Add(CheckBox);
Add comment 42 Minus }
Add comment 43 Minus }
Add comment 44 Minus
Add comment 45 Minus /// <summary>
Add comment 46 Minus /// Gets the [Content] of the checked CheckBoxes.
Add comment 47 Minus /// </summary>
Add comment 48 Minus /// <returns></returns>
Add comment 49 Minus public List<string> CheckedItems() {
Add comment 50 Minus return this.Items.OfType<CheckBox>().Where(x => x.IsChecked.Value).Select(x => x.Content.ToString()).ToList();
Add comment 51 Minus }
Add comment 52 Minus
Add comment 53 Minus public void Activate(Control Container) {
Add comment 54 Minus Container.ContextMenu = this;
Add comment 55 Minus Container.ContextMenu.IsEnabled = true;
Add comment 56 Minus Container.ContextMenu.PlacementTarget = Container;
Add comment 57 Minus Container.ContextMenu.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom;
Add comment 58 Minus Container.ContextMenu.IsOpen = true;
Add comment 59 Minus }
Add comment 60 Minus
Add comment 61 Minus void CheckBox_Unchecked(object sender, RoutedEventArgs e) {
Add comment 62 Minus if (OnCheckChanged != null) OnCheckChanged(sender, e, false);
Add comment 63 Minus }
Add comment 64 Minus
Add comment 65 Minus void CheckBox_Checked(object sender, System.Windows.RoutedEventArgs e) {
Add comment 66 Minus if (OnCheckChanged != null) OnCheckChanged(sender, e, true);
Add comment 67 Minus }
Add comment 68 Minus }
Add comment 69 Minus }
Add comment 70 Minus
AsyncUnbuffCopy.cs
/Shell1/FileOperation/AsyncUnbuffCopy.cs-375/Shell1/FileOperation/AsyncUnbuffCopy.cs
Add comment 1 Minus //
Add comment 2 Minus // AsyncUnbuffCopy.cs
Add comment 3 Minus //
Add comment 4 Minus // Authors:
Add comment 5 Minus // Wesley D. Brown <wes@planetarydb.com>
Add comment 6 Minus //
Add comment 7 Minus // Copyright (C) 2010 SQLServerIO (http://www.SQLServerIO.com)
Add comment 8 Minus //
Add comment 9 Minus // Permission is hereby granted, free of charge, to any person obtaining
Add comment 10 Minus // a copy of this software and associated documentation files (the
Add comment 11 Minus // "Software"), to deal in the Software without restriction, including
Add comment 12 Minus // without limitation the rights to use, copy, modify, merge, publish,
Add comment 13 Minus // distribute, sublicense, and/or sell copies of the Software, and to
Add comment 14 Minus // permit persons to whom the Software is furnished to do so, subject to
Add comment 15 Minus // the following conditions:
Add comment 16 Minus //
Add comment 17 Minus // The above copyright notice and this permission notice shall be
Add comment 18 Minus // included in all copies or substantial portions of the Software.
Add comment 19 Minus //
Add comment 20 Minus // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Add comment 21 Minus // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Add comment 22 Minus // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Add comment 23 Minus // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
Add comment 24 Minus // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
Add comment 25 Minus // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
Add comment 26 Minus // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Add comment 27 Minus //
Add comment 28 Minus
Add comment 29 Minus using System;
Add comment 30 Minus using System.IO;
Add comment 31 Minus using System.Runtime.CompilerServices;
Add comment 32 Minus using System.Security.Cryptography;
Add comment 33 Minus using System.Text;
Add comment 34 Minus using System.Threading;
Add comment 35 Minus
Add comment 36 Minus namespace BExplorer.Shell {
Add comment 37 Minus public class CopyEventArgs {
Add comment 38 Minus public String InFileName { get; set; }
Add comment 39 Minus public String OutFileName { get; set; }
Add comment 40 Minus public long BytesTransferred { get; set; }
Add comment 41 Minus public long TotalBytes { get; set; }
Add comment 42 Minus }
Add comment 43 Minus public class AsyncUnbuffCopy {
Add comment 44 Minus
Add comment 45 Minus public event EventHandler<CopyEventArgs> OnProgress;
Add comment 46 Minus
Add comment 47 Minus //file names
Add comment 48 Minus private static string _inputfile;
Add comment 49 Minus private static string _outputfile;
Add comment 50 Minus
Add comment 51 Minus //checksum holders
Add comment 52 Minus private static string _infilechecksum;
Add comment 53 Minus private static string _outfilechecksum;
Add comment 54 Minus
Add comment 55 Minus //show write progress
Add comment 56 Minus private static bool _reportprogress;
Add comment 57 Minus
Add comment 58 Minus //cursor position
Add comment 59 Minus private static int _origRow;
Add comment 60 Minus private static int _origCol;
Add comment 61 Minus
Add comment 62 Minus //number of chunks to copy
Add comment 63 Minus private static int _numchunks;
Add comment 64 Minus
Add comment 65 Minus //track read state and read failed state
Add comment 66 Minus private static bool _readfailed;
Add comment 67 Minus
Add comment 68 Minus //syncronization object
Add comment 69 Minus private static readonly object Locker1 = new object();
Add comment 70 Minus
Add comment 71 Minus //buffer size
Add comment 72 Minus public static int CopyBufferSize;
Add comment 73 Minus private static long _infilesize;
Add comment 74 Minus
Add comment 75 Minus //buffer read
Add comment 76 Minus public static byte[] Buffer1;
Add comment 77 Minus private static int _bytesRead1;
Add comment 78 Minus
Add comment 79 Minus //buffer overlap
Add comment 80 Minus public static byte[] Buffer2;
Add comment 81 Minus private static bool _buffer2Dirty;
Add comment 82 Minus private static int _bytesRead2;
Add comment 83 Minus
Add comment 84 Minus //buffer write
Add comment 85 Minus public static byte[] Buffer3;
Add comment 86 Minus
Add comment 87 Minus //total bytes read
Add comment 88 Minus private static long _totalbytesread;
Add comment 89 Minus private static long _totalbyteswritten;
Add comment 90 Minus
Add comment 91 Minus //filestreams
Add comment 92 Minus private static FileStream _infile;
Add comment 93 Minus private static FileStream _outfile;
Add comment 94 Minus
Add comment 95 Minus //secret sauce for unbuffered IO
Add comment 96 Minus const FileOptions FileFlagNoBuffering = (FileOptions)0x20000000;
Add comment 97 Minus
Add comment 98 Minus private static void AsyncReadFile() {
Add comment 99 Minus //open input file
Add comment 100 Minus try {
Add comment 101 Minus _infile = new FileStream(_inputfile, FileMode.Open, FileAccess.Read, FileShare.Read, CopyBufferSize, FileFlagNoBuffering);
Add comment 102 Minus } catch {
Add comment 103 Minus throw;
Add comment 104 Minus }
Add comment 105 Minus //if we have data read it
Add comment 106 Minus while (_totalbytesread < _infilesize) {
Add comment 107 Minus
Add comment 108 Minus _bytesRead1 = _infile.Read(Buffer1, 0, CopyBufferSize);
Add comment 109 Minus Monitor.Enter(Locker1);
Add comment 110 Minus try {
Add comment 111 Minus while (_buffer2Dirty) Monitor.Wait(Locker1);
Add comment 112 Minus Buffer.BlockCopy(Buffer1, 0, Buffer2, 0, _bytesRead1);
Add comment 113 Minus _buffer2Dirty = true;
Add comment 114 Minus _bytesRead2 = _bytesRead1;
Add comment 115 Minus _totalbytesread = _totalbytesread + _bytesRead1;
Add comment 116 Minus Monitor.PulseAll(Locker1);
Add comment 117 Minus
Add comment 118 Minus } catch {
Add comment 119 Minus _readfailed = true;
Add comment 120 Minus throw;
Add comment 121 Minus } finally { Monitor.Exit(Locker1); }
Add comment 122 Minus }
Add comment 123 Minus //clean up open handle
Add comment 124 Minus _infile.Close();
Add comment 125 Minus _infile.Dispose();
Add comment 126 Minus }
Add comment 127 Minus
Add comment 128 Minus private void AsyncWriteFile() {
Add comment 129 Minus //open output file set length to prevent growth and file fragmentation and close it.
Add comment 130 Minus //We do this to prevent file fragmentation and make the write as fast as possible.
Add comment 131 Minus try {
Add comment 132 Minus _outfile = new FileStream(_outputfile, FileMode.Create, FileAccess.Write, FileShare.None, 8, FileOptions.WriteThrough);
Add comment 133 Minus
Add comment 134 Minus //set file size to minimum of one buffer to cut down on fragmentation
Add comment 135 Minus _outfile.SetLength(_infilesize > CopyBufferSize ? _infilesize : CopyBufferSize);
Add comment 136 Minus
Add comment 137 Minus _outfile.Close();
Add comment 138 Minus _outfile.Dispose();
Add comment 139 Minus } catch {
Add comment 140 Minus throw;
Add comment 141 Minus }
Add comment 142 Minus
Add comment 143 Minus //open file for write unbuffered
Add comment 144 Minus try {
Add comment 145 Minus _outfile = new FileStream(_outputfile, FileMode.Open, FileAccess.Write, FileShare.None, 8, FileOptions.WriteThrough | FileFlagNoBuffering);
Add comment 146 Minus
Add comment 147 Minus } catch {
Add comment 148 Minus throw;
Add comment 149 Minus }
Add comment 150 Minus
Add comment 151 Minus var pctinc = 0.0;
Add comment 152 Minus var progress = pctinc;
Add comment 153 Minus
Add comment 154 Minus //progress stuff
Add comment 155 Minus if (_reportprogress) {
Add comment 156 Minus
Add comment 157 Minus pctinc = 100.00 / _numchunks;
Add comment 158 Minus }
Add comment 159 Minus
Add comment 160 Minus while ((_totalbyteswritten < _infilesize) && !_readfailed) {
Add comment 161 Minus lock (Locker1) {
Add comment 162 Minus
Add comment 163 Minus while (!_buffer2Dirty) Monitor.Wait(Locker1);
Add comment 164 Minus
Add comment 165 Minus Buffer.BlockCopy(Buffer2, 0, Buffer3, 0, _bytesRead2);
Add comment 166 Minus _buffer2Dirty = false;
Add comment 167 Minus
Add comment 168 Minus _totalbyteswritten = _totalbyteswritten + CopyBufferSize;
Add comment 169 Minus
Add comment 170 Minus Monitor.PulseAll(Locker1);
Add comment 171 Minus //fancy dan in place percent update on each write.
Add comment 172 Minus if (this.OnProgress != null) {
Add comment 173 Minus this.OnProgress.Invoke(this, new CopyEventArgs() {
Add comment 174 Minus InFileName = _inputfile,
Add comment 175 Minus OutFileName = _outputfile,
Add comment 176 Minus BytesTransferred = _totalbyteswritten,
Add comment 177 Minus TotalBytes = _infilesize
Add comment 178 Minus });
Add comment 179 Minus }
Add comment 180 Minus if (_reportprogress) {
Add comment 181 Minus
Add comment 182 Minus Console.SetCursorPosition(_origCol, _origRow);
Add comment 183 Minus if (progress < 101 - pctinc) {
Add comment 184 Minus progress = progress + pctinc;
Add comment 185 Minus Console.Write("%{0}", Math.Round(progress, 0));
Add comment 186 Minus }
Add comment 187 Minus }
Add comment 188 Minus }
Add comment 189 Minus try {
Add comment 190 Minus _outfile.Write(Buffer3, 0, CopyBufferSize);
Add comment 191 Minus } catch {
Add comment 192 Minus throw;
Add comment 193 Minus }
Add comment 194 Minus }
Add comment 195 Minus
Add comment 196 Minus //close the file handle that was using unbuffered and write through
Add comment 197 Minus
Add comment 198 Minus _outfile.Close();
Add comment 199 Minus _outfile.Dispose();
Add comment 200 Minus
Add comment 201 Minus try {
Add comment 202 Minus
Add comment 203 Minus _outfile = new FileStream(_outputfile, FileMode.Open, FileAccess.Write, FileShare.None, 8,
Add comment 204 Minus FileOptions.WriteThrough);
Add comment 205 Minus _outfile.SetLength(_infilesize);
Add comment 206 Minus _outfile.Close();
Add comment 207 Minus _outfile.Dispose();
Add comment 208 Minus } catch {
Add comment 209 Minus throw;
Add comment 210 Minus }
Add comment 211 Minus }
Add comment 212 Minus
Add comment 213 Minus public int AsyncCopyFileUnbuffered(string inputfile, string outputfile, bool overwrite,bool movefile, bool checksum, int buffersize, bool reportprogress) {
Add comment 214 Minus
Add comment 215 Minus //report write progress
Add comment 216 Minus _reportprogress = reportprogress;
Add comment 217 Minus
Add comment 218 Minus //set file name globals
Add comment 219 Minus _inputfile = inputfile;
Add comment 220 Minus _outputfile = outputfile;
Add comment 221 Minus
Add comment 222 Minus //setup single buffer size, remember this will be x3.
Add comment 223 Minus CopyBufferSize = buffersize * 1024 * 1024;
Add comment 224 Minus
Add comment 225 Minus //buffer read
Add comment 226 Minus Buffer1 = new byte[CopyBufferSize];
Add comment 227 Minus
Add comment 228 Minus //buffer overlap
Add comment 229 Minus Buffer2 = new byte[CopyBufferSize];
Add comment 230 Minus
Add comment 231 Minus //buffer write
Add comment 232 Minus Buffer3 = new byte[CopyBufferSize];
Add comment 233 Minus
Add comment 234 Minus //clear all flags and handles
Add comment 235 Minus _totalbytesread = 0;
Add comment 236 Minus _totalbyteswritten = 0;
Add comment 237 Minus _bytesRead1 = 0;
Add comment 238 Minus _buffer2Dirty = false;
Add comment 239 Minus
Add comment 240 Minus //if the overwrite flag is set to false check to see if the file is there.
Add comment 241 Minus if (File.Exists(outputfile) && !overwrite) {
Add comment 242 Minus
Add comment 243 Minus Console.WriteLine("Destination File Exists!");
Add comment 244 Minus return 0;
Add comment 245 Minus }
Add comment 246 Minus
Add comment 247 Minus //create the directory if it doesn't exist
Add comment 248 Minus if (!Directory.Exists(outputfile)) {
Add comment 249 Minus try {
Add comment 250 Minus // ReSharper disable AssignNullToNotNullAttribute
Add comment 251 Minus Directory.CreateDirectory(Path.GetDirectoryName(outputfile));
Add comment 252 Minus // ReSharper restore AssignNullToNotNullAttribute
Add comment 253 Minus } catch (Exception e) {
Add comment 254 Minus
Add comment 255 Minus Console.WriteLine("Create Directory Failed.");
Add comment 256 Minus Console.WriteLine(e.Message);
Add comment 257 Minus throw;
Add comment 258 Minus }
Add comment 259 Minus }
Add comment 260 Minus
Add comment 261 Minus //get input file size for later use
Add comment 262 Minus var inputFileInfo = new FileInfo(_inputfile);
Add comment 263 Minus _infilesize = inputFileInfo.Length;
Add comment 264 Minus
Add comment 265 Minus //get number of buffer sized chunks used to correctly display percent complete.
Add comment 266 Minus _numchunks = (int)((_infilesize / CopyBufferSize) <= 0 ? (_infilesize / CopyBufferSize) : 1);
Add comment 267 Minus
Add comment 268 Minus
Add comment 269 Minus Console.WriteLine("File Copy Started");
Add comment 270 Minus
Add comment 271 Minus //create read thread and start it.
Add comment 272 Minus var readfile = new Thread(AsyncReadFile) { Name = "ReadThread", IsBackground = true };
Add comment 273 Minus readfile.Start();
Add comment 274 Minus
Add comment 275 Minus
Add comment 276 Minus //create write thread and start it.
Add comment 277 Minus var writefile = new Thread(AsyncWriteFile) { Name = "WriteThread", IsBackground = true };
Add comment 278 Minus writefile.Start();
Add comment 279 Minus
Add comment 280 Minus if (_reportprogress) {
Add comment 281 Minus //set fancy curor position
Add comment 282 Minus _origRow = Console.CursorTop;
Add comment 283 Minus _origCol = Console.CursorLeft;
Add comment 284 Minus }
Add comment 285 Minus
Add comment 286 Minus //wait for threads to finish
Add comment 287 Minus readfile.Join();
Add comment 288 Minus writefile.Join();
Add comment 289 Minus
Add comment 290 Minus //leave a blank line for the progress indicator
Add comment 291 Minus if (_reportprogress)
Add comment 292 Minus Console.WriteLine();
Add comment 293 Minus
Add comment 294 Minus
Add comment 295 Minus
Add comment 296 Minus Console.WriteLine("File Copy Done");
Add comment 297 Minus
Add comment 298 Minus if (checksum) {
Add comment 299 Minus
Add comment 300 Minus Console.WriteLine("Checksum Source File Started");
Add comment 301 Minus //create checksum read file thread and start it.
Add comment 302 Minus var checksumreadfile = new Thread(GetMD5HashFromInputFile) {
Add comment 303 Minus Name = "checksumreadfile",
Add comment 304 Minus IsBackground = true
Add comment 305 Minus };
Add comment 306 Minus checksumreadfile.Start();
Add comment 307 Minus
Add comment 308 Minus
Add comment 309 Minus Console.WriteLine("Checksum Destination File Started");
Add comment 310 Minus //create checksum write file thread and start it.
Add comment 311 Minus var checksumwritefile = new Thread(GetMD5HashFromOutputFile) {
Add comment 312 Minus Name = "checksumwritefile",
Add comment 313 Minus IsBackground = true
Add comment 314 Minus };
Add comment 315 Minus checksumwritefile.Start();
Add comment 316 Minus
Add comment 317 Minus //hang out until the checksums are done.
Add comment 318 Minus checksumreadfile.Join();
Add comment 319 Minus checksumwritefile.Join();
Add comment 320 Minus
Add comment 321 Minus if (_infilechecksum.Equals(_outfilechecksum)) {
Add comment 322 Minus
Add comment 323 Minus Console.WriteLine("Checksum Verified");
Add comment 324 Minus } else {
Add comment 325 Minus
Add comment 326 Minus Console.WriteLine("Checksum Failed");
Add comment 327 Minus Console.WriteLine("Input File Checksum : {0}", _infilechecksum);
Add comment 328 Minus Console.WriteLine("Output File Checksum: {0}", _outfilechecksum);
Add comment 329 Minus }
Add comment 330 Minus }
Add comment 331 Minus
Add comment 332 Minus if (movefile && File.Exists(inputfile) && File.Exists(outputfile))
Add comment 333 Minus try {
Add comment 334 Minus File.Delete(inputfile);
Add comment 335 Minus } catch (IOException ioex) {
Add comment 336 Minus
Add comment 337 Minus Console.WriteLine("File in use or locked");
Add comment 338 Minus Console.WriteLine(ioex.Message);
Add comment 339 Minus } catch (Exception ex) {
Add comment 340 Minus
Add comment 341 Minus Console.WriteLine("File Failed to Delete");
Add comment 342 Minus Console.WriteLine(ex.Message);
Add comment 343 Minus }
Add comment 344 Minus return 1;
Add comment 345 Minus }
Add comment 346 Minus
Add comment 347 Minus //hash input file
Add comment 348 Minus public void GetMD5HashFromInputFile() {
Add comment 349 Minus var fs = new FileStream(_inputfile, FileMode.Open, FileAccess.Read, FileShare.None, CopyBufferSize);
Add comment 350 Minus MD5 md5 = new MD5CryptoServiceProvider();
Add comment 351 Minus byte[] retVal = md5.ComputeHash(fs);
Add comment 352 Minus fs.Close();
Add comment 353 Minus
Add comment 354 Minus var sb = new StringBuilder();
Add comment 355 Minus for (var i = 0; i < retVal.Length; i++) {
Add comment 356 Minus sb.Append(retVal[i].ToString("x2"));
Add comment 357 Minus }
Add comment 358 Minus _infilechecksum = sb.ToString();
Add comment 359 Minus }
Add comment 360 Minus
Add comment 361 Minus //hash output file
Add comment 362 Minus public void GetMD5HashFromOutputFile() {
Add comment 363 Minus var fs = new FileStream(_outputfile, FileMode.Open, FileAccess.Read, FileShare.None, CopyBufferSize);
Add comment 364 Minus MD5 md5 = new MD5CryptoServiceProvider();
Add comment 365 Minus byte[] retVal = md5.ComputeHash(fs);
Add comment 366 Minus fs.Close();
Add comment 367 Minus
Add comment 368 Minus var sb = new StringBuilder();
Add comment 369 Minus for (var i = 0; i < retVal.Length; i++) {
Add comment 370 Minus sb.Append(retVal[i].ToString("x2"));
Add comment 371 Minus }
Add comment 372 Minus _outfilechecksum = sb.ToString();
Add comment 373 Minus }
Add comment 374 Minus }
Add comment 375 Minus }
CollisionDialog.xaml
/Shell1/FileOperation/CollisionDialog.xaml/Shell1/FileOperation/CollisionDialog.xaml
CollisionDialog.xaml.cs
/Shell1/FileOperation/CollisionDialog.xaml.cs/Shell1/FileOperation/CollisionDialog.xaml.cs
DeleteNotificationDialog.xaml
/Shell1/FileOperation/DeleteNotificationDialog.xaml/Shell1/FileOperation/DeleteNotificationDialog.xaml
DeleteNotificationDialog.xaml.cs
/Shell1/FileOperation/DeleteNotificationDialog.xaml.cs/Shell1/FileOperation/DeleteNotificationDialog.xaml.cs
FileOperation.xaml
/Shell1/FileOperation/FileOperation.xaml/Shell1/FileOperation/FileOperation.xaml
FileOperation.xaml.cs
/Shell1/FileOperation/FileOperation.xaml.cs/Shell1/FileOperation/FileOperation.xaml.cs
FileOperationDialog.xaml
/Shell1/FileOperation/FileOperationDialog.xaml/Shell1/FileOperation/FileOperationDialog.xaml
FileOperationDialog.xaml.cs
/Shell1/FileOperation/FileOperationDialog.xaml.cs/Shell1/FileOperation/FileOperationDialog.xaml.cs
IIFileOperation.cs
/Shell1/FileOperation/IIFileOperation.cs/Shell1/FileOperation/IIFileOperation.cs
IFileOperationProgressSink.cs
/Shell1/Interop/IFileOperationProgressSink.cs/Shell1/Interop/IFileOperationProgressSink.cs
IFileSystemBindData.cs
/Shell1/Interop/IFileSystemBindData.cs/Shell1/Interop/IFileSystemBindData.cs
INativeShellLibrary.cs
/Shell1/Interop/INativeShellLibrary.cs/Shell1/Interop/INativeShellLibrary.cs
IOperationsProgressDialog.cs
/Shell1/Interop/IOperationsProgressDialog.cs/Shell1/Interop/IOperationsProgressDialog.cs
NativeWindowListener.cs
/Shell1/Interop/NativeWindowListener.cs/Shell1/Interop/NativeWindowListener.cs
PropertySystemNativeMethods.cs
/Shell1/Interop/PropertySystemNativeMethods.cs/Shell1/Interop/PropertySystemNativeMethods.cs
PropVariantNativeMethods.cs
/Shell1/Interop/PropVariantNativeMethods.cs/Shell1/Interop/PropVariantNativeMethods.cs
WindowsThumbnailProvider.cs
/Shell1/Interop/WindowsThumbnailProvider.cs/Shell1/Interop/WindowsThumbnailProvider.cs
DefinitionOptions.cs
/Shell1/KnownFolders/DefinitionOptions.cs/Shell1/KnownFolders/DefinitionOptions.cs
FileSystemKnownFolder.cs
/Shell1/KnownFolders/FileSystemKnownFolder.cs/Shell1/KnownFolders/FileSystemKnownFolder.cs
FolderProperties.cs
/Shell1/KnownFolders/FolderProperties.cs/Shell1/KnownFolders/FolderProperties.cs
FoldersIdentifiers.cs
/Shell1/KnownFolders/FoldersIdentifiers.cs/Shell1/KnownFolders/FoldersIdentifiers.cs
KnownFolderHelper.cs
/Shell1/KnownFolders/KnownFolderHelper.cs/Shell1/KnownFolders/KnownFolderHelper.cs
KnownFolderSettings.cs
/Shell1/KnownFolders/KnownFolderSettings.cs/Shell1/KnownFolders/KnownFolderSettings.cs
NonFileSystemKnownFolder.cs
/Shell1/KnownFolders/NonFileSystemKnownFolder.cs/Shell1/KnownFolders/NonFileSystemKnownFolder.cs
RedirectionCapabilities.cs
/Shell1/KnownFolders/RedirectionCapabilities.cs/Shell1/KnownFolders/RedirectionCapabilities.cs
Resources.Designer.cs
/Shell1/Properties/Resources.Designer.cs/Shell1/Properties/Resources.Designer.cs
IOwnerDataCallback.cs
/Shell1/VirtualGroups/IOwnerDataCallback.cs/Shell1/VirtualGroups/IOwnerDataCallback.cs
VirtualGrouping.cs
/Shell1/VirtualGroups/VirtualGrouping.cs/Shell1/VirtualGroups/VirtualGrouping.cs
SearchCondition.cs
/Shell1/WindowsSearch/SearchCondition.cs/Shell1/WindowsSearch/SearchCondition.cs
SearchConditionFactory.cs
/Shell1/WindowsSearch/SearchConditionFactory.cs/Shell1/WindowsSearch/SearchConditionFactory.cs
ShellSearchFolder.cs
/Shell1/WindowsSearch/ShellSearchFolder.cs/Shell1/WindowsSearch/ShellSearchFolder.cs
LeftMarginMultiplierConverter.cs
/Shell1/LeftMarginMultiplierConverter.cs/Shell1/LeftMarginMultiplierConverter.cs
ObjectToSeparatorBooleanConverter.cs
/Shell1/ObjectToSeparatorBooleanConverter.cs/Shell1/ObjectToSeparatorBooleanConverter.cs
ShellItemEqualityComparer.cs
/Shell1/ShellItemEqualityComparer.cs/Shell1/ShellItemEqualityComparer.cs
ShellNotificationListener.cs
/Shell1/ShellNotificationListener.cs/Shell1/ShellNotificationListener.cs
ShellTreeViewEx.Designer.cs
/Shell1/ShellTreeViewEx.Designer.cs/Shell1/ShellTreeViewEx.Designer.cs
TooltipDataTemplateSelector.cs
/Shell1/TooltipDataTemplateSelector.cs/Shell1/TooltipDataTemplateSelector.cs