about summary refs log tree commit diff
path: root/ModerationClient/ViewModels/MainWindowViewModel.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-08-08 02:57:34 +0200
committerRory& <root@rory.gay>2024-08-08 03:02:10 +0200
commitdf5fe7c86e41235f99a9b0d69519a18581eddd5e (patch)
treed7ae3b2c9b98ffcf4fbe4613091dfc7db7e2c62b /ModerationClient/ViewModels/MainWindowViewModel.cs
parentList rooms (diff)
downloadModerationClient-df5fe7c86e41235f99a9b0d69519a18581eddd5e.tar.xz
Further work
Diffstat (limited to '')
-rw-r--r--ModerationClient/ViewModels/MainWindowViewModel.cs28
1 files changed, 20 insertions, 8 deletions
diff --git a/ModerationClient/ViewModels/MainWindowViewModel.cs b/ModerationClient/ViewModels/MainWindowViewModel.cs

index 01ec6d6..be64de4 100644 --- a/ModerationClient/ViewModels/MainWindowViewModel.cs +++ b/ModerationClient/ViewModels/MainWindowViewModel.cs
@@ -1,14 +1,16 @@ using System; +using Avalonia; using ModerationClient.Services; using ModerationClient.Views; namespace ModerationClient.ViewModels; public partial class MainWindowViewModel(MatrixAuthenticationService authService, CommandLineConfiguration cfg) : ViewModelBase { - public MainWindow? MainWindow { get; set; } - + // public MainWindow? MainWindow { get; set; } + private float _scale = 1.0f; private ViewModelBase _currentViewModel = new LoginViewModel(authService); + private Size _physicalSize = new Size(300, 220); public ViewModelBase CurrentViewModel { get => _currentViewModel; @@ -21,13 +23,23 @@ public partial class MainWindowViewModel(MatrixAuthenticationService authService public float Scale { get => _scale; set { - SetProperty(ref _scale, (float)Math.Round(value, 2)); - OnPropertyChanged(nameof(ChildTargetWidth)); - OnPropertyChanged(nameof(ChildTargetHeight)); + if (SetProperty(ref _scale, (float)Math.Round(value, 2))) { + OnPropertyChanged(nameof(ChildTargetWidth)); + OnPropertyChanged(nameof(ChildTargetHeight)); + } } } - public int ChildTargetWidth => (int)(MainWindow?.Width / Scale ?? 1); - public int ChildTargetHeight => (int)(MainWindow?.Height / Scale ?? 1); - + public int ChildTargetWidth => (int)(PhysicalSize.Width / Scale); + public int ChildTargetHeight => (int)(PhysicalSize.Height / Scale); + + public Size PhysicalSize { + get => _physicalSize; + set { + if (SetProperty(ref _physicalSize, value)) { + OnPropertyChanged(nameof(ChildTargetWidth)); + OnPropertyChanged(nameof(ChildTargetHeight)); + } + } + } } \ No newline at end of file