blob: 235fdec06f9f973ef1809300f5e4dbceef89c59c (
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
60
61
62
63
64
65
66
67
68
69
70
71
|
using Avalonia.Markup.Xaml;
using UVtools.Core.Operations;
using UVtools.WPF.Windows;
namespace UVtools.WPF.Controls.Tools
{
public class ToolRepairLayersControl : ToolControl
{
public OperationRepairLayers Operation => BaseOperation as OperationRepairLayers;
public ToolRepairLayersControl()
{
BaseOperation = new OperationRepairLayers(SlicerFile);
if (!ValidateSpawn()) return;
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
public static OperationRepairLayers GetOperationRepairLayers() => new (App.SlicerFile)
{
RepairIslands = UserSettings.Instance.LayerRepair.RepairIslands,
RepairResinTraps = UserSettings.Instance.LayerRepair.RepairResinTraps,
RemoveEmptyLayers = UserSettings.Instance.LayerRepair.RemoveEmptyLayers,
RemoveIslandsBelowEqualPixelCount = UserSettings.Instance.LayerRepair.RemoveIslandsBelowEqualPixels,
RemoveIslandsRecursiveIterations = UserSettings.Instance.LayerRepair.RemoveIslandsRecursiveIterations,
AttachIslandsBelowLayers = UserSettings.Instance.LayerRepair.AttachIslandsBelowLayers,
GapClosingIterations = UserSettings.Instance.LayerRepair.ClosingIterations,
NoiseRemovalIterations = UserSettings.Instance.LayerRepair.OpeningIterations,
};
public void SetFromUserSettings()
{
Operation.RepairIslands = UserSettings.Instance.LayerRepair.RepairIslands;
Operation.RepairResinTraps = UserSettings.Instance.LayerRepair.RepairResinTraps;
Operation.RemoveEmptyLayers = UserSettings.Instance.LayerRepair.RemoveEmptyLayers;
Operation.RemoveIslandsBelowEqualPixelCount = UserSettings.Instance.LayerRepair.RemoveIslandsBelowEqualPixels;
Operation.RemoveIslandsRecursiveIterations = UserSettings.Instance.LayerRepair.RemoveIslandsRecursiveIterations;
Operation.AttachIslandsBelowLayers = UserSettings.Instance.LayerRepair.AttachIslandsBelowLayers;
Operation.GapClosingIterations = UserSettings.Instance.LayerRepair.ClosingIterations;
Operation.NoiseRemovalIterations = UserSettings.Instance.LayerRepair.OpeningIterations;
}
public override void Callback(ToolWindow.Callbacks callback)
{
switch (callback)
{
case ToolWindow.Callbacks.Init:
case ToolWindow.Callbacks.Loaded:
if (callback is ToolWindow.Callbacks.Init)
{
ParentWindow.LayerRangeVisible = false;
ParentWindow.IsCheckBox1Visible = true;
}
SetFromUserSettings();
break;
case ToolWindow.Callbacks.Checkbox1:
ParentWindow.LayerRangeVisible = ParentWindow.IsCheckBox1Checked;
if (!ParentWindow.IsCheckBox1Checked)
{
ParentWindow.SelectAllLayers();
}
break;
}
}
}
}
|