blob: b98f6057432cd2abb381cd09fef386def5a467db (
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
|
using System;
using Avalonia.Markup.Xaml;
using UVtools.Core.Operations;
using UVtools.WPF.Extensions;
using UVtools.WPF.Windows;
namespace UVtools.WPF.Controls.Tools
{
public class ToolPatternControl : ToolControl
{
public OperationPattern Operation => BaseOperation as OperationPattern;
private bool _isDefaultAnchorChecked = true;
public bool IsDefaultAnchorChecked
{
get => _isDefaultAnchorChecked;
set => RaiseAndSetIfChanged(ref _isDefaultAnchorChecked, value);
}
public ToolPatternControl()
{
BaseOperation = new OperationPattern(SlicerFile, App.MainWindow.ROI);
if (!ValidateSpawn()) return;
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
public override void Callback(ToolWindow.Callbacks callback)
{
switch (callback)
{
case ToolWindow.Callbacks.Init:
case ToolWindow.Callbacks.Loaded:
Operation.ROI = App.MainWindow.ROI.IsEmpty ? SlicerFile.BoundingRectangle : App.MainWindow.ROI;
Operation.PropertyChanged += (sender, e) =>
{
if (e.PropertyName.Equals(nameof(Operation.IsWithinBoundary)))
{
ParentWindow.ButtonOkEnabled = Operation.IsWithinBoundary;
}
};
break;
case ToolWindow.Callbacks.ClearROI:
Operation.SetRoi(SlicerFile.BoundingRectangle);
break;
}
}
}
}
|