blob: be64de499ba6ae0bfb9e3cd9a0b38964b09a7fbb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
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; }
private float _scale = 1.0f;
private ViewModelBase _currentViewModel = new LoginViewModel(authService);
private Size _physicalSize = new Size(300, 220);
public ViewModelBase CurrentViewModel {
get => _currentViewModel;
set => SetProperty(ref _currentViewModel, value);
}
public CommandLineConfiguration CommandLineConfiguration { get; } = cfg;
public MatrixAuthenticationService AuthService { get; } = authService;
public float Scale {
get => _scale;
set {
if (SetProperty(ref _scale, (float)Math.Round(value, 2))) {
OnPropertyChanged(nameof(ChildTargetWidth));
OnPropertyChanged(nameof(ChildTargetHeight));
}
}
}
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));
}
}
}
}
|