mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-09 01:52:32 +02:00
5da3c7e173
* (Add) Auto-updater: When a new version is detected UVtools still show the same green button at top, on click, it will prompt for auto or manual update. On Linux and Mac the script will kill all UVtools instances and auto-upgrade. On Windows the user must close all instances and continue with the shown MSI installation * (Add) Tool profiles: Create and remove named presets for some tools * (Add) Event handler for handling non-UI thread exceptions * (Fix) Mac: File - Open in a new window was not working * (Fix) Tool - Rotate: Allow negative angles * (Fix) Tool - Rotate: The operation was inverting the angle * (Fix) Tools: Select normal layers can crash the program with small files with low layer count, eg: 3 layers total
86 lines
2.6 KiB
C#
86 lines
2.6 KiB
C#
using Avalonia.Markup.Xaml;
|
|
using Emgu.CV.CvEnum;
|
|
using UVtools.Core.Operations;
|
|
|
|
namespace UVtools.WPF.Controls.Tools
|
|
{
|
|
public class ToolThresholdControl : ToolControl
|
|
{
|
|
private int _selectedPresetIndex;
|
|
private bool _isThresholdEnabled = true;
|
|
private bool _isMaximumEnabled = true;
|
|
private bool _isTypeEnabled = true;
|
|
public OperationThreshold Operation => BaseOperation as OperationThreshold;
|
|
|
|
public string[] Presets => new[]
|
|
{
|
|
"Free use",
|
|
"Strip AntiAliasing",
|
|
"Set pixel brightness"
|
|
};
|
|
|
|
public bool IsThresholdEnabled
|
|
{
|
|
get => _isThresholdEnabled;
|
|
set => RaiseAndSetIfChanged(ref _isThresholdEnabled, value);
|
|
}
|
|
|
|
public bool IsMaximumEnabled
|
|
{
|
|
get => _isMaximumEnabled;
|
|
set => RaiseAndSetIfChanged(ref _isMaximumEnabled, value);
|
|
}
|
|
|
|
public bool IsTypeEnabled
|
|
{
|
|
get => _isTypeEnabled;
|
|
set => RaiseAndSetIfChanged(ref _isTypeEnabled, value);
|
|
}
|
|
|
|
public int SelectedPresetIndex
|
|
{
|
|
get => _selectedPresetIndex;
|
|
set
|
|
{
|
|
if (!RaiseAndSetIfChanged(ref _selectedPresetIndex, value)) return;
|
|
|
|
switch (_selectedPresetIndex)
|
|
{
|
|
case 0:
|
|
IsThresholdEnabled = true;
|
|
IsMaximumEnabled = true;
|
|
IsTypeEnabled = true;
|
|
break;
|
|
case 1:
|
|
IsThresholdEnabled = true;
|
|
IsMaximumEnabled = false;
|
|
IsTypeEnabled = false;
|
|
Operation.Threshold = 127;
|
|
Operation.Maximum = 255;
|
|
Operation.Type = ThresholdType.Binary;
|
|
break;
|
|
case 2:
|
|
IsThresholdEnabled = false;
|
|
IsMaximumEnabled = true;
|
|
IsTypeEnabled = false;
|
|
Operation.Threshold = 254;
|
|
//Operation.Maximum = 254;
|
|
Operation.Type = ThresholdType.Binary;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
public ToolThresholdControl()
|
|
{
|
|
InitializeComponent();
|
|
BaseOperation = new OperationThreshold();
|
|
}
|
|
|
|
private void InitializeComponent()
|
|
{
|
|
AvaloniaXamlLoader.Load(this);
|
|
}
|
|
}
|
|
}
|