mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
Adds a button for Light Switch in the Quick Access section of the Dashboard page. Clicking the button will toggle the theme. <img width="1886" height="1173" alt="image" src="https://github.com/user-attachments/assets/7923e1ac-aeea-47ab-b648-2400cb6f3ca4" />
78 lines
2.8 KiB
C#
78 lines
2.8 KiB
C#
// 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;
|
|
using System.Collections.Generic;
|
|
using System.Reflection;
|
|
using System.Text.Json.Serialization;
|
|
using ManagedCommon;
|
|
using Microsoft.PowerToys.Settings.UI.Library;
|
|
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
|
|
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.Library
|
|
{
|
|
public class LightSwitchSettings : BasePTModuleSettings, ISettingsConfig, ICloneable, IHotkeyConfig
|
|
{
|
|
public const string ModuleName = "LightSwitch";
|
|
|
|
public LightSwitchSettings()
|
|
{
|
|
Name = ModuleName;
|
|
Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
|
Properties = new LightSwitchProperties();
|
|
}
|
|
|
|
[JsonPropertyName("properties")]
|
|
public LightSwitchProperties Properties { get; set; }
|
|
|
|
public HotkeyAccessor[] GetAllHotkeyAccessors()
|
|
{
|
|
var hotkeyAccessors = new List<HotkeyAccessor>
|
|
{
|
|
new HotkeyAccessor(
|
|
() => Properties.ToggleThemeHotkey.Value,
|
|
value => Properties.ToggleThemeHotkey.Value = value ?? LightSwitchProperties.DefaultToggleThemeHotkey,
|
|
"LightSwitch_ThemeToggle_Shortcut"),
|
|
};
|
|
|
|
return hotkeyAccessors.ToArray();
|
|
}
|
|
|
|
public ModuleType GetModuleType() => ModuleType.LightSwitch;
|
|
|
|
public object Clone()
|
|
{
|
|
return new LightSwitchSettings()
|
|
{
|
|
Name = Name,
|
|
Version = Version,
|
|
Properties = new LightSwitchProperties()
|
|
{
|
|
ChangeSystem = new BoolProperty(Properties.ChangeSystem.Value),
|
|
ChangeApps = new BoolProperty(Properties.ChangeApps.Value),
|
|
ScheduleMode = new StringProperty(Properties.ScheduleMode.Value),
|
|
LightTime = new IntProperty((int)Properties.LightTime.Value),
|
|
DarkTime = new IntProperty((int)Properties.DarkTime.Value),
|
|
SunriseOffset = new IntProperty((int)Properties.SunriseOffset.Value),
|
|
SunsetOffset = new IntProperty((int)Properties.SunsetOffset.Value),
|
|
Latitude = new StringProperty(Properties.Latitude.Value),
|
|
Longitude = new StringProperty(Properties.Longitude.Value),
|
|
ToggleThemeHotkey = new KeyboardKeysProperty(Properties.ToggleThemeHotkey.Value),
|
|
},
|
|
};
|
|
}
|
|
|
|
public string GetModuleName()
|
|
{
|
|
return Name;
|
|
}
|
|
|
|
public bool UpgradeSettingsConfiguration()
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|