mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 18:57:19 +02:00
Update settings
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
|
||||
|
||||
@@ -34,14 +35,14 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
|
||||
Settings = moduleSettingsRepository.SettingsConfig;
|
||||
|
||||
_isEnabled = GeneralSettingsConfig.Enabled.Espresso;
|
||||
_keepDisplayOn = Settings.Properties.KeepDisplayOn.Value;
|
||||
_mode = Settings.Properties.Mode;
|
||||
_timeAllocation = Settings.Properties.TimeAllocation.Value;
|
||||
_hours = Settings.Properties.Hours.Value;
|
||||
_minutes = Settings.Properties.Minutes.Value;
|
||||
|
||||
// set the callback functions value to hangle outgoing IPC message.
|
||||
SendConfigMSG = ipcMSGCallBackFunc;
|
||||
|
||||
IsEnabled = GeneralSettingsConfig.Enabled.Espresso;
|
||||
}
|
||||
|
||||
public bool IsEnabled
|
||||
@@ -52,19 +53,79 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
if (_isEnabled != value)
|
||||
{
|
||||
_isEnabled = value;
|
||||
OnPropertyChanged(nameof(IsEnabled));
|
||||
|
||||
GeneralSettingsConfig.Enabled.Espresso = value;
|
||||
var outgoing = new OutGoingGeneralSettings(GeneralSettingsConfig);
|
||||
|
||||
var outgoing = new OutGoingGeneralSettings(GeneralSettingsConfig);
|
||||
SendConfigMSG(outgoing.ToString());
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool KeepDisplayOn
|
||||
{
|
||||
get => _keepDisplayOn;
|
||||
set
|
||||
{
|
||||
if (_keepDisplayOn != value)
|
||||
{
|
||||
_keepDisplayOn = value;
|
||||
OnPropertyChanged(nameof(KeepDisplayOn));
|
||||
|
||||
Settings.Properties.KeepDisplayOn = new BoolProperty(value);
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int Hours
|
||||
{
|
||||
get => _hours;
|
||||
set
|
||||
{
|
||||
if (_hours != value)
|
||||
{
|
||||
_hours = value;
|
||||
OnPropertyChanged(nameof(Hours));
|
||||
|
||||
Settings.Properties.Hours = new IntProperty(value);
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int Minutes
|
||||
{
|
||||
get => _minutes;
|
||||
set
|
||||
{
|
||||
if (_minutes != value)
|
||||
{
|
||||
_minutes = value;
|
||||
OnPropertyChanged(nameof(Minutes));
|
||||
|
||||
Settings.Properties.Minutes = new IntProperty(value);
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void NotifyPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
OnPropertyChanged(propertyName);
|
||||
if (SendConfigMSG != null)
|
||||
{
|
||||
SndEspressoSettings outsettings = new SndEspressoSettings(Settings);
|
||||
SndModuleSettings<SndEspressoSettings> ipcMessage = new SndModuleSettings<SndEspressoSettings>(outsettings);
|
||||
SendConfigMSG(ipcMessage.ToJsonString());
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isEnabled;
|
||||
private int _hours;
|
||||
private int _minutes;
|
||||
private bool _keepDisplayOn;
|
||||
private EspressoMode _mode;
|
||||
private int _timeAllocation;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user