60 lines
1.5 KiB
C#
60 lines
1.5 KiB
C#
using System.Collections.ObjectModel;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using VisionBuilder.UI.Common.Commands;
|
|
using VisionBuilder.UI.Common.Commands.Interfaces;
|
|
using VisionBuilder.UI.Common.ViewModel.Interfaces.UI;
|
|
|
|
namespace VisionBuilder.UI.Common.ViewModel;
|
|
|
|
public partial class MainWindowVM:ObservableObject
|
|
{
|
|
private readonly ISettingsService _settingsService;
|
|
public event Action ProgramStarted = delegate { };
|
|
public event Action ProgramClosed = delegate { };
|
|
public event Action<bool> TestModeChanged = delegate { };
|
|
|
|
[ObservableProperty]
|
|
private bool _testMode;
|
|
|
|
public MainWindowVM(ISettingsService settingsService)
|
|
{
|
|
_settingsService = settingsService;
|
|
}
|
|
|
|
public ObservableCollection<SingleCameraVM> SingleCameraVms { get; set; } =
|
|
new ObservableCollection<SingleCameraVM>();
|
|
|
|
|
|
[RelayCommand]
|
|
public void Settings()
|
|
{
|
|
_settingsService.ShowSettingsDialog();
|
|
}
|
|
|
|
[RelayCommand]
|
|
public void ToggleTestMode()
|
|
{
|
|
TestMode = !TestMode;
|
|
TestModeChanged(TestMode);
|
|
}
|
|
|
|
public void OnProgramStarted()
|
|
{
|
|
ProgramStarted?.Invoke();
|
|
}
|
|
|
|
public void OnProgramClosed()
|
|
{
|
|
foreach (var singleCameraVm in SingleCameraVms)
|
|
{
|
|
if (singleCameraVm.IsRunning)
|
|
{
|
|
singleCameraVm.StopCommand.Execute(null);
|
|
|
|
}
|
|
}
|
|
ProgramClosed?.Invoke();
|
|
}
|
|
|
|
} |