summaryrefslogtreecommitdiff
path: root/ViewModels/Settings
diff options
context:
space:
mode:
Diffstat (limited to 'ViewModels/Settings')
-rw-r--r--ViewModels/Settings/ISettingLimits.cs9
-rw-r--r--ViewModels/Settings/SettingLimits.cs20
-rw-r--r--ViewModels/Settings/SettingsViewModel.cs52
3 files changed, 80 insertions, 1 deletions
diff --git a/ViewModels/Settings/ISettingLimits.cs b/ViewModels/Settings/ISettingLimits.cs
new file mode 100644
index 0000000..a4927f0
--- /dev/null
+++ b/ViewModels/Settings/ISettingLimits.cs
@@ -0,0 +1,9 @@
+namespace Avalar.ViewModels.Settings
+{
+ public interface ISettingLimits
+ {
+ uint MaxWidth { get; }
+
+ uint MaxHeight { get; }
+ }
+} \ No newline at end of file
diff --git a/ViewModels/Settings/SettingLimits.cs b/ViewModels/Settings/SettingLimits.cs
new file mode 100644
index 0000000..8a0f3ea
--- /dev/null
+++ b/ViewModels/Settings/SettingLimits.cs
@@ -0,0 +1,20 @@
+using Avalonia.Media.Imaging;
+using System;
+
+namespace Avalar.ViewModels.Settings
+{
+ public class SettingLimits : ISettingLimits
+ {
+ public SettingLimits(IBitmap bitmap)
+ {
+ var _ = bitmap ?? throw new ArgumentNullException(nameof(bitmap));
+
+ MaxWidth = Convert.ToUInt32(bitmap.Size.Width);
+ MaxHeight = Convert.ToUInt32(bitmap.Size.Height);
+ }
+
+ public uint MaxWidth { get; }
+
+ public uint MaxHeight { get; }
+ }
+}
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);
+ }
}
}