mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 21:46:30 +00:00
79 lines
2.5 KiB
C#
79 lines
2.5 KiB
C#
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using Azaion.Common.DTO;
|
|
|
|
namespace Azaion.Common.Controls;
|
|
|
|
public class DetectionClassChangedEventArgs(DetectionClass detectionClass, int classNumber) : EventArgs
|
|
{
|
|
public DetectionClass DetectionClass { get; } = detectionClass;
|
|
public int ClassNumber { get; } = classNumber;
|
|
}
|
|
|
|
public partial class DetectionClasses
|
|
{
|
|
public event EventHandler<DetectionClassChangedEventArgs>? DetectionClassChanged;
|
|
private const int CaptionedMinWidth = 230;
|
|
|
|
public DetectionClasses()
|
|
{
|
|
InitializeComponent();
|
|
SizeChanged += (sender, args) =>
|
|
{
|
|
if (args.NewSize.Width < CaptionedMinWidth)
|
|
{
|
|
RegularModeButton.Text = "";
|
|
WinterModeButton.Text = "";
|
|
NightModeButton.Text = "";
|
|
}
|
|
else
|
|
{
|
|
RegularModeButton.Text = Constants.REGULAR_MODE_CAPTION;
|
|
WinterModeButton.Text= Constants.WINTER_MODE_CAPTION;
|
|
NightModeButton.Text= Constants.NIGHT_MODE_CAPTION;
|
|
}
|
|
};
|
|
}
|
|
|
|
public void Init(List<DetectionClass> detectionClasses)
|
|
{
|
|
DetectionDataGrid.ItemsSource = detectionClasses;
|
|
DetectionDataGrid.SelectedIndex = 0;
|
|
}
|
|
|
|
public int CurrentClassNumber { get; private set; } = 0;
|
|
public DetectionClass? CurrentDetectionClass { get; set; }
|
|
|
|
private void DetectionDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) =>
|
|
RaiseDetectionClassChanged();
|
|
|
|
private void ModeRadioButton_Checked(object sender, RoutedEventArgs e) =>
|
|
RaiseDetectionClassChanged();
|
|
|
|
private void RaiseDetectionClassChanged()
|
|
{
|
|
var detClass = (DetectionClass)DetectionDataGrid.SelectedItem;
|
|
if (detClass == null)
|
|
return;
|
|
|
|
var modeAmplifier = 0;
|
|
foreach (var child in ModeSwitcherPanel.Children)
|
|
if (child is RadioButton { IsChecked: true } rb)
|
|
if (int.TryParse(rb.Tag?.ToString(), out int modeIndex))
|
|
{
|
|
detClass.PhotoMode = (PhotoMode)modeIndex;
|
|
modeAmplifier += modeIndex;
|
|
}
|
|
|
|
CurrentDetectionClass = detClass;
|
|
CurrentClassNumber = detClass.Id + modeAmplifier;
|
|
|
|
DetectionClassChanged?.Invoke(this, new DetectionClassChangedEventArgs(detClass, CurrentClassNumber));
|
|
}
|
|
|
|
|
|
public void SelectNum(int keyNumber)
|
|
{
|
|
DetectionDataGrid.SelectedIndex = keyNumber;
|
|
}
|
|
} |