blob: b31e0172752a1610217fa9df3b7339982887e5f7 (
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/*
* GNU AFFERO GENERAL PUBLIC LICENSE
* Version 3, 19 November 2007
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
using System;
using System.Linq;
using System.Text;
using UVtools.Core.FileFormats;
using UVtools.Core.Objects;
namespace UVtools.Core.Operations
{
[Serializable]
public class OperationEditParameters : Operation
{
#region Members
private bool _perLayerOverride;
#endregion
#region Overrides
public override Enumerations.LayerRangeSelection StartLayerRangeSelection => Enumerations.LayerRangeSelection.None;
public override bool CanROI => false;
public override string Title => "Edit print parameters";
public override string Description =>
"Edits the available print parameters.\n" +
"Note: Set global parameters will override all per layer settings when they are available.";
public override string ConfirmationText
{
get
{
var sb = new StringBuilder();
foreach (var modifier in Modifiers)
{
if(!modifier.HasChanged) continue;
sb.AppendLine($"{modifier.Name}: {modifier.OldValue}{modifier.ValueUnit} » {modifier.NewValue}{modifier.ValueUnit}");
}
var text = "commit print parameter changes";
if (_perLayerOverride)
{
if (LayerRangeCount == 1)
{
text += $" to layer {LayerIndexStart}";
}
else
{
text += $" from layer {LayerIndexStart} to {LayerIndexEnd}";
}
}
return $"{text}?\n{sb}";
}
}
public override string ProgressTitle => "Change print parameters";
public override string ProgressAction => "Changing print parameters";
public override bool CanHaveProfiles => false;
public override StringTag Validate(params object[] parameters)
{
var sb = new StringBuilder();
var changed = Modifiers.Any(modifier => modifier.HasChanged);
if (!changed)
{
sb.AppendLine("Nothing changed\nDo some changes or cancel the operation.");
}
return new StringTag(sb.ToString());
}
#endregion
#region Propertiers
public FileFormat.PrintParameterModifier[] Modifiers { get; set; }
/// <summary>
/// Gets or sets if parameters are global or per layer inside a layer range
/// </summary>
public bool PerLayerOverride
{
get => _perLayerOverride;
set => RaiseAndSetIfChanged(ref _perLayerOverride, value);
}
#endregion
public OperationEditParameters()
{
}
public OperationEditParameters(FileFormat.PrintParameterModifier[] modifiers)
{
Modifiers = modifiers;
}
#region Methods
public override bool Execute(FileFormat slicerFile, OperationProgress progress = null)
{
slicerFile.EditPrintParameters(this);
return true;
}
#endregion
}
}
|