/ src / settings-ui / Settings.UI.Library / MeasureToolSettings.cs
MeasureToolSettings.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 MeasureToolSettings : BasePTModuleSettings, ISettingsConfig, IHotkeyConfig
14      {
15          public const string ModuleName = "Measure Tool";
16  
17          [JsonPropertyName("properties")]
18          public MeasureToolProperties Properties { get; set; }
19  
20          public MeasureToolSettings()
21          {
22              Properties = new MeasureToolProperties();
23              Version = "1";
24              Name = ModuleName;
25          }
26  
27          public string GetModuleName()
28              => Name;
29  
30          public ModuleType GetModuleType() => ModuleType.MeasureTool;
31  
32          public HotkeyAccessor[] GetAllHotkeyAccessors()
33          {
34              var hotkeyAccessors = new List<HotkeyAccessor>
35              {
36                  new HotkeyAccessor(
37                      () => Properties.ActivationShortcut,
38                      value => Properties.ActivationShortcut = value ?? Properties.DefaultActivationShortcut,
39                      "MeasureTool_ActivationShortcut"),
40              };
41  
42              return hotkeyAccessors.ToArray();
43          }
44  
45          // This can be utilized in the future if the settings.json file is to be modified/deleted.
46          public bool UpgradeSettingsConfiguration()
47              => false;
48      }
49  }