public void Execute() { string path; var selectedItem = this.treeViewModel.SelectedItem; if (selectedItem == null) { path = this.workspaceDirectoryModel.CurrentWorkspaceDirectory; } else { path = selectedItem.Path; } if (String.IsNullOrEmpty(path) || (!File.Exists(path) && !Directory.Exists(path))) { return; } var uri = new Uri(path); ShellItem shellItem = new ShellItem(uri); ShellContextMenu menu = new ShellContextMenu(shellItem); try { menu.ShowContextMenu(System.Windows.Forms.Control.MousePosition); } catch (Exception ex) { Logger.Error(ex, "Failed to show Windows Explorer Context Menu"); } }
private void Item_MouseRightButtonDown(object sender, MouseButtonEventArgs e) { FileItem item = (FileItem)sender; ShellItem myFile = new ShellItem(new Uri(item.Filepath)); ShellContextMenu ctxmenu = new ShellContextMenu(myFile); ctxmenu.ShowContextMenu(null, Helpers.GetMousePosition()); }