feat: SectionPanel

This commit is contained in:
2026-02-09 15:23:43 +03:00
parent 6179567170
commit b638d4e752
3 changed files with 114 additions and 9 deletions
+7 -2
View File
@@ -13,7 +13,10 @@ public partial class MainViewModel : ViewModelBase
[ObservableProperty] private CameraViewModel _cameraViewModel;
[ObservableProperty] private ResourcesViewModel _resourcesViewModel;
[ObservableProperty] private OpenCvSharp.Mat? _image;
[ObservableProperty] private IRelayCommand _buttonClick;
[ObservableProperty] private IRelayCommand _buttonCaptureClick;
[ObservableProperty] private IRelayCommand _buttonUpClick;
[ObservableProperty] private IRelayCommand _buttonDownClick;
[ObservableProperty] private int _currentIndex;
public MainViewModel(ILogger<MainViewModel> logger, CameraViewModel cameraViewModel, ResourcesViewModel resourcesViewModel, CameraService cameraService)
{
@@ -21,10 +24,12 @@ public partial class MainViewModel : ViewModelBase
_cameraService = cameraService;
CameraViewModel = cameraViewModel;
ResourcesViewModel = resourcesViewModel;
ButtonClick = new RelayCommand(() =>
ButtonCaptureClick = new RelayCommand(() =>
{
Task.Run(() => cameraService.CaptureImage(CancellationToken.None, 10).ContinueWith(image => Image = image.Result));
});
ButtonUpClick = new RelayCommand(() => CurrentIndex--);
ButtonDownClick = new RelayCommand(() => CurrentIndex++);
_logger.LogInformation("{} initialized", nameof(MainViewModel));
}
+11 -7
View File
@@ -6,12 +6,16 @@
xmlns:core="using:GSS2.UI.Core"
x:DataType="local_vm:MainViewModel"
x:Class="GSS2.Test.Views.MainView">
<Grid RowDefinitions="*,*">
<Grid Grid.Row="0" ColumnDefinitions="*,*,Auto">
<ContentControl Grid.Column="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Content="{Binding CameraViewModel}" />
<core:OpenCvImage Grid.Column="1" Image="{Binding Image}" />
<Button Grid.Column="2" Width="50" VerticalAlignment="Stretch" Command="{Binding ButtonClick}"/>
</Grid>
<ContentControl Grid.Row="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Content="{Binding ResourcesViewModel}" />
<Grid ColumnDefinitions="*,100" RowDefinitions="*,*">
<Button Grid.Row="0" Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Command="{Binding ButtonUpClick}"/>
<Button Grid.Row="1" Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Command="{Binding ButtonDownClick}"/>
<core:SectionPanel Grid.Row="0" Grid.RowSpan="2" Grid.Column="0" CurrentIndex="{Binding CurrentIndex}">
<ContentControl VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Content="{Binding ResourcesViewModel}" />
<ContentControl VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Content="{Binding CameraViewModel}" />
<Grid ColumnDefinitions="100, *">
<Button Grid.Column="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Command="{Binding ButtonCaptureClick}"/>
<core:OpenCvImage Grid.Column="1" Image="{Binding Image}" Background="Red" />
</Grid>
</core:SectionPanel>
</Grid>
</UserControl>