Files
PowerToys/src/settings-ui/Settings.UI.Library/KeyBoardKeysProperty.cs

45 lines
1.2 KiB
C#
Raw Normal View History

2020-04-16 11:45:27 -07:00
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Globalization;
2020-04-16 11:45:27 -07:00
using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.Library
2020-04-16 11:45:27 -07:00
{
public record KeyboardKeysProperty : ICmdLineRepresentable
2020-04-16 11:45:27 -07:00
{
public KeyboardKeysProperty()
2020-04-16 11:45:27 -07:00
{
Value = new HotkeySettings();
2020-04-16 11:45:27 -07:00
}
public KeyboardKeysProperty(HotkeySettings hkSettings)
{
Value = hkSettings;
}
2020-04-16 11:45:27 -07:00
[JsonPropertyName("value")]
public HotkeySettings Value { get; set; }
public static bool TryParseFromCmd(string cmd, out object result)
{
if (!HotkeySettings.TryParseFromCmd(cmd, out var hotkey))
{
result = null;
return false;
}
else
{
result = new KeyboardKeysProperty { Value = (HotkeySettings)hotkey };
return true;
}
}
public bool TryToCmdRepresentable(out string result)
{
return Value.TryToCmdRepresentable(out result);
}
2020-04-16 11:45:27 -07:00
}
}