mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 22:16:30 +00:00
fde9a9f418
also restrict detections to be no bigger than in classes.json
57 lines
1.7 KiB
C#
57 lines
1.7 KiB
C#
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;
|
|
}
|
|
}
|