ContextMenuHelper.cs
1 // Copyright (c) Microsoft Corporation 2 // The Microsoft Corporation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System; 6 using System.Collections.Generic; 7 using System.Windows; 8 using System.Windows.Input; 9 using Microsoft.CmdPal.Ext.Registry.Classes; 10 using Microsoft.CmdPal.Ext.Registry.Commands; 11 using Microsoft.CmdPal.Ext.Registry.Properties; 12 using Microsoft.CommandPalette.Extensions.Toolkit; 13 14 namespace Microsoft.CmdPal.Ext.Registry.Helpers; 15 16 /// <summary> 17 /// Helper class to easier work with context menu entries 18 /// </summary> 19 internal static class ContextMenuHelper 20 { 21 /// <summary> 22 /// Return a list with all context menu entries for the given <see cref="Result"/> 23 /// <para>Symbols taken from <see href="https://learn.microsoft.com/windows/uwp/design/style/segoe-ui-symbol-font"/></para> 24 /// </summary> 25 internal static List<CommandContextItem> GetContextMenu(RegistryEntry entry) 26 { 27 var list = new List<CommandContextItem>(); 28 29 if (string.IsNullOrEmpty(entry.ValueName)) 30 { 31 list.Add(new CommandContextItem(new CopyRegistryInfoCommand(entry, CopyType.Key))); 32 } 33 else 34 { 35 list.Add(new CommandContextItem(new CopyRegistryInfoCommand(entry, CopyType.ValueData))); 36 list.Add(new CommandContextItem(new CopyRegistryInfoCommand(entry, CopyType.ValueName))); 37 } 38 39 // list.Add(new CommandContextItem(new OpenKeyInEditorCommand(entry))); 40 return list; 41 } 42 }