/// <summary> /// Handles the context menu. /// </summary> /// <param name="listBox">The list box.</param> /// <param name="leftSide">if set to <c>true</c> [left side].</param> protected virtual void HandleContextMenu(IronyModManager.Controls.ListBox listBox, bool leftSide) { List <MenuItem> menuItems = null; var hoveredItem = listBox.GetLogicalChildren().Cast <ListBoxItem>().FirstOrDefault(p => p.IsPointerOver); if (hoveredItem != null) { if (!ViewModel.RightSidePatchMod && !ViewModel.LeftSidePatchMod) { menuItems = GetNonEditableMenuItems(leftSide); } else { if (leftSide) { menuItems = ViewModel.RightSidePatchMod ? GetActionsMenuItems(leftSide) : GetEditableMenuItems(leftSide); } else { menuItems = ViewModel.LeftSidePatchMod ? GetActionsMenuItems(leftSide) : GetEditableMenuItems(leftSide); } } } listBox.SetContextMenu(menuItems); }
/// <summary> /// Binds the ListBox pointer. /// </summary> /// <param name="listBox">The list box.</param> protected virtual void BindListBoxPointer(IronyModManager.Controls.ListBox listBox) { listBox.ContextMenuOpening += (sender, args) => { List <MenuItem> menuItems = null; var hoveredItem = listBox.GetLogicalChildren().Cast <ListBoxItem>().FirstOrDefault(p => p.IsPointerOver); if (hoveredItem != null) { ViewModel.SetParameters(hoveredItem.Content as IDefinition); if (!string.IsNullOrWhiteSpace(ViewModel.ConflictPath)) { menuItems = new List <MenuItem>() { new MenuItem() { Header = ViewModel.OpenFile, Command = ViewModel.OpenFileCommand } }; if (!ViewModel.ConflictPath.EndsWith(Shared.Constants.ZipExtension, StringComparison.OrdinalIgnoreCase) && !ViewModel.ConflictPath.EndsWith(Shared.Constants.BinExtension, StringComparison.OrdinalIgnoreCase)) { menuItems.Add(new MenuItem() { Header = ViewModel.OpenDirectory, Command = ViewModel.OpenDirectoryCommand }); } } } listBox.SetContextMenu(menuItems); }; }