LenovoLegionToolkit
93 строки · 5.7 Кб
1using System;2using System.Collections.Generic;3using System.Threading.Tasks;4using LenovoLegionToolkit.WPF.Controls;5using LenovoLegionToolkit.WPF.Controls.Dashboard;6using LenovoLegionToolkit.WPF.Resources;7using Wpf.Ui.Common;8
9namespace LenovoLegionToolkit.WPF.Extensions;10
11public static class DashboardItemExtensions12{
13public static SymbolRegular GetIcon(this DashboardItem dashboardItem) => dashboardItem switch14{15DashboardItem.PowerMode => SymbolRegular.Gauge24,16DashboardItem.BatteryMode => SymbolRegular.BatteryCharge24,17DashboardItem.BatteryNightChargeMode => SymbolRegular.WeatherMoon24,18DashboardItem.AlwaysOnUsb => SymbolRegular.UsbStick24,19DashboardItem.InstantBoot => SymbolRegular.PlugDisconnected24,20DashboardItem.HybridMode => SymbolRegular.LeafOne24,21DashboardItem.DiscreteGpu => SymbolRegular.DeveloperBoard24,22DashboardItem.OverclockDiscreteGpu => SymbolRegular.DeveloperBoardLightning20,23DashboardItem.Resolution => SymbolRegular.ScaleFill24,24DashboardItem.RefreshRate => SymbolRegular.DesktopPulse24,25DashboardItem.DpiScale => SymbolRegular.TextFontSize24,26DashboardItem.Hdr => SymbolRegular.Hdr24,27DashboardItem.OverDrive => SymbolRegular.TopSpeed24,28DashboardItem.PanelLogoBacklight => SymbolRegular.LightbulbCircle24,29DashboardItem.PortsBacklight => SymbolRegular.UsbPlug24,30DashboardItem.TurnOffMonitors => SymbolRegular.Desktop24,31DashboardItem.Microphone => SymbolRegular.Mic24,32DashboardItem.FlipToStart => SymbolRegular.Power24,33DashboardItem.TouchpadLock => SymbolRegular.Tablet24,34DashboardItem.FnLock => SymbolRegular.Keyboard24,35DashboardItem.WinKeyLock => SymbolRegular.Keyboard24,36DashboardItem.WhiteKeyboardBacklight => SymbolRegular.Keyboard24,37_ => throw new InvalidOperationException($"Invalid DashboardItem {dashboardItem}"),38};39
40public static string GetTitle(this DashboardItem dashboardItem) => dashboardItem switch41{42DashboardItem.PowerMode => Resource.PowerModeControl_Title,43DashboardItem.BatteryMode => Resource.BatteryModeControl_Title,44DashboardItem.BatteryNightChargeMode => Resource.BatteryNightChargeModeControl_Title,45DashboardItem.AlwaysOnUsb => Resource.AlwaysOnUSBControl_Title,46DashboardItem.InstantBoot => Resource.InstantBootControl_Title,47DashboardItem.HybridMode => $"{Resource.ComboBoxHybridModeControl_Title} / {Resource.ToggleHybridModeControl_Title}",48DashboardItem.DiscreteGpu => Resource.DiscreteGPUControl_Title,49DashboardItem.OverclockDiscreteGpu => Resource.OverclockDiscreteGPUControl_Title,50DashboardItem.Resolution => Resource.ResolutionControl_Title,51DashboardItem.RefreshRate => Resource.RefreshRateControl_Title,52DashboardItem.DpiScale => Resource.DpiScaleControl_Title,53DashboardItem.Hdr => Resource.HDRControl_Title,54DashboardItem.OverDrive => Resource.OverDriveControl_Title,55DashboardItem.PanelLogoBacklight => Resource.PanelLogoBacklightControl_Title,56DashboardItem.PortsBacklight => Resource.PortsBacklightControl_Title,57DashboardItem.TurnOffMonitors => Resource.TurnOffMonitorsControl_Title,58DashboardItem.Microphone => Resource.MicrophoneControl_Title,59DashboardItem.FlipToStart => Resource.FlipToStartControl_Title,60DashboardItem.TouchpadLock => Resource.TouchpadLockControl_Title,61DashboardItem.FnLock => Resource.FnLockControl_Title,62DashboardItem.WinKeyLock => Resource.WinKeyControl_Title,63DashboardItem.WhiteKeyboardBacklight => Resource.WhiteKeyboardBacklightControl_Title,64_ => throw new InvalidOperationException($"Invalid DashboardItem {dashboardItem}"),65};66
67public static async Task<IEnumerable<AbstractRefreshingControl>> GetControlAsync(this DashboardItem dashboardItem) => dashboardItem switch68{69DashboardItem.PowerMode => new[] { new PowerModeControl() },70DashboardItem.BatteryMode => new[] { new BatteryModeControl() },71DashboardItem.BatteryNightChargeMode => new[] { new BatteryNightChargeModeControl() },72DashboardItem.AlwaysOnUsb => new[] { new AlwaysOnUSBControl() },73DashboardItem.InstantBoot => new[] { new InstantBootControl() },74DashboardItem.HybridMode => new[] { await HybridModeControlFactory.GetControlAsync() },75DashboardItem.DiscreteGpu => new[] { new DiscreteGPUControl() },76DashboardItem.OverclockDiscreteGpu => new[] { new OverclockDiscreteGPUControl() },77DashboardItem.Resolution => new[] { new ResolutionControl() },78DashboardItem.RefreshRate => new[] { new RefreshRateControl() },79DashboardItem.DpiScale => new[] { new DpiScaleControl() },80DashboardItem.Hdr => new[] { new HDRControl() },81DashboardItem.OverDrive => new[] { new OverDriveControl() },82DashboardItem.PanelLogoBacklight => new[] { new PanelLogoBacklightControl() },83DashboardItem.PortsBacklight => new[] { new PortsBacklightControl() },84DashboardItem.TurnOffMonitors => new[] { new TurnOffMonitorsControl() },85DashboardItem.Microphone => new[] { new MicrophoneControl() },86DashboardItem.FlipToStart => new[] { new FlipToStartControl() },87DashboardItem.TouchpadLock => new[] { new TouchpadLockControl() },88DashboardItem.FnLock => new[] { new FnLockControl() },89DashboardItem.WinKeyLock => new[] { new WinKeyControl() },90DashboardItem.WhiteKeyboardBacklight => new AbstractRefreshingControl[] { new WhiteKeyboardBacklightControl(), new OneLevelWhiteKeyboardBacklightControl() },91_ => throw new InvalidOperationException($"Invalid DashboardItem {dashboardItem}"),92};93}
94