PowerToys/src/core/Microsoft.PowerToys.Settings.UI.Lib/HotkeySettings.cs

69 lines
1.6 KiB
C#
Raw Normal View History

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.
using System.Text;
2020-04-17 02:45:27 +08:00
using System.Text.Json.Serialization;
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; }
public override string ToString()
{
StringBuilder output = new StringBuilder();
2020-04-17 02:45:27 +08:00
if (Win)
{
output.Append("Win + ");
}
2020-04-08 15:19:00 +08:00
2020-04-17 02:45:27 +08:00
if (Ctrl)
{
output.Append("Ctrl + ");
}
2020-04-08 15:19:00 +08:00
2020-04-17 02:45:27 +08:00
if (Alt)
{
output.Append("Alt + ");
}
2020-04-08 15:19:00 +08:00
2020-04-17 02:45:27 +08:00
if (Shift)
{
output.Append("Shift + ");
}
2020-04-08 15:19:00 +08:00
2020-04-17 02:45:27 +08:00
output.Append(Key);
return output.ToString();
}
}
}