Beispiel #1
0
 /// <summary>
 /// Binds the ListBox pointer.
 /// </summary>
 /// <param name="listBox">The list box.</param>
 protected virtual void BindListBoxPointer(IronyModManager.Controls.ListBox listBox)
 {
     listBox.ContextMenuOpening += (item) =>
     {
         List <MenuItem> menuItems = null;
         if (item != null)
         {
             ViewModel.SetParameters(item.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.SetContextMenuItems(menuItems);
     };
 }
Beispiel #2
0
        /// <summary>
        /// Handles the context menu.
        /// </summary>
        /// <param name="listBox">The list box.</param>
        /// <param name="hoveredItem">The hovered item.</param>
        /// <param name="leftSide">if set to <c>true</c> [left side].</param>
        protected virtual void HandleContextMenu(IronyModManager.Controls.ListBox listBox, ListBoxItem hoveredItem, bool leftSide)
        {
            List <MenuItem> menuItems = null;

            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.SetContextMenuItems(menuItems);
        }