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.
|
|
|
|
|
|
|
2024-04-02 01:09:47 +02:00
|
|
|
|
using System.Globalization;
|
2020-04-16 11:45:27 -07:00
|
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
|
|
|
2020-10-22 09:45:48 -07:00
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.Library
|
2020-04-16 11:45:27 -07:00
|
|
|
|
{
|
2024-04-02 01:09:47 +02:00
|
|
|
|
public record KeyboardKeysProperty : ICmdLineRepresentable
|
2020-04-16 11:45:27 -07:00
|
|
|
|
{
|
2020-07-21 14:06:39 -07:00
|
|
|
|
public KeyboardKeysProperty()
|
2020-04-16 11:45:27 -07:00
|
|
|
|
{
|
2020-07-21 14:06:39 -07:00
|
|
|
|
Value = new HotkeySettings();
|
2020-04-16 11:45:27 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-07-21 14:06:39 -07:00
|
|
|
|
public KeyboardKeysProperty(HotkeySettings hkSettings)
|
2020-05-08 08:22:57 -07:00
|
|
|
|
{
|
2020-07-21 14:06:39 -07:00
|
|
|
|
Value = hkSettings;
|
2020-05-08 08:22:57 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-04-16 11:45:27 -07:00
|
|
|
|
[JsonPropertyName("value")]
|
|
|
|
|
|
public HotkeySettings Value { get; set; }
|
2024-04-02 01:09:47 +02:00
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
}
|