HotkeyData.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.Linq; 8 using System.Text; 9 using System.Threading.Tasks; 10 using Microsoft.PowerToys.Settings.UI.Library.Utilities; 11 12 namespace Microsoft.PowerToys.Settings.UI.Library.HotkeyConflicts 13 { 14 public class HotkeyData 15 { 16 public bool Win { get; set; } 17 18 public bool Ctrl { get; set; } 19 20 public bool Shift { get; set; } 21 22 public bool Alt { get; set; } 23 24 public int Key { get; set; } 25 26 public List<object> GetKeysList() 27 { 28 List<object> shortcutList = new List<object>(); 29 30 if (Win) 31 { 32 shortcutList.Add(92); // The Windows key or button. 33 } 34 35 if (Ctrl) 36 { 37 shortcutList.Add("Ctrl"); 38 } 39 40 if (Alt) 41 { 42 shortcutList.Add("Alt"); 43 } 44 45 if (Shift) 46 { 47 shortcutList.Add(16); // The Shift key or button. 48 } 49 50 if (Key > 0) 51 { 52 switch (Key) 53 { 54 // https://learn.microsoft.com/uwp/api/windows.system.virtualkey?view=winrt-20348 55 case 38: // The Up Arrow key or button. 56 case 40: // The Down Arrow key or button. 57 case 37: // The Left Arrow key or button. 58 case 39: // The Right Arrow key or button. 59 shortcutList.Add(Key); 60 break; 61 default: 62 var localKey = Helper.GetKeyName((uint)Key); 63 shortcutList.Add(localKey); 64 break; 65 } 66 } 67 68 return shortcutList; 69 } 70 } 71 }