KeyBoardKeysProperty.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.Globalization; 6 using System.Text.Json.Serialization; 7 8 namespace Microsoft.PowerToys.Settings.UI.Library 9 { 10 public record KeyboardKeysProperty : ICmdLineRepresentable 11 { 12 public KeyboardKeysProperty() 13 { 14 Value = new HotkeySettings(); 15 } 16 17 public KeyboardKeysProperty(HotkeySettings hkSettings) 18 { 19 Value = hkSettings; 20 } 21 22 [JsonPropertyName("value")] 23 public HotkeySettings Value { get; set; } 24 25 public static bool TryParseFromCmd(string cmd, out object result) 26 { 27 if (!HotkeySettings.TryParseFromCmd(cmd, out var hotkey)) 28 { 29 result = null; 30 return false; 31 } 32 else 33 { 34 result = new KeyboardKeysProperty { Value = (HotkeySettings)hotkey }; 35 return true; 36 } 37 } 38 39 public bool TryToCmdRepresentable(out string result) 40 { 41 return Value.TryToCmdRepresentable(out result); 42 } 43 } 44 }