2020-08-18 01:00:56 +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.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2020-09-24 04:20:32 +08:00
|
|
|
|
using System.Text.Json;
|
2020-08-18 01:00:56 +08:00
|
|
|
|
using System.Text.Json.Serialization;
|
2020-10-23 00:45:48 +08:00
|
|
|
|
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
|
2020-08-18 01:00:56 +08:00
|
|
|
|
|
2020-10-23 00:45:48 +08:00
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.Library
|
2020-08-18 01:00:56 +08:00
|
|
|
|
{
|
|
|
|
|
public class KeysDataModel
|
|
|
|
|
{
|
|
|
|
|
[JsonPropertyName("originalKeys")]
|
|
|
|
|
public string OriginalKeys { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonPropertyName("newRemapKeys")]
|
|
|
|
|
public string NewRemapKeys { get; set; }
|
|
|
|
|
|
2020-10-10 08:58:52 +08:00
|
|
|
|
private static List<string> MapKeys(string stringOfKeys)
|
2020-08-18 01:00:56 +08:00
|
|
|
|
{
|
|
|
|
|
return stringOfKeys
|
|
|
|
|
.Split(';')
|
|
|
|
|
.Select(uint.Parse)
|
|
|
|
|
.Select(Helper.GetKeyName)
|
|
|
|
|
.ToList();
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-10 08:58:52 +08:00
|
|
|
|
public List<string> GetMappedOriginalKeys()
|
2020-08-18 01:00:56 +08:00
|
|
|
|
{
|
|
|
|
|
return MapKeys(OriginalKeys);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-10 08:58:52 +08:00
|
|
|
|
public List<string> GetMappedNewRemapKeys()
|
2020-08-18 01:00:56 +08:00
|
|
|
|
{
|
|
|
|
|
return MapKeys(NewRemapKeys);
|
|
|
|
|
}
|
2020-09-24 04:20:32 +08:00
|
|
|
|
|
|
|
|
|
public string ToJsonString()
|
|
|
|
|
{
|
|
|
|
|
return JsonSerializer.Serialize(this);
|
|
|
|
|
}
|
2020-08-18 01:00:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|