mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 15:56:30 +00:00
add altitude + camera spec component and calc tile size by this
also restrict detections to be no bigger than in classes.json
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Azaion.Common.DTO.Config;
|
||||
|
||||
namespace Azaion.Common.Controls;
|
||||
|
||||
public partial class CameraConfigControl
|
||||
{
|
||||
public static readonly DependencyProperty CameraProperty = DependencyProperty.Register(
|
||||
nameof(Camera), typeof(CameraConfig), typeof(CameraConfigControl),
|
||||
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
|
||||
|
||||
public CameraConfig Camera
|
||||
{
|
||||
get => (CameraConfig)GetValue(CameraProperty) ?? new CameraConfig();
|
||||
set => SetValue(CameraProperty, value);
|
||||
}
|
||||
|
||||
// Fires whenever any camera parameter value changes in UI
|
||||
public event EventHandler? CameraChanged;
|
||||
|
||||
public CameraConfigControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = this;
|
||||
Loaded += OnLoaded;
|
||||
}
|
||||
|
||||
private void OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Hook up change notifications
|
||||
if (AltitudeSlider != null)
|
||||
AltitudeSlider.ValueChanged += (_, __) => CameraChanged?.Invoke(this, EventArgs.Empty);
|
||||
|
||||
SubscribeNud(AltitudeNud);
|
||||
SubscribeNud(FocalNud);
|
||||
SubscribeNud(SensorNud);
|
||||
}
|
||||
|
||||
private void SubscribeNud(UserControl? nud)
|
||||
{
|
||||
if (nud is NumericUpDown num)
|
||||
{
|
||||
var dpd = DependencyPropertyDescriptor.FromProperty(NumericUpDown.ValueProperty, typeof(NumericUpDown));
|
||||
dpd?.AddValueChanged(num, (_, __) => CameraChanged?.Invoke(this, EventArgs.Empty));
|
||||
}
|
||||
}
|
||||
|
||||
// Initializes the control with the provided CameraConfig instance and wires two-way binding via dependency property
|
||||
public void Init(CameraConfig cameraConfig)
|
||||
{
|
||||
Camera = cameraConfig;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user