blob: 4a0311697e2031d3d823201b3066b97ad464dbe4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using UVtools.Core.Operations;
namespace UVtools.WPF.Controls.Tools
{
public class ToolBlurControl : ToolControl
{
private int _selectedAlgorithmIndex;
private bool _isSizeEnabled = true;
private bool _isKernelVisible;
private KernelControl _kernelCtrl;
public OperationBlur Operation { get; }
public int SelectedAlgorithmIndex
{
get => _selectedAlgorithmIndex;
set
{
if(!RaiseAndSetIfChanged(ref _selectedAlgorithmIndex, value) || value < 0) return;
Operation.BlurOperation = (OperationBlur.BlurAlgorithm) OperationBlur.BlurTypes[_selectedAlgorithmIndex].Tag;
IsKernelVisible = Operation.BlurOperation == OperationBlur.BlurAlgorithm.Filter2D;
IsSizeEnabled = Operation.BlurOperation != OperationBlur.BlurAlgorithm.Pyramid &&
Operation.BlurOperation != OperationBlur.BlurAlgorithm.Filter2D;
}
}
public bool IsSizeEnabled
{
get => _isSizeEnabled;
set => RaiseAndSetIfChanged(ref _isSizeEnabled, value);
}
public bool IsKernelVisible
{
get => _isKernelVisible;
set => RaiseAndSetIfChanged(ref _isKernelVisible, value);
}
public ToolBlurControl()
{
InitializeComponent();
BaseOperation = Operation = new OperationBlur();
_kernelCtrl = this.Find<KernelControl>("KernelCtrl");
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
public override bool UpdateOperation()
{
Operation.Kernel.Matrix = _kernelCtrl.GetMatrix();
Operation.Kernel.Anchor = _kernelCtrl.Anchor;
return !(Operation.Kernel.Matrix is null);
}
}
}
|