Files
GSS2Rework/GSS2/ViewModels/AmineContentViewModel.cs
T
amkovkov 72ae26eee7 comprehensive update
1) remove unused components: camera view (due it causes segmentation faults), compute resources and all related, illuminator controller (due in useless without camera view), image storage service, temperature and humidity service
2) database schema - reduce tables references, features storing in records themselves in compressed form, add records creation and editing date and time, add separator comment column
3) analysis - rework of pipeline and ui, now database storing only raw data and all display values calculated from it
4) lights service - add reconnection if disconnected
5) add width and height command line arguments
6) fix some typos and other issues
2026-06-29 15:13:29 +03:00

80 lines
3.0 KiB
C#

using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using GSS2.UI.Core.Services;
using GSS2.ViewModels.Common;
using GSS2.ViewModels.AmineContent;
using ViewModelBase = GSS2.UI.Core.ViewModels.ViewModelBase;
using System.ComponentModel;
namespace GSS2.ViewModels;
public partial class AmineContentViewModel : ViewModelBase
{
private readonly NavigationService _navigationService;
[ObservableProperty] public partial AnalysisViewModel Analysis { get; set; }
[ObservableProperty] public partial SampleCalibrationViewModel SampleCalibration { get; set; }
[ObservableProperty] public partial SeparatorCalibrationViewModel SeparatorCalibration { get; set; }
// [ObservableProperty] public partial CameraViewModel Camera { get; set; }
[ObservableProperty] public partial BrandCalibrationViewModel BrandCalibration { get; set; }
// [ObservableProperty] public partial SystemViewModel System { get; set; }
[ObservableProperty] public partial int CurrentIndex { get; set; } = 0;
[ObservableProperty] public partial bool IsScrolling { get; set; } = false;
[ObservableProperty] public partial bool CanInteract { get; set; } = true;
public AmineContentViewModel(
NavigationService navigationService,
AnalysisViewModel analysis,
SampleCalibrationViewModel sampleCalibration,
SeparatorCalibrationViewModel separatorCalibration,
BrandCalibrationViewModel brandCalibration
)
{
_navigationService = navigationService;
Analysis = analysis;
SampleCalibration = sampleCalibration;
SeparatorCalibration = separatorCalibration;
BrandCalibration = brandCalibration;
PropertyChanged += (_, ea) =>
{
if (ea.PropertyName == nameof(IsScrolling))
UpdateCanInteract();
};
Analysis.PropertyChanged += SubViewModelPropertyChanged;
SampleCalibration.PropertyChanged += SubViewModelPropertyChanged;
SeparatorCalibration.PropertyChanged += SubViewModelPropertyChanged;
BrandCalibration.PropertyChanged += SubViewModelPropertyChanged;
}
private void SubViewModelPropertyChanged(object? sender, PropertyChangedEventArgs ea)
{
if (ea.PropertyName == nameof(Analysis.CanInteract) ||
ea.PropertyName == nameof(Analysis.ImagesIsCapturing))
UpdateCanInteract();
}
private void UpdateCanInteract()
{
CanInteract = !IsScrolling;
CanInteract &= Analysis.CanInteract;
CanInteract &= SampleCalibration.CanInteract;
CanInteract &= SeparatorCalibration.CanInteract;
CanInteract &= BrandCalibration.CanInteract;
CanInteract &= !Analysis.ImagesIsCapturing;
CanInteract &= !SampleCalibration.ImagesIsCapturing;
CanInteract &= !SeparatorCalibration.ImagesIsCapturing;
}
[RelayCommand]
void ChangeSection(string sectionNumberStr)
{
if (!int.TryParse(sectionNumberStr, out var sectionNumber))
return;
CurrentIndex = sectionNumber;
}
}