forked from amkovkov/GranuSightSoftware2
feat: OpenCvImage
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
using GSS2.Core.Hardware;
|
||||
using GSS2.UI.Core.ViewModels;
|
||||
|
||||
namespace GSS2.Test.ViewModels;
|
||||
@@ -7,14 +9,23 @@ namespace GSS2.Test.ViewModels;
|
||||
public partial class MainViewModel : ViewModelBase
|
||||
{
|
||||
private readonly ILogger<MainViewModel> _logger;
|
||||
private readonly CameraService _cameraService;
|
||||
[ObservableProperty] private CameraViewModel _cameraViewModel;
|
||||
[ObservableProperty] private ResourcesViewModel _resourcesViewModel;
|
||||
[ObservableProperty] private OpenCvSharp.Mat? _image;
|
||||
[ObservableProperty] private IRelayCommand _buttonClick;
|
||||
|
||||
public MainViewModel(ILogger<MainViewModel> logger, CameraViewModel cameraViewModel, ResourcesViewModel resourcesViewModel)
|
||||
public MainViewModel(ILogger<MainViewModel> logger, CameraViewModel cameraViewModel, ResourcesViewModel resourcesViewModel, CameraService cameraService)
|
||||
{
|
||||
_logger = logger;
|
||||
_cameraService = cameraService;
|
||||
CameraViewModel = cameraViewModel;
|
||||
ResourcesViewModel = resourcesViewModel;
|
||||
ButtonClick = new RelayCommand(() =>
|
||||
{
|
||||
cameraService.CaptureImage(CancellationToken.None, 10).ContinueWith(image => Image = image.Result);
|
||||
});
|
||||
|
||||
_logger.LogInformation("{} initialized", nameof(MainViewModel));
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,13 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local_vm="using:GSS2.Test.ViewModels"
|
||||
xmlns:core_vm="using:GSS2.UI.Core.ViewModels"
|
||||
xmlns:core="using:GSS2.UI.Core"
|
||||
x:DataType="local_vm:MainViewModel"
|
||||
x:Class="GSS2.Test.Views.MainView">
|
||||
<Grid RowDefinitions="*,*">
|
||||
<ContentControl Grid.Row="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Content="{Binding CameraViewModel}" />
|
||||
<ContentControl Grid.Row="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Content="{Binding ResourcesViewModel}" />
|
||||
<Grid ColumnDefinitions="*,Auto">
|
||||
<core:OpenCvImage Grid.Column="0" Image="{Binding Image}" />
|
||||
<Button Grid.Column="1" Width="50" VerticalAlignment="Stretch" Command="{Binding ButtonClick}"/>
|
||||
<!-- <ContentControl Grid.Row="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Content="{Binding CameraViewModel}" /> -->
|
||||
<!-- <ContentControl Grid.Row="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Content="{Binding ResourcesViewModel}" /> -->
|
||||
</Grid>
|
||||
</UserControl>
|
||||
Reference in New Issue
Block a user