diff --git a/IdeapadToolkit/Models/ChargingMode.cs b/IdeapadToolkit/Models/ChargingMode.cs index 278e971..c45b93d 100644 --- a/IdeapadToolkit/Models/ChargingMode.cs +++ b/IdeapadToolkit/Models/ChargingMode.cs @@ -8,7 +8,7 @@ namespace IdeapadToolkit.Models { public enum ChargingMode { - Conservative = 1, + Conservation = 1, Normal = 0, Rapid = 2 } diff --git a/IdeapadToolkit/ViewModels/LenovoSettingsViewModel.cs b/IdeapadToolkit/ViewModels/LenovoSettingsViewModel.cs index 78740e4..c401d51 100644 --- a/IdeapadToolkit/ViewModels/LenovoSettingsViewModel.cs +++ b/IdeapadToolkit/ViewModels/LenovoSettingsViewModel.cs @@ -22,14 +22,19 @@ public LenovoSettingsViewModel(ILenovoPowerSettingsService lenovoPowerSettingsSe public void Refresh() { Plan = _lenovoPowerSettingsService.GetPowerPlan(); + Mode = _lenovoPowerSettingsService.GetChargingMode(); } [ObservableProperty] [NotifyPropertyChangedFor(nameof(IsEfficientChecked), nameof(IsIntelligentCoolingChecked), nameof(IsExtremePerformanceChecked))] private PowerPlan _plan; + [ObservableProperty] + [NotifyPropertyChangedFor(nameof(IsConservationModeEnabled), nameof(IsNormalModeEnabled), nameof(IsRapidModeEnabled))] + private ChargingMode _mode; private readonly ILenovoPowerSettingsService _lenovoPowerSettingsService; private readonly IUEFISettingsService _uEFISettingsService; + #region PowerPlanProperties public bool IsEfficientChecked { get @@ -56,7 +61,9 @@ public bool IsExtremePerformanceChecked } set { } } + #endregion + #region OtherProperties public bool IsFlipToBootEnabled { get @@ -93,6 +100,55 @@ public bool IsAlwaysOnUsbBatteryEnabled _lenovoPowerSettingsService.SetAlwaysOnUsbBattery(value); } } + #endregion + + #region ChargingModeProperties + public bool IsConservationModeEnabled + { + get + { + return _mode == ChargingMode.Conservation; + } + set + { + } + } + + public bool IsNormalModeEnabled + { + get + { + return _mode == ChargingMode.Normal; + } + set + { + } + } + + public bool IsRapidModeEnabled + { + get + { + return _mode == ChargingMode.Rapid; + } + set + { + } + } + + #endregion + + [RelayCommand] + private void SetChargingMode(int? mode) + { + if (mode == null) return; + try + { + _lenovoPowerSettingsService.SetChargingMode((ChargingMode)mode); + Refresh(); + } + catch { } + } [RelayCommand] private void SetPlan(int? plan) diff --git a/IdeapadToolkit/Views/MainPage.xaml b/IdeapadToolkit/Views/MainPage.xaml index ceeb5bf..92e7414 100644 --- a/IdeapadToolkit/Views/MainPage.xaml +++ b/IdeapadToolkit/Views/MainPage.xaml @@ -50,6 +50,36 @@ + + + + + 1 + + + + + 0 + + + + + 2 + + +