LightSwitchSettings.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; 6 using System.Collections.Generic; 7 using System.Reflection; 8 using System.Text.Json.Serialization; 9 using ManagedCommon; 10 using Microsoft.PowerToys.Settings.UI.Library; 11 using Microsoft.PowerToys.Settings.UI.Library.Helpers; 12 using Microsoft.PowerToys.Settings.UI.Library.Interfaces; 13 14 namespace Microsoft.PowerToys.Settings.UI.Library 15 { 16 public class LightSwitchSettings : BasePTModuleSettings, ISettingsConfig, ICloneable, IHotkeyConfig 17 { 18 public const string ModuleName = "LightSwitch"; 19 20 public LightSwitchSettings() 21 { 22 Name = ModuleName; 23 Version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); 24 Properties = new LightSwitchProperties(); 25 } 26 27 [JsonPropertyName("properties")] 28 public LightSwitchProperties Properties { get; set; } 29 30 public HotkeyAccessor[] GetAllHotkeyAccessors() 31 { 32 var hotkeyAccessors = new List<HotkeyAccessor> 33 { 34 new HotkeyAccessor( 35 () => Properties.ToggleThemeHotkey.Value, 36 value => Properties.ToggleThemeHotkey.Value = value ?? LightSwitchProperties.DefaultToggleThemeHotkey, 37 "LightSwitch_ThemeToggle_Shortcut"), 38 }; 39 40 return hotkeyAccessors.ToArray(); 41 } 42 43 public ModuleType GetModuleType() => ModuleType.LightSwitch; 44 45 public object Clone() 46 { 47 return new LightSwitchSettings() 48 { 49 Name = Name, 50 Version = Version, 51 Properties = new LightSwitchProperties() 52 { 53 ChangeSystem = new BoolProperty(Properties.ChangeSystem.Value), 54 ChangeApps = new BoolProperty(Properties.ChangeApps.Value), 55 ScheduleMode = new StringProperty(Properties.ScheduleMode.Value), 56 LightTime = new IntProperty((int)Properties.LightTime.Value), 57 DarkTime = new IntProperty((int)Properties.DarkTime.Value), 58 SunriseOffset = new IntProperty((int)Properties.SunriseOffset.Value), 59 SunsetOffset = new IntProperty((int)Properties.SunsetOffset.Value), 60 Latitude = new StringProperty(Properties.Latitude.Value), 61 Longitude = new StringProperty(Properties.Longitude.Value), 62 ToggleThemeHotkey = new KeyboardKeysProperty(Properties.ToggleThemeHotkey.Value), 63 EnableDarkModeProfile = new BoolProperty(Properties.EnableDarkModeProfile.Value), 64 EnableLightModeProfile = new BoolProperty(Properties.EnableLightModeProfile.Value), 65 DarkModeProfile = new StringProperty(Properties.DarkModeProfile.Value), 66 LightModeProfile = new StringProperty(Properties.LightModeProfile.Value), 67 }, 68 }; 69 } 70 71 public string GetModuleName() 72 { 73 return Name; 74 } 75 76 public bool UpgradeSettingsConfiguration() 77 { 78 return false; 79 } 80 } 81 }