LenovoLegionToolkit

Форк
0
93 строки · 5.7 Кб
1
using System;
2
using System.Collections.Generic;
3
using System.Threading.Tasks;
4
using LenovoLegionToolkit.WPF.Controls;
5
using LenovoLegionToolkit.WPF.Controls.Dashboard;
6
using LenovoLegionToolkit.WPF.Resources;
7
using Wpf.Ui.Common;
8

9
namespace LenovoLegionToolkit.WPF.Extensions;
10

11
public static class DashboardItemExtensions
12
{
13
    public static SymbolRegular GetIcon(this DashboardItem dashboardItem) => dashboardItem switch
14
    {
15
        DashboardItem.PowerMode => SymbolRegular.Gauge24,
16
        DashboardItem.BatteryMode => SymbolRegular.BatteryCharge24,
17
        DashboardItem.BatteryNightChargeMode => SymbolRegular.WeatherMoon24,
18
        DashboardItem.AlwaysOnUsb => SymbolRegular.UsbStick24,
19
        DashboardItem.InstantBoot => SymbolRegular.PlugDisconnected24,
20
        DashboardItem.HybridMode => SymbolRegular.LeafOne24,
21
        DashboardItem.DiscreteGpu => SymbolRegular.DeveloperBoard24,
22
        DashboardItem.OverclockDiscreteGpu => SymbolRegular.DeveloperBoardLightning20,
23
        DashboardItem.Resolution => SymbolRegular.ScaleFill24,
24
        DashboardItem.RefreshRate => SymbolRegular.DesktopPulse24,
25
        DashboardItem.DpiScale => SymbolRegular.TextFontSize24,
26
        DashboardItem.Hdr => SymbolRegular.Hdr24,
27
        DashboardItem.OverDrive => SymbolRegular.TopSpeed24,
28
        DashboardItem.PanelLogoBacklight => SymbolRegular.LightbulbCircle24,
29
        DashboardItem.PortsBacklight => SymbolRegular.UsbPlug24,
30
        DashboardItem.TurnOffMonitors => SymbolRegular.Desktop24,
31
        DashboardItem.Microphone => SymbolRegular.Mic24,
32
        DashboardItem.FlipToStart => SymbolRegular.Power24,
33
        DashboardItem.TouchpadLock => SymbolRegular.Tablet24,
34
        DashboardItem.FnLock => SymbolRegular.Keyboard24,
35
        DashboardItem.WinKeyLock => SymbolRegular.Keyboard24,
36
        DashboardItem.WhiteKeyboardBacklight => SymbolRegular.Keyboard24,
37
        _ => throw new InvalidOperationException($"Invalid DashboardItem {dashboardItem}"),
38
    };
39

40
    public static string GetTitle(this DashboardItem dashboardItem) => dashboardItem switch
41
    {
42
        DashboardItem.PowerMode => Resource.PowerModeControl_Title,
43
        DashboardItem.BatteryMode => Resource.BatteryModeControl_Title,
44
        DashboardItem.BatteryNightChargeMode => Resource.BatteryNightChargeModeControl_Title,
45
        DashboardItem.AlwaysOnUsb => Resource.AlwaysOnUSBControl_Title,
46
        DashboardItem.InstantBoot => Resource.InstantBootControl_Title,
47
        DashboardItem.HybridMode => $"{Resource.ComboBoxHybridModeControl_Title} / {Resource.ToggleHybridModeControl_Title}",
48
        DashboardItem.DiscreteGpu => Resource.DiscreteGPUControl_Title,
49
        DashboardItem.OverclockDiscreteGpu => Resource.OverclockDiscreteGPUControl_Title,
50
        DashboardItem.Resolution => Resource.ResolutionControl_Title,
51
        DashboardItem.RefreshRate => Resource.RefreshRateControl_Title,
52
        DashboardItem.DpiScale => Resource.DpiScaleControl_Title,
53
        DashboardItem.Hdr => Resource.HDRControl_Title,
54
        DashboardItem.OverDrive => Resource.OverDriveControl_Title,
55
        DashboardItem.PanelLogoBacklight => Resource.PanelLogoBacklightControl_Title,
56
        DashboardItem.PortsBacklight => Resource.PortsBacklightControl_Title,
57
        DashboardItem.TurnOffMonitors => Resource.TurnOffMonitorsControl_Title,
58
        DashboardItem.Microphone => Resource.MicrophoneControl_Title,
59
        DashboardItem.FlipToStart => Resource.FlipToStartControl_Title,
60
        DashboardItem.TouchpadLock => Resource.TouchpadLockControl_Title,
61
        DashboardItem.FnLock => Resource.FnLockControl_Title,
62
        DashboardItem.WinKeyLock => Resource.WinKeyControl_Title,
63
        DashboardItem.WhiteKeyboardBacklight => Resource.WhiteKeyboardBacklightControl_Title,
64
        _ => throw new InvalidOperationException($"Invalid DashboardItem {dashboardItem}"),
65
    };
66

67
    public static async Task<IEnumerable<AbstractRefreshingControl>> GetControlAsync(this DashboardItem dashboardItem) => dashboardItem switch
68
    {
69
        DashboardItem.PowerMode => new[] { new PowerModeControl() },
70
        DashboardItem.BatteryMode => new[] { new BatteryModeControl() },
71
        DashboardItem.BatteryNightChargeMode => new[] { new BatteryNightChargeModeControl() },
72
        DashboardItem.AlwaysOnUsb => new[] { new AlwaysOnUSBControl() },
73
        DashboardItem.InstantBoot => new[] { new InstantBootControl() },
74
        DashboardItem.HybridMode => new[] { await HybridModeControlFactory.GetControlAsync() },
75
        DashboardItem.DiscreteGpu => new[] { new DiscreteGPUControl() },
76
        DashboardItem.OverclockDiscreteGpu => new[] { new OverclockDiscreteGPUControl() },
77
        DashboardItem.Resolution => new[] { new ResolutionControl() },
78
        DashboardItem.RefreshRate => new[] { new RefreshRateControl() },
79
        DashboardItem.DpiScale => new[] { new DpiScaleControl() },
80
        DashboardItem.Hdr => new[] { new HDRControl() },
81
        DashboardItem.OverDrive => new[] { new OverDriveControl() },
82
        DashboardItem.PanelLogoBacklight => new[] { new PanelLogoBacklightControl() },
83
        DashboardItem.PortsBacklight => new[] { new PortsBacklightControl() },
84
        DashboardItem.TurnOffMonitors => new[] { new TurnOffMonitorsControl() },
85
        DashboardItem.Microphone => new[] { new MicrophoneControl() },
86
        DashboardItem.FlipToStart => new[] { new FlipToStartControl() },
87
        DashboardItem.TouchpadLock => new[] { new TouchpadLockControl() },
88
        DashboardItem.FnLock => new[] { new FnLockControl() },
89
        DashboardItem.WinKeyLock => new[] { new WinKeyControl() },
90
        DashboardItem.WhiteKeyboardBacklight => new AbstractRefreshingControl[] { new WhiteKeyboardBacklightControl(), new OneLevelWhiteKeyboardBacklightControl() },
91
        _ => throw new InvalidOperationException($"Invalid DashboardItem {dashboardItem}"),
92
    };
93
}
94

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.