Cleaning
f318deb8
Aaron Campf
committed
4 changed files
ShellComboBox.cs
/Shell/ShellComboBox.cs-12+8
/Shell/ShellComboBox.cs
Add comment 329 void m_Combo_DrawItem(object sender, DrawItemEventArgs e)
Add comment 330 {
Add comment 331 int iconWidth = SystemInformation.SmallIconSize.Width;
Add comment 332 Minus   int indent = ((e.State & DrawItemState.ComboBoxEdit) == 0) ?
Add comment 333 Minus   (iconWidth / 2) : 0;
Add comment 332 Plus   int indent = ((e.State & DrawItemState.ComboBoxEdit) == 0) ? (iconWidth / 2) : 0;
Add comment 334 333
Add comment 335 334 if (e.Index != -1)
Add comment 336 335 {
Add comment 355 354
Add comment 356 355 size = TextRenderer.MeasureText(display, m_Combo.Font);
Add comment 357 356
Add comment 358 Minus   textRect = new Rectangle(
Add comment 359 Minus   e.Bounds.Left + iconWidth + (item.Indent * indent) + 3,
Add comment 360 Minus   e.Bounds.Y, (int)size.Width, e.Bounds.Height);
Add comment 357 Plus   textRect = new Rectangle(e.Bounds.Left + iconWidth + (item.Indent * indent) + 3, e.Bounds.Y, (int)size.Width, e.Bounds.Height);
Add comment 361 358 textOffset = (int)((e.Bounds.Height - size.Height) / 2);
Add comment 362 359
Add comment 363 360 // If the text is being drawin in the main combo box edit area,
Add comment 382 379 ControlPaint.DrawFocusRectangle(e.Graphics, textRect);
Add comment 383 380 }
Add comment 384 381
Add comment 385 Minus   SystemImageList.DrawSmallImage(e.Graphics,
Add comment 386 Minus   new Point(e.Bounds.Left + (item.Indent * indent),
Add comment 387 Minus   e.Bounds.Top),
Add comment 382 Plus   SystemImageList.DrawSmallImage(
Add comment 383 Plus   e.Graphics,
Add comment 384 Plus   new Point(e.Bounds.Left + (item.Indent * indent), e.Bounds.Top),
Add comment 388 385 item.Folder.GetSystemImageListIndex(ShellIconType.SmallIcon,
Add comment 389 386 ShellIconFlags.OverlayIndex),
Add comment 390 Minus   (e.State & DrawItemState.Selected) != 0);
Add comment 391 Minus   TextRenderer.DrawText(e.Graphics, display, m_Combo.Font,
Add comment 392 Minus   new Point(textRect.Left, textRect.Top + textOffset),
Add comment 393 Minus   textColor);
Add comment 387 Plus   (e.State & DrawItemState.Selected) != 0
Add comment 388 Plus   );
Add comment 389 Plus   TextRenderer.DrawText(e.Graphics, display, m_Combo.Font, new Point(textRect.Left, textRect.Top + textOffset), textColor);
Add comment 394 390 }
Add comment 395 391 }
Add comment 396 392
ShellTreeViewEx.cs
/Shell/ShellTreeViewEx.cs-19+5
/Shell/ShellTreeViewEx.cs
Add comment 17 namespace BExplorer.Shell
Add comment 18 {
Add comment 19
Add comment 20 Plus   /*
Add comment 20 21 public class NodeSorter : IComparer
Add comment 21 22 {
Add comment 22 23 public int Compare(object x, object y)
Add comment 29 30 return (tx.Tag as IListItemEx).DisplayName.CompareTo((ty.Tag as IListItemEx).DisplayName);
Add comment 30 31 }
Add comment 31 32 }
Add comment 33 Plus   */
Add comment 32 34
Add comment 33 35 public partial class ShellTreeViewEx : UserControl
Add comment 34 36 {
Add comment 35 37
Add comment 36 Minus   /*
Add comment 37 Minus   * Should we use HashSets not Lists?
Add comment 38 Minus   * http://stackoverflow.com/questions/150750/hashset-vs-list-performance
Add comment 39 Minus   * http://blog.goyello.com/2013/01/30/6-more-things-c-developers-should-not-do/
Add comment 40 Minus   * http://www.c-sharpcorner.com/UploadFile/0f68f2/comparative-analysis-of-list-hashset-and-sortedset/
Add comment 41 Minus   *
Add comment 42 Minus   *
Add comment 43 Minus   * Performance Test Code!
Add comment 44 Minus   * http://stackoverflow.com/questions/25615764/list-add-vs-hashset-add-for-small-collections-in-c-sharp
Add comment 45 Minus   *
Add comment 46 Minus   * I think HashSets are actually worse as the lists are to small
Add comment 47 Minus   */
Add comment 48 Minus  
Add comment 49 38 #region Event Handlers
Add comment 50 39
Add comment 51 40 public event EventHandler<TreeNodeMouseClickEventArgs> NodeClick;
Add comment 221 210 }
Add comment 222 211 }
Add comment 223 212 }
Add comment 213 Plus  
Add comment 224 214 public void SelItem(IListItemEx item)
Add comment 225 215 {
Add comment 226 216 var node = this.FromItem(item);
Add comment 245 235 if (itemNode != null) break;
Add comment 246 236 }
Add comment 247 237
Add comment 248 Minus   if (itemNode != null)
Add comment 249 Minus   {
Add comment 250 Minus   itemNode.Remove();
Add comment 251 Minus   }
Add comment 238 Plus   itemNode?.Remove();
Add comment 252 239 }
Add comment 253 240
Add comment 254 241 public void AddItem(IListItemEx item)
Add comment 279 266 itemReal = FileSystemListItem.ToFileSystemItem(IntPtr.Zero, item.ParsingName.ToShellParsingName());
Add comment 280 267 node.Tag = itemReal;
Add comment 281 268 var oldnodearray = itemNode.Nodes.OfType<TreeNode>().ToList();
Add comment 282 Minus   if (oldnodearray.SingleOrDefault(s => s.Tag != null && (s.Tag as IListItemEx).Equals(itemReal)) == null)
Add comment 283 Minus   oldnodearray.Add(node);
Add comment 269 Plus   if (oldnodearray.SingleOrDefault(s => s.Tag != null && (s.Tag as IListItemEx).Equals(itemReal)) == null) oldnodearray.Add(node);
Add comment 284 270 var newArray = oldnodearray.OrderBy(o => o.Text).ToArray();
Add comment 285 271 this.ShellTreeView.BeginUpdate();
Add comment 286 272 itemNode.Nodes.Clear();
ShellViewEx.cs
/Shell/ShellViewEx.cs-6+2
/Shell/ShellViewEx.cs
Add comment 463 private bool _IsCanceledOperation { get; set; }
Add comment 464 private int LastItemForRename { get; set; }
Add comment 465 private System.Runtime.InteropServices.ComTypes.IDataObject dataObject { get; set; }
Add comment 466 Minus   private Boolean _showCheckBoxes = false;
Add comment 467 Minus   private Boolean _ShowHidden;
Add comment 466 Plus   private bool _showCheckBoxes = false;
Add comment 467 Plus   private bool _ShowHidden;
Add comment 468 private F.Timer _ResetTimer = new F.Timer();
Add comment 469 private List<int> DraggedItemIndexes = new List<int>();
Add comment 470 private F.Timer _KeyJumpTimer = new F.Timer();
Add comment 490 private ImageList large = new ImageList(ImageListSize.Large);
Add comment 491 private ShellViewStyle m_View;
Add comment 492
Add comment 493 Minus  
Add comment 494 Minus  
Add comment 495 493 private Thread _OverlaysLoadingThread;
Add comment 496 494 private F.Timer selectionTimer = new F.Timer();
Add comment 497 495 private SyncQueue<int> shieldQueue = new SyncQueue<int>(); //3000
Add comment 511 509 private SyncQueue<int?> ThumbnailsForCacheLoad = new SyncQueue<int?>(); //5000
Add comment 512 510 private SyncQueue<int?> waitingThumbnails = new SyncQueue<int?>(); //3000
Add comment 513 511
Add comment 514 Minus  
Add comment 515 Minus  
Add comment 516 512 #endregion Private Members
Add comment 517 513
Add comment 518 514 #region Initializer
SystemImageList.cs
/Shell/SystemImageList.cs-39+47
/Shell/SystemImageList.cs
Add comment 23 using System.Windows.Forms;
Add comment 24 using BExplorer.Shell.Interop;
Add comment 25
Add comment 26 Minus  namespace BExplorer.Shell {
Add comment 27 Minus   class SystemImageList {
Add comment 28 Minus   public static void DrawSmallImage(Graphics g, Point point, int imageIndex, bool selected) {
Add comment 26 Plus  namespace BExplorer.Shell
Add comment 27 Plus  {
Add comment 28 Plus   class SystemImageList
Add comment 29 Plus   {
Add comment 30 Plus   static IntPtr m_SmallImageList;
Add comment 31 Plus   static IntPtr m_LargeImageList;
Add comment 32 Plus  
Add comment 33 Plus   static IntPtr SmallImageList
Add comment 34 Plus   {
Add comment 35 Plus   get
Add comment 36 Plus   {
Add comment 37 Plus   if (m_SmallImageList == IntPtr.Zero) InitializeImageLists();
Add comment 38 Plus   return m_SmallImageList;
Add comment 39 Plus   }
Add comment 40 Plus   }
Add comment 41 Plus  
Add comment 42 Plus   static IntPtr LargeImageList
Add comment 43 Plus   {
Add comment 44 Plus   get
Add comment 45 Plus   {
Add comment 46 Plus   if (m_LargeImageList == IntPtr.Zero) InitializeImageLists();
Add comment 47 Plus  
Add comment 48 Plus   return m_LargeImageList;
Add comment 49 Plus   }
Add comment 50 Plus   }
Add comment 51 Plus  
Add comment 52 Plus   public static void DrawSmallImage(Graphics g, Point point, int imageIndex, bool selected)
Add comment 53 Plus   {
Add comment 29 54 uint flags = (uint)(imageIndex >> 16);
Add comment 30 55 IntPtr hdc = g.GetHdc();
Add comment 31 56
Add comment 32 Minus   try {
Add comment 57 Plus   try
Add comment 58 Plus   {
Add comment 33 59 if (selected) flags |= (int)ILD.BLEND50;
Add comment 34 60 ComCtl32.ImageList_Draw(SmallImageList, imageIndex & 0xffff, hdc, point.X, point.Y, flags);
Add comment 35 61 }
Add comment 36 Minus   finally {
Add comment 62 Plus   finally
Add comment 63 Plus   {
Add comment 37 64 g.ReleaseHdc();
Add comment 38 65 }
Add comment 39 66 }
Add comment 40 67
Add comment 41 Minus   public static void UseSystemImageList(ListView control) {
Add comment 68 Plus   public static void UseSystemImageList(ListView control)
Add comment 69 Plus   {
Add comment 42 70 IntPtr large, small;
Add comment 43 71 int x, y;
Add comment 44 72
Add comment 45 Minus   if (control.LargeImageList == null) {
Add comment 73 Plus   if (control.LargeImageList == null)
Add comment 74 Plus   {
Add comment 46 75 control.LargeImageList = new System.Windows.Forms.ImageList();
Add comment 47 76 }
Add comment 48 77
Add comment 49 Minus   if (control.SmallImageList == null) {
Add comment 78 Plus   if (control.SmallImageList == null)
Add comment 79 Plus   {
Add comment 50 80 control.SmallImageList = new System.Windows.Forms.ImageList();
Add comment 51 81 }
Add comment 52 82
Add comment 53 83 Shell32.FileIconInit(true);
Add comment 54 Minus   if (!Shell32.Shell_GetImageLists(out large, out small)) {
Add comment 84 Plus   if (!Shell32.Shell_GetImageLists(out large, out small))
Add comment 85 Plus   {
Add comment 55 86 throw new Exception("Failed to get system image list");
Add comment 56 87 }
Add comment 57 88
Add comment 60 91 ComCtl32.ImageList_GetIconSize(small, out x, out y);
Add comment 61 92 control.SmallImageList.ImageSize = new System.Drawing.Size(x, y);
Add comment 62 93
Add comment 63 Minus   User32.SendMessage(control.Handle, BExplorer.Shell.Interop.MSG.LVM_SETIMAGELIST,
Add comment 64 Minus   (int)LVSIL.LVSIL_NORMAL, LargeImageList);
Add comment 65 Minus   User32.SendMessage(control.Handle, BExplorer.Shell.Interop.MSG.LVM_SETIMAGELIST,
Add comment 66 Minus   (int)LVSIL.LVSIL_SMALL, SmallImageList);
Add comment 94 Plus   User32.SendMessage(control.Handle, MSG.LVM_SETIMAGELIST, (int)LVSIL.LVSIL_NORMAL, LargeImageList);
Add comment 95 Plus   User32.SendMessage(control.Handle, MSG.LVM_SETIMAGELIST, (int)LVSIL.LVSIL_SMALL, SmallImageList);
Add comment 67 96 }
Add comment 68 97
Add comment 69 Minus   public static void UseSystemImageList(TreeView control) {
Add comment 70 Minus   User32.SendMessage(control.Handle, BExplorer.Shell.Interop.MSG.TVM_SETIMAGELIST, 0, SmallImageList);
Add comment 71 Minus   }
Add comment 98 Plus   public static void UseSystemImageList(TreeView control) => User32.SendMessage(control.Handle, MSG.TVM_SETIMAGELIST, 0, SmallImageList);
Add comment 72 99
Add comment 73 Minus   static void InitializeImageLists() {
Add comment 100 Plus   static void InitializeImageLists()
Add comment 101 Plus   {
Add comment 74 102 Shell32.FileIconInit(true);
Add comment 75 Minus   if (!Shell32.Shell_GetImageLists(out m_LargeImageList, out m_SmallImageList)) {
Add comment 103 Plus   if (!Shell32.Shell_GetImageLists(out m_LargeImageList, out m_SmallImageList))
Add comment 104 Plus   {
Add comment 76 105 throw new Exception("Failed to get system image list");
Add comment 77 106 }
Add comment 78 107 }
Add comment 79 Minus  
Add comment 80 Minus   static IntPtr SmallImageList {
Add comment 81 Minus   get {
Add comment 82 Minus   if (m_SmallImageList == IntPtr.Zero) {
Add comment 83 Minus   InitializeImageLists();
Add comment 84 Minus   }
Add comment 85 Minus   return m_SmallImageList;
Add comment 86 Minus   }
Add comment 87 Minus   }
Add comment 88 Minus  
Add comment 89 Minus   static IntPtr LargeImageList {
Add comment 90 Minus   get {
Add comment 91 Minus   if (m_LargeImageList == IntPtr.Zero) {
Add comment 92 Minus   InitializeImageLists();
Add comment 93 Minus   }
Add comment 94 Minus   return m_LargeImageList;
Add comment 95 Minus   }
Add comment 96 Minus   }
Add comment 97 Minus  
Add comment 98 Minus   static IntPtr m_SmallImageList;
Add comment 99 Minus   static IntPtr m_LargeImageList;
Add comment 100 108 }
Add comment 101 109 }
Add comment 102 110