2020-04-08 15:19:00 +08: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.
|
|
|
|
|
|
2020-04-04 10:02:38 +08:00
|
|
|
|
using System.Text;
|
2020-04-17 02:45:27 +08:00
|
|
|
|
using System.Text.Json.Serialization;
|
2020-04-04 10:02:38 +08:00
|
|
|
|
|
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.Lib
|
|
|
|
|
{
|
|
|
|
|
public class HotkeySettings
|
|
|
|
|
{
|
2020-04-17 02:45:27 +08:00
|
|
|
|
public HotkeySettings()
|
|
|
|
|
{
|
|
|
|
|
this.Win = false;
|
|
|
|
|
this.Ctrl = false;
|
|
|
|
|
this.Alt = false;
|
|
|
|
|
this.Shift = false;
|
|
|
|
|
this.Key = string.Empty;
|
|
|
|
|
this.Code = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[JsonPropertyName("win")]
|
|
|
|
|
public bool Win { get; set; }
|
2020-04-08 15:19:00 +08:00
|
|
|
|
|
2020-04-17 02:45:27 +08:00
|
|
|
|
[JsonPropertyName("ctrl")]
|
|
|
|
|
public bool Ctrl { get; set; }
|
2020-04-08 15:19:00 +08:00
|
|
|
|
|
2020-04-17 02:45:27 +08:00
|
|
|
|
[JsonPropertyName("alt")]
|
|
|
|
|
public bool Alt { get; set; }
|
2020-04-08 15:19:00 +08:00
|
|
|
|
|
2020-04-17 02:45:27 +08:00
|
|
|
|
[JsonPropertyName("shift")]
|
|
|
|
|
public bool Shift { get; set; }
|
2020-04-08 15:19:00 +08:00
|
|
|
|
|
2020-04-17 02:45:27 +08:00
|
|
|
|
[JsonPropertyName("key")]
|
|
|
|
|
public string Key { get; set; }
|
2020-04-08 15:19:00 +08:00
|
|
|
|
|
2020-04-17 02:45:27 +08:00
|
|
|
|
[JsonPropertyName("code")]
|
|
|
|
|
public int Code { get; set; }
|
2020-04-04 10:02:38 +08:00
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
StringBuilder output = new StringBuilder();
|
|
|
|
|
|
2020-04-17 02:45:27 +08:00
|
|
|
|
if (Win)
|
2020-04-04 10:02:38 +08:00
|
|
|
|
{
|
|
|
|
|
output.Append("Win + ");
|
|
|
|
|
}
|
2020-04-08 15:19:00 +08:00
|
|
|
|
|
2020-04-17 02:45:27 +08:00
|
|
|
|
if (Ctrl)
|
2020-04-04 10:02:38 +08:00
|
|
|
|
{
|
|
|
|
|
output.Append("Ctrl + ");
|
|
|
|
|
}
|
2020-04-08 15:19:00 +08:00
|
|
|
|
|
2020-04-17 02:45:27 +08:00
|
|
|
|
if (Alt)
|
2020-04-04 10:02:38 +08:00
|
|
|
|
{
|
|
|
|
|
output.Append("Alt + ");
|
|
|
|
|
}
|
2020-04-08 15:19:00 +08:00
|
|
|
|
|
2020-04-17 02:45:27 +08:00
|
|
|
|
if (Shift)
|
2020-04-04 10:02:38 +08:00
|
|
|
|
{
|
|
|
|
|
output.Append("Shift + ");
|
|
|
|
|
}
|
2020-04-08 15:19:00 +08:00
|
|
|
|
|
2020-04-17 02:45:27 +08:00
|
|
|
|
output.Append(Key);
|
2020-04-04 10:02:38 +08:00
|
|
|
|
return output.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|