Esempio n. 1
0
		private void ShellTreeView_KeyDown(object sender, KeyEventArgs e) {
			if ((Control.ModifierKeys & Keys.Control) == Keys.Control) {
				switch (e.KeyCode) {
					case Keys.C:
						this.CopySelectedFiles();
						break;

					case Keys.V:
						this.PasteAvailableFiles();
						break;

					case Keys.X:
						this.CutSelectedFiles();
						break;
				}
			} else if (e.KeyCode == Keys.F2) {
				this.RenameSelectedNode();
			} else if (e.KeyCode == Keys.F5) {
				this.RefreshContents();
			} else if (e.KeyCode == Keys.Escape) {
				var item = new TVITEMW() { mask = TVIF.TVIF_STATE, stateMask = TVIS.TVIS_CUT, state = 0, hItem = this.cuttedNode.Handle };
				User32.SendMessage(this.ShellTreeView.Handle, MSG.TVM_SETITEMW, 0, ref item);
				Clipboard.Clear();
			}
		}
Esempio n. 2
0
		/// <summary>Cuts the currently selected items (signals the UI and saves items into the clipboard)</summary>
		private void CutSelectedFiles() {
			var item = new TVITEMW() {
				mask = TVIF.TVIF_STATE,
				stateMask = TVIS.TVIS_CUT,
				state = TVIS.TVIS_CUT,
				hItem = this.ShellTreeView.SelectedNode.Handle,
			};

			User32.SendMessage(this.ShellTreeView.Handle, MSG.TVM_SETITEMW, 0, ref item);

			this.cuttedNode = this.ShellTreeView.SelectedNode;
			var selectedItems = new[] { this.ShellTreeView.SelectedNode.Tag as IListItemEx };
			var ddataObject = new F.DataObject();
			// Copy or Cut operation (5 = copy; 2 = cut)
			ddataObject.SetData("Preferred DropEffect", true, new MemoryStream(new byte[] { 2, 0, 0, 0 }));
			ddataObject.SetData("Shell IDList Array", true, selectedItems.CreateShellIDList());
			Clipboard.SetDataObject(ddataObject, true);
		}
Esempio n. 3
0
 public static extern int SendMessage(IntPtr hWnd, MSG Msg,
                                      int wParam, ref TVITEMW lParam);
Esempio n. 4
0
		private void SetNodeImage(IntPtr node, IntPtr pidl, IntPtr m_TreeViewHandle, Boolean isOverlayed) {
			try {
				var itemInfo = new TVITEMW();

				// We need to set the images for the item by sending a
				// TVM_SETITEMW message, as we need to set the overlay images,
				// and the .Net TreeView API does not support overlays.
				itemInfo.mask = TVIF.TVIF_IMAGE | TVIF.TVIF_SELECTEDIMAGE | TVIF.TVIF_STATE;
				itemInfo.hItem = node;
				itemInfo.iImage = ShellItem.GetSystemImageListIndex(pidl, ShellIconType.SmallIcon, ShellIconFlags.OverlayIndex);
				if (isOverlayed) {
					itemInfo.state = (TVIS)(itemInfo.iImage >> 16);
					itemInfo.stateMask = TVIS.TVIS_OVERLAYMASK;
				}
				itemInfo.iSelectedImage = ShellItem.GetSystemImageListIndex(pidl, ShellIconType.SmallIcon, ShellIconFlags.OpenIcon);
				this.UpdatedImages.Add(node);
				User32.SendMessage(m_TreeViewHandle, MSG.TVM_SETITEMW, 0, ref itemInfo);
			} catch (Exception) {
			}
		}
Esempio n. 5
0
		public static extern int SendMessage(IntPtr hWnd, MSG Msg, int wParam, ref TVITEMW lParam);