internal void OnShellItemUpdate(object sender, ShellItemUpdateEventArgs e) { if (ShellItemUpdate != null) { ShellItemUpdate(sender, e); } }
private void ShellItemUpdateInvoke(object sender, ShellItemUpdateEventArgs e) { switch (e.UpdateType) { case ShellItemUpdateType.Created: #region Created { if (Object.Equals(sender, selectedItem)) { string[] subItems = new string[fileView.Columns.Count - 1]; ListViewItem newListItem = GetListViewItem(subItems, e.NewItem); fileView.Items.Add(newListItem); if (newItemCreated) { newItemCreated = false; foreach (ListViewItem item in fileView.Items) item.Selected = false; newListItem.Selected = true; newListItem.BeginEdit(); } } if (e.NewItem.IsFolder) { ShellItem parent = sender as ShellItem; TreeNode parentNode; if (folderView.GetTreeNode(parent, out parentNode)) { TreeNode newNode = new TreeNode( e.NewItem.Text, e.NewItem.ImageIndex, e.NewItem.SelectedImageIndex); newNode.Tag = e.NewItem; if (e.NewItem.HasSubfolder) newNode.Nodes.Add(string.Empty); newNode.Name = newNode.Text; parentNode.Nodes.Add(newNode); } } } #endregion break; case ShellItemUpdateType.Deleted: #region Deleted { ListViewItem listItem; if (Object.Equals(sender, selectedItem) && fileView.GetListItem(e.OldItem, out listItem)) { fileView.Items.Remove(listItem); } if (e.OldItem.IsFolder) { ShellItem parent = sender as ShellItem; TreeNode parentNode; if (folderView.GetTreeNode(parent, out parentNode)) { parentNode.Nodes.RemoveByKey(e.OldItem.Text); } } } #endregion break; case ShellItemUpdateType.Renamed: #region Renamed { ListViewItem listItem; if (Object.Equals(sender, selectedItem) && fileView.GetListItem(e.OldItem, out listItem)) { listItem.Text = e.NewItem.Text; listItem.Name = listItem.Text; } if (e.NewItem.IsFolder) { TreeNode node; if (folderView.GetTreeNode(e.NewItem, out node)) { node.Text = e.NewItem.Text; node.Name = node.Text; TreeNode parent = node.Parent; parent.Nodes.Remove(node); parent.Nodes.Add(node); } } } #endregion break; case ShellItemUpdateType.IconChange: #region IconChange { ListViewItem listItem; if (Object.Equals(sender, selectedItem) && fileView.GetListItem(e.OldItem, out listItem) && listItem.ImageIndex != e.NewItem.ImageIndex) { listItem.ImageIndex = e.NewItem.ImageIndex; } if (e.NewItem.IsFolder) { TreeNode node; if (folderView.GetTreeNode(e.NewItem, out node) && node.ImageIndex != e.NewItem.ImageIndex) { node.ImageIndex = e.NewItem.ImageIndex; } } } #endregion break; case ShellItemUpdateType.MediaChange: #region MediaChange { ListViewItem listItem; if (Object.Equals(sender, selectedItem) && fileView.GetListItem(e.OldItem, out listItem)) { listItem.ImageIndex = e.NewItem.ImageIndex; } TreeNode node; if (folderView.GetTreeNode(e.NewItem, out node)) { node.Collapse(true); if (node.Equals(selectedNode) || folderView.IsParentNode(node, selectedNode)) folderView.SelectedNode = node.Parent; node.Nodes.Clear(); node.ImageIndex = e.NewItem.ImageIndex; if (e.NewItem.HasSubfolder) node.Nodes.Add(string.Empty); } } #endregion break; } }
void shellBrowser_ShellItemUpdate(object sender, ShellItemUpdateEventArgs e) { if (updating) { if (this.InvokeRequired) Invoke(updateInvoker, sender, e); else ShellItemUpdateInvoke(sender, e); } }
private void ShellItemUpdateInvoke(object sender, ShellItemUpdateEventArgs e) { switch (e.UpdateType) { case ShellItemUpdateType.Created: #region Created { if (e.NewItem.IsFolder) { ShellItem parent = sender as ShellItem; TreeNode parentNode; if (folderView.GetTreeNode(parent, out parentNode)) { TreeNode newNode = new TreeNode( e.NewItem.Text, e.NewItem.ImageIndex, e.NewItem.SelectedImageIndex); newNode.Tag = e.NewItem; if (e.NewItem.HasSubfolder) newNode.Nodes.Add(string.Empty); newNode.Name = newNode.Text; parentNode.Nodes.Add(newNode); } } } #endregion break; case ShellItemUpdateType.Deleted: #region Deleted { if (e.OldItem.IsFolder) { ShellItem parent = sender as ShellItem; TreeNode parentNode; if (folderView.GetTreeNode(parent, out parentNode)) { parentNode.Nodes.RemoveByKey(e.OldItem.Text); } } } #endregion break; case ShellItemUpdateType.Renamed: #region Renamed { if (e.NewItem.IsFolder) { TreeNode node; if (folderView.GetTreeNode(e.NewItem, out node)) { node.Text = e.NewItem.Text; node.Name = node.Text; TreeNode parent = node.Parent; parent.Nodes.Remove(node); parent.Nodes.Add(node); } } } #endregion break; case ShellItemUpdateType.IconChange: #region IconChange { if (e.NewItem.IsFolder) { TreeNode node; if (folderView.GetTreeNode(e.NewItem, out node) && node.ImageIndex != e.NewItem.ImageIndex) { node.ImageIndex = e.NewItem.ImageIndex; } } } #endregion break; case ShellItemUpdateType.MediaChange: #region MediaChange { TreeNode node; if (folderView.GetTreeNode(e.NewItem, out node)) { node.Collapse(true); if (node.Equals(selectedNode) || folderView.IsParentNode(node, selectedNode)) folderView.SelectedNode = node.Parent; node.Nodes.Clear(); node.ImageIndex = e.NewItem.ImageIndex; if (e.NewItem.HasSubfolder) node.Nodes.Add(string.Empty); } } #endregion break; } }
private void shellBrowser_ShellItemUpdate(object sender, ShellItemUpdateEventArgs e) { if(_isUpdating) { if(InvokeRequired) { Invoke(new EventHandler<ShellItemUpdateEventArgs>(ShellItemUpdateInvoke), sender, e); } else { ShellItemUpdateInvoke(sender, e); } } }