/ src / settings-ui / Settings.UI.Library / FindMyMouseSettings.cs
FindMyMouseSettings.cs
 1  // Copyright (c) Microsoft Corporation
 2  // The Microsoft Corporation licenses this file to you under the MIT license.
 3  // See the LICENSE file in the project root for more information.
 4  
 5  using System.Collections.Generic;
 6  using System.Text.Json.Serialization;
 7  using ManagedCommon;
 8  using Microsoft.PowerToys.Settings.UI.Library.Helpers;
 9  using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
10  
11  namespace Microsoft.PowerToys.Settings.UI.Library
12  {
13      public class FindMyMouseSettings : BasePTModuleSettings, ISettingsConfig, IHotkeyConfig
14      {
15          public const string ModuleName = "FindMyMouse";
16  
17          [JsonPropertyName("properties")]
18          public FindMyMouseProperties Properties { get; set; }
19  
20          public FindMyMouseSettings()
21          {
22              Name = ModuleName;
23              Properties = new FindMyMouseProperties();
24              Version = "1.1";
25          }
26  
27          public string GetModuleName()
28          {
29              return Name;
30          }
31  
32          public ModuleType GetModuleType() => ModuleType.FindMyMouse;
33  
34          public HotkeyAccessor[] GetAllHotkeyAccessors()
35          {
36              var hotkeyAccessors = new List<HotkeyAccessor>
37              {
38                  new HotkeyAccessor(
39                      () => Properties.ActivationShortcut,
40                      value => Properties.ActivationShortcut = value ?? Properties.DefaultActivationShortcut,
41                      "MouseUtils_FindMyMouse_ActivationShortcut"),
42              };
43  
44              return hotkeyAccessors.ToArray();
45          }
46  
47          // This can be utilized in the future if the settings.json file is to be modified/deleted.
48          public bool UpgradeSettingsConfiguration()
49          {
50              if (Version == "1.0")
51              {
52                  if (Properties.ActivationMethod.Value == 1)
53                  {
54                      Properties.ActivationMethod = new IntProperty(2);
55                  }
56  
57                  Version = "1.1";
58                  return true;
59              }
60  
61              return false;
62          }
63      }
64  }