public ShellItemContextMenu(ShellItem[] files, ShellFolder parentFolder, IntPtr hwndOwner, ItemSelectAction itemSelected, bool isInteractive, bool canRename, ShellMenuCommandBuilder preBuilder, ShellMenuCommandBuilder postBuilder) { if (files == null || files.Length < 1) { return; } lock (IconHelper.ComLock) { x = Cursor.Position.X; y = Cursor.Position.Y; this.itemSelected = itemSelected; SetupContextMenu(files, parentFolder, hwndOwner, isInteractive, canRename, preBuilder, postBuilder); } }
public ShellContextMenu(SystemFile[] files, ItemSelectAction itemSelected) { lock (Shell.ComLock) { CreateHandle(new CreateParams()); paths = files; parent = getParentDir(paths[0].FullName); parentShellFolder = getParentShellFolder(paths[0].FullName); pidls = pathsToPidls(paths); x = Cursor.Position.X; y = Cursor.Position.Y; this.itemSelected = itemSelected; ShowContextMenu(); } }
public ShellContextMenu(SystemFile[] files, System.Windows.Controls.Button sender, ItemSelectAction itemSelected) { lock (Shell.ComLock) { this.CreateHandle(new CreateParams()); this.paths = files; this.parent = getParentDir(this.paths[0].FullName); this.parentShellFolder = getParentShellFolder(this.paths[0].FullName); this.pidls = pathsToPidls(this.paths); this.x = Cursor.Position.X; this.y = Cursor.Position.Y; this.itemSelected = itemSelected; this.sender = sender; ShowContextMenu(); } }
// Helper method for common icon invokation code. public static void OpenContextMenuFromIcon(System.Windows.Input.MouseButtonEventArgs e, ItemSelectAction action) { System.Windows.Controls.Button btn = null; if (e.OriginalSource.GetType() == typeof(System.Windows.Controls.Image)) { System.Windows.Controls.Image img = e.OriginalSource as System.Windows.Controls.Image; System.Windows.Controls.DockPanel dock = img.Parent as System.Windows.Controls.DockPanel; btn = dock.Parent as System.Windows.Controls.Button; } else if (e.OriginalSource.GetType() == typeof(System.Windows.Controls.TextBlock)) { System.Windows.Controls.TextBlock txt = e.OriginalSource as System.Windows.Controls.TextBlock; System.Windows.Controls.Border bdr = txt.Parent as System.Windows.Controls.Border; System.Windows.Controls.DockPanel dock = bdr.Parent as System.Windows.Controls.DockPanel; btn = dock.Parent as System.Windows.Controls.Button; } else if (e.OriginalSource.GetType() == typeof(System.Windows.Controls.Border) && (e.OriginalSource as System.Windows.Controls.Border).Parent != null && (e.OriginalSource as System.Windows.Controls.Border).Parent.GetType() == typeof(System.Windows.Controls.DockPanel)) { System.Windows.Controls.Border bdr = e.OriginalSource as System.Windows.Controls.Border; System.Windows.Controls.DockPanel dock = bdr.Parent as System.Windows.Controls.DockPanel; btn = dock.Parent as System.Windows.Controls.Button; } else if (e.OriginalSource.GetType() == typeof(System.Windows.Controls.DockPanel)) { System.Windows.Controls.DockPanel dock = e.OriginalSource as System.Windows.Controls.DockPanel; btn = dock.Parent as System.Windows.Controls.Button; } else if (e.OriginalSource.GetType() == typeof(System.Windows.Controls.Border)) { System.Windows.Controls.Border bdr = e.OriginalSource as System.Windows.Controls.Border; btn = bdr.TemplatedParent as System.Windows.Controls.Button; } if (btn != null) { //string filePath = btn.CommandParameter as string; SystemFile file = btn.DataContext as SystemFile; ShellContextMenu cm = new ShellContextMenu(new SystemFile[] { file }, btn, action); e.Handled = true; } else { CairoLogger.Instance.Debug("Surface was right-clicked but it wasn't a recognized object."); } }
// Helper method for common icon invocation code. public static void OpenContextMenuFromIcon(System.Windows.Input.MouseButtonEventArgs e, ItemSelectAction action) { if (typeof(FrameworkElement).IsAssignableFrom(e.OriginalSource.GetType())) { FrameworkElement el = e.OriginalSource as FrameworkElement; SystemFile file = el.DataContext as SystemFile; ShellContextMenu cm = new ShellContextMenu(new SystemFile[] { file }, el, action); e.Handled = true; } else { CairoLogger.Instance.Debug("Surface was right-clicked but it wasn't a recognized object."); } }
public ShellItemContextMenu(ShellItem[] files, ShellFolder parentFolder, IntPtr hwndOwner, ItemSelectAction itemSelected, bool isInteractive, ShellMenuCommandBuilder preBuilder, ShellMenuCommandBuilder postBuilder) : this(files, parentFolder, hwndOwner, itemSelected, isInteractive, true, preBuilder, postBuilder) { }
public ShellItemContextMenu(ShellItem[] files, ShellFolder parentFolder, IntPtr hwndOwner, ItemSelectAction itemSelected, bool isInteractive) : this(files, parentFolder, hwndOwner, itemSelected, isInteractive, new ShellMenuCommandBuilder(), new ShellMenuCommandBuilder()) { }