summaryrefslogtreecommitdiff
path: root/ViewModels/Settings/SettingsViewModel.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ViewModels/Settings/SettingsViewModel.cs')
-rw-r--r--ViewModels/Settings/SettingsViewModel.cs52
1 files changed, 51 insertions, 1 deletions
diff --git a/ViewModels/Settings/SettingsViewModel.cs b/ViewModels/Settings/SettingsViewModel.cs
index 730b662..17c27cc 100644
--- a/ViewModels/Settings/SettingsViewModel.cs
+++ b/ViewModels/Settings/SettingsViewModel.cs
@@ -1,7 +1,57 @@

+using Avalar.Models.Interfaces;
+using ReactiveUI;
+using System;
+using System.ComponentModel;
+using System.Threading.Tasks;
+
namespace Avalar.ViewModels.Settings
{
- public class SettingsViewModel
+ public class SettingsViewModel : ReactiveObject
{
+ private readonly ISettingsModel m_SettingsModel;
+ public SettingsViewModel(ISettingsModel settingsModel)
+ {
+ m_SettingsModel = settingsModel;
+
+ PropertyChanged += OnPropertyChanged;
+ }
+
+ private async void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ if(e.PropertyName == nameof(Width))
+ {
+ await Task.Run(() => m_SettingsModel.SetWidth(Width)).ConfigureAwait(false);
+ }
+ if (e.PropertyName == nameof(Height))
+ {
+ await Task.Run(() => m_SettingsModel.SetHeight(Height)).ConfigureAwait(false);
+ }
+ if (e.PropertyName == nameof(BrightnessDelta))
+ {
+ await Task.Run(() => m_SettingsModel.SetBrightnessDelta(BrightnessDelta)).ConfigureAwait(false);
+ }
+ }
+
+ private uint m_Width;
+ public uint Width
+ {
+ get => m_Width;
+ set => this.RaiseAndSetIfChanged(ref m_Width, value);
+ }
+
+ private uint m_Height;
+ public uint Height
+ {
+ get => m_Height;
+ set => this.RaiseAndSetIfChanged(ref m_Height, value);
+ }
+
+ private int m_BrightnessDelta;
+ public int BrightnessDelta
+ {
+ get => m_BrightnessDelta;
+ set => this.RaiseAndSetIfChanged(ref m_BrightnessDelta, value);
+ }
}
}