BExplorer.Shell.ShellView.ProcessShellNotifications C# (CSharp) Method

ProcessShellNotifications() private method

private ProcessShellNotifications ( Message &m ) : void
m Message
return void
    private void ProcessShellNotifications(ref Message m) {
      if (Notifications.NotificationReceipt(m.WParam, m.LParam)) {
        foreach (NotifyInfos info in Notifications.NotificationsReceived.ToArray()) {
          try {
            switch (info.Notification) {
              case ShellNotifications.SHCNE.SHCNE_MKDIR:
              case ShellNotifications.SHCNE.SHCNE_CREATE:
                try {
                  var obj = FileSystemListItem.ToFileSystemItem(this.LVHandle, info.Item1);
                  if (obj.IsInCurrentFolder(this.CurrentFolder)) {
                    if (this.IsRenameNeeded) {
                      var existingItem = this.Items.FirstOrDefault(s => s.Equals(obj));
                      if (existingItem == null) {
                        var itemIndex = this.InsertNewItem(obj);
                        this.SelectItemByIndex(itemIndex, true, true);
                        this.RenameSelectedItem(itemIndex);
                        this.IsRenameNeeded = false;
                      } else {
                        this.RenameSelectedItem(existingItem.ItemIndex);
                      }
                    } else if (this._ItemsQueue.Enqueue(new Tuple<ItemUpdateType, IListItemEx>(ItemUpdateType.Created, obj))) {
                      this.UnvalidateDirectory();
                    }
                  }
                } catch (FileNotFoundException) { }
                break;

              case ShellNotifications.SHCNE.SHCNE_RMDIR:
              case ShellNotifications.SHCNE.SHCNE_DELETE:
                var objDelete = FileSystemListItem.ToFileSystemItem(this.LVHandle, info.Item1);
                if (this._ItemsQueue.Enqueue(Tuple.Create(ItemUpdateType.RecycleBin, FileSystemListItem.InitializeWithIShellItem(IntPtr.Zero, ((ShellItem)KnownFolders.RecycleBin).ComInterface)))) {
                  this.UnvalidateDirectory();
                }
                if (objDelete.IsInCurrentFolder(this.CurrentFolder) && this._ItemsQueue.Enqueue(Tuple.Create(ItemUpdateType.Deleted, objDelete.Clone()), true)) {
                  this.UnvalidateDirectory();
                  this.RaiseItemUpdated(ItemUpdateType.Deleted, null, objDelete, -1);
                  objDelete.Dispose();
                  break;
                }
                break;

              case ShellNotifications.SHCNE.SHCNE_UPDATEDIR:
                IListItemEx objUpdate = null;
                try {
                  objUpdate = FileSystemListItem.ToFileSystemItem(this.LVHandle, Shell32.ILFindLastID(info.Item1));
                } catch { }
                if (objUpdate.IsInCurrentFolder(this.CurrentFolder)) {
                  this.UnvalidateDirectory();
                }
                break;

              case ShellNotifications.SHCNE.SHCNE_UPDATEITEM:
                var objUpdateItem = FileSystemListItem.ToFileSystemItem(this.LVHandle, info.Item1);
                if (objUpdateItem.IsInCurrentFolder(this.CurrentFolder)) {
                  var exisitingUItem = this.Items.ToArray().FirstOrDefault(w => w.Equals(objUpdateItem));
                  if (exisitingUItem != null) {
                    if (this.View == ShellViewStyle.Details) {
                      foreach (var collumn in this.Collumns) {
                        if (collumn.Index > 0 && this.IconSize == 16) {
						  this.SmallImageList.EnqueueSubitemsGet(new Tuple<Int32, Int32, PROPERTYKEY>(exisitingUItem.ItemIndex, collumn.Index, collumn.pkey));
                        }
                      }
                    }

                    if (this._ItemsQueue.Enqueue(new Tuple<ItemUpdateType, IListItemEx>(ItemUpdateType.Updated, exisitingUItem)))
                      this.UnvalidateDirectory();
                    //this.RefreshItem(exisitingUItem.ItemIndex, true);
                  }
                }
                break;

              case ShellNotifications.SHCNE.SHCNE_RENAMEFOLDER:
              case ShellNotifications.SHCNE.SHCNE_RENAMEITEM:
                var obj1 = FileSystemListItem.ToFileSystemItem(this.LVHandle, info.Item1);
                var obj2 = FileSystemListItem.ToFileSystemItem(this.LVHandle, info.Item2);
                if (!String.IsNullOrEmpty(obj1.ParsingName) && !String.IsNullOrEmpty(obj2.ParsingName))
                  this.UpdateItem(obj1, obj2);
                this.IsRenameInProgress = false;
                break;

              case ShellNotifications.SHCNE.SHCNE_NETSHARE:
              case ShellNotifications.SHCNE.SHCNE_NETUNSHARE:
              case ShellNotifications.SHCNE.SHCNE_ATTRIBUTES:
                var objNetA = FileSystemListItem.ToFileSystemItem(this.LVHandle, info.Item1);
                var exisitingItemNetA = this.Items.FirstOrDefault(w => w.Equals(objNetA));
                if (this.View == ShellViewStyle.Details) {
                  foreach (var collumn in this.Collumns) {
                    if (collumn.Index > 0 &&this.IconSize == 16) {
                        this.SmallImageList.EnqueueSubitemsGet(new Tuple<Int32, Int32, PROPERTYKEY>(exisitingItemNetA.ItemIndex, collumn.Index, collumn.pkey));
                    }
                  }
                }
                this._ItemsQueue.Enqueue(new Tuple<ItemUpdateType, IListItemEx>(ItemUpdateType.Updated, exisitingItemNetA));
                break;

              case ShellNotifications.SHCNE.SHCNE_MEDIAINSERTED:
              case ShellNotifications.SHCNE.SHCNE_MEDIAREMOVED:
                if (this.CurrentFolder.ParsingName == KnownFolders.Computer.ParsingName) {
                  var objMedia = FileSystemListItem.ToFileSystemItem(this.LVHandle, info.Item1);
                  var exisitingItem = this.Items.SingleOrDefault(w => w.Equals(objMedia));
                  if (exisitingItem != null)
                    this.UpdateItem(exisitingItem.ItemIndex);
                }
                break;

              case ShellNotifications.SHCNE.SHCNE_DRIVEREMOVED:
                var objDr = FileSystemListItem.ToFileSystemItem(this.LVHandle, info.Item1);
                if (this.CurrentFolder != null && this.CurrentFolder.ParsingName.Equals(KnownFolders.Computer.ParsingName)) {
                  this.Items.Remove(objDr);
                  var i = 0;
                  this.Items.ToList().ForEach(e => e.ItemIndex = i++);
                  if (this.IsGroupsEnabled) this.SetGroupOrder(false);

                  User32.SendMessage(this.LVHandle, MSG.LVM_SETITEMCOUNT, this.Items.Count, 0);
                }
                this.RaiseItemUpdated(ItemUpdateType.DriveRemoved, null, objDr, -1);
                break;

              case ShellNotifications.SHCNE.SHCNE_DRIVEADD:
                if (this.CurrentFolder != null && this.CurrentFolder.ParsingName.Equals(KnownFolders.Computer.ParsingName))
                  this.InsertNewItem(FileSystemListItem.ToFileSystemItem(this.LVHandle, info.Item1));
                break;
              case ShellNotifications.SHCNE.SHCNE_FREESPACE:
                //if (this._ItemsQueue.Enqueue(Tuple.Create(ItemUpdateType.RecycleBin, FileSystemListItem.InitializeWithIShellItem(IntPtr.Zero, ((ShellItem)KnownFolders.RecycleBin).ComInterface)))) {
                //	this.UnvalidateDirectory();
                //}
                break;
              case ShellNotifications.SHCNE.SHCNE_UPDATEIMAGE:

                break;
            }
          } catch {
          }

          Notifications.NotificationsReceived.Remove(info);
        }
      }
    }
ShellView