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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using UVtools.Core.FileFormats;
using UVtools.GUI.Properties;
namespace UVtools.GUI.Forms
{
public partial class FrmSettings : Form
{
public FrmSettings()
{
InitializeComponent();
Text = $"UVtools - Settings [v{FrmAbout.AssemblyVersion}]";
var fileFormats = new List<string>
{
FileFormat.AllSlicerFiles.Replace("*", string.Empty)
};
fileFormats.AddRange(from format in FileFormat.AvaliableFormats from extension in format.FileExtensions select $"{extension.Description} (.{extension.Extension})");
cbDefaultOpenFileExtension.Items.AddRange(fileFormats.ToArray());
Init();
}
public void Init()
{
try
{
cbCheckForUpdatesOnStartup.Checked = Settings.Default.CheckForUpdatesOnStartup;
cbStartMaximized.Checked = Settings.Default.StartMaximized;
cbDefaultOpenFileExtension.SelectedIndex = Settings.Default.DefaultOpenFileExtension;
tbFileOpenDefaultDirectory.Text = Settings.Default.FileOpenDefaultDirectory;
tbFileSaveDefaultDirectory.Text = Settings.Default.FileSaveDefaultDirectory;
tbFileExtractDefaultDirectory.Text = Settings.Default.FileExtractDefaultDirectory;
tbFileConvertDefaultDirectory.Text = Settings.Default.FileConvertDefaultDirectory;
cbFileSavePromptOverwrite.Checked = Settings.Default.FileSavePromptOverwrite;
tbFileSaveNamePreffix.Text = Settings.Default.FileSaveNamePreffix;
tbFileSaveNameSuffix.Text = Settings.Default.FileSaveNameSuffix;
btnPreviousNextLayerColor.BackColor = Settings.Default.PreviousNextLayerColor;
btnPreviousLayerColor.BackColor = Settings.Default.PreviousLayerColor;
btnNextLayerColor.BackColor = Settings.Default.NextLayerColor;
btnIslandColor.BackColor = Settings.Default.IslandColor;
btnResinTrapColor.BackColor = Settings.Default.ResinTrapColor;
btnTouchingBoundsColor.BackColor = Settings.Default.TouchingBoundsColor;
btnOutlinePrintVolumeBoundsColor.BackColor = Settings.Default.OutlinePrintVolumeBoundsColor;
btnOutlineLayerBoundsColor.BackColor = Settings.Default.OutlineLayerBoundsColor;
btnOutlineHollowAreasColor.BackColor = Settings.Default.OutlineHollowAreasColor;
nmOutlinePrintVolumeBoundsLineThickness.Value = Settings.Default.OutlinePrintVolumeBoundsLineThickness;
nmOutlineLayerBoundsLineThickness.Value = Settings.Default.OutlineLayerBoundsLineThickness;
nmOutlineHollowAreasLineThickness.Value = Settings.Default.OutlineHollowAreasLineThickness;
cbOutlinePrintVolumeBounds.Checked = Settings.Default.OutlinePrintVolumeBounds;
cbOutlineLayerBounds.Checked = Settings.Default.OutlineLayerBounds;
cbOutlineHollowAreas.Checked = Settings.Default.OutlineHollowAreas;
cbLayerAutoRotateBestView.Checked = Settings.Default.LayerAutoRotateBestView;
cbLayerZoomToFit.Checked = Settings.Default.LayerZoomToFit;
cbZoomToFitPrintVolumeBounds.Checked = Settings.Default.ZoomToFitPrintVolumeBounds;
cbAutoZoomIssues.Checked = Settings.Default.AutoZoomIssues;
cbLayerDifferenceDefault.Checked = Settings.Default.LayerDifferenceDefault;
cbComputeIssuesOnLoad.Checked = Settings.Default.ComputeIssuesOnLoad;
cbComputeIslands.Checked = Settings.Default.ComputeIslands;
cbComputeResinTraps.Checked = Settings.Default.ComputeResinTraps;
cbAutoComputeIssuesClickOnTab.Checked = Settings.Default.AutoComputeIssuesClickOnTab;
nmIslandBinaryThreshold.Value = Settings.Default.IslandBinaryThreshold;
nmIslandRequiredAreaToProcessCheck.Value = Settings.Default.IslandRequiredAreaToProcessCheck;
nmIslandRequiredPixelBrightnessToProcessCheck.Value = Settings.Default.IslandRequiredPixelBrightnessToProcessCheck;
nmIslandRequiredPixelsToSupport.Value = Settings.Default.IslandRequiredPixelsToSupport;
nmIslandRequiredPixelBrightnessToSupport.Value = Settings.Default.IslandRequiredPixelBrightnessToSupport;
nmResinTrapBinaryThreshold.Value = Settings.Default.ResinTrapBinaryThreshold;
nmResinTrapRequiredAreaToProcessCheck.Value = Settings.Default.ResinTrapRequiredAreaToProcessCheck;
nmResinTrapRequiredBlackPixelsToDrain.Value = Settings.Default.ResinTrapRequiredBlackPixelsToDrain;
nmResinTrapMaximumPixelBrightnessToDrain.Value = Settings.Default.ResinTrapMaximumPixelBrightnessToDrain;
btnPixelEditorAddPixelColor.BackColor = Settings.Default.PixelEditorAddPixelColor;
btnPixelEditorRemovePixelColor.BackColor = Settings.Default.PixelEditorRemovePixelColor;
btnPixelEditorSupportColor.BackColor = Settings.Default.PixelEditorSupportColor;
btnPixelEditorDrainHoleColor.BackColor = Settings.Default.PixelEditorDrainHoleColor;
}
catch (Exception ex)
{
MessageBox.Show($"Unable to use current settings, a reset will be performed.\n{ex.Message}",
"Unable to use current settings", MessageBoxButtons.OK, MessageBoxIcon.Error);
Settings.Default.Reset();
Settings.Default.Save();
Init();
}
}
private void EventClick(object sender, EventArgs e)
{
if (
ReferenceEquals(sender, btnPreviousNextLayerColor) ||
ReferenceEquals(sender, btnPreviousLayerColor) ||
ReferenceEquals(sender, btnNextLayerColor) ||
ReferenceEquals(sender, btnIslandColor) ||
ReferenceEquals(sender, btnResinTrapColor) ||
ReferenceEquals(sender, btnTouchingBoundsColor) ||
ReferenceEquals(sender, btnOutlinePrintVolumeBoundsColor) ||
ReferenceEquals(sender, btnOutlineLayerBoundsColor) ||
ReferenceEquals(sender, btnOutlineHollowAreasColor) ||
ReferenceEquals(sender, btnPixelEditorAddPixelColor) ||
ReferenceEquals(sender, btnPixelEditorRemovePixelColor) ||
ReferenceEquals(sender, btnPixelEditorSupportColor) ||
ReferenceEquals(sender, btnPixelEditorDrainHoleColor)
)
{
Button btn = sender as Button;
colorDialog.Color = btn.BackColor;
if (colorDialog.ShowDialog() != DialogResult.OK) return;
btn.BackColor = colorDialog.Color;
return;
}
if (ReferenceEquals(sender, btnFileOpenDefaultDirectorySearch) || ReferenceEquals(sender, btnFileSaveDefaultDirectorySearch) || ReferenceEquals(sender, btnFileConvertDefaultDirectorySearch) || ReferenceEquals(sender, btnFileExtractDefaultDirectorySearch))
{
using (FolderBrowserDialog folder = new FolderBrowserDialog())
{
if (folder.ShowDialog() != DialogResult.OK) return;
if (ReferenceEquals(sender, btnFileOpenDefaultDirectorySearch)) tbFileOpenDefaultDirectory.Text = folder.SelectedPath;
else if (ReferenceEquals(sender, btnFileSaveDefaultDirectorySearch)) tbFileSaveDefaultDirectory.Text = folder.SelectedPath;
else if (ReferenceEquals(sender, btnFileExtractDefaultDirectorySearch)) tbFileExtractDefaultDirectory.Text = folder.SelectedPath;
else if (ReferenceEquals(sender, btnFileConvertDefaultDirectorySearch)) tbFileConvertDefaultDirectory.Text = folder.SelectedPath;
}
return;
}
if (ReferenceEquals(sender, btnFileOpenDefaultDirectoryClear))
{
tbFileOpenDefaultDirectory.Text = string.Empty;
return;
}
if (ReferenceEquals(sender, btnFileSaveDefaultDirectoryClear))
{
tbFileSaveDefaultDirectory.Text = string.Empty;
return;
}
if (ReferenceEquals(sender, btnFileExtractDefaultDirectoryClear))
{
tbFileExtractDefaultDirectory.Text = string.Empty;
return;
}
if (ReferenceEquals(sender, btnFileConvertDefaultDirectoryClear))
{
tbFileConvertDefaultDirectory.Text = string.Empty;
return;
}
if (ReferenceEquals(sender, btnReset))
{
if (MessageBox.Show("Are you sure you want to reset the settings to the default values?",
"Reset settings?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) !=
DialogResult.Yes) return;
Settings.Default.Reset();
Init();
return;
}
if (ReferenceEquals(sender, btnSave))
{
Settings.Default.CheckForUpdatesOnStartup = cbCheckForUpdatesOnStartup.Checked;
Settings.Default.StartMaximized = cbStartMaximized.Checked;
Settings.Default.DefaultOpenFileExtension = (byte) cbDefaultOpenFileExtension.SelectedIndex;
Settings.Default.FileOpenDefaultDirectory = tbFileOpenDefaultDirectory.Text;
Settings.Default.FileSaveDefaultDirectory = tbFileSaveDefaultDirectory.Text;
Settings.Default.FileExtractDefaultDirectory = tbFileExtractDefaultDirectory.Text;
Settings.Default.FileConvertDefaultDirectory = tbFileConvertDefaultDirectory.Text;
Settings.Default.FileSavePromptOverwrite = cbFileSavePromptOverwrite.Checked;
Settings.Default.FileSaveNamePreffix = tbFileSaveNamePreffix.Text.Trim();
Settings.Default.FileSaveNameSuffix = tbFileSaveNameSuffix.Text.Trim();
Settings.Default.PreviousNextLayerColor = btnPreviousNextLayerColor.BackColor;
Settings.Default.PreviousLayerColor = btnPreviousLayerColor.BackColor;
Settings.Default.NextLayerColor = btnNextLayerColor.BackColor;
Settings.Default.IslandColor = btnIslandColor.BackColor;
Settings.Default.ResinTrapColor = btnResinTrapColor.BackColor;
Settings.Default.TouchingBoundsColor = btnTouchingBoundsColor.BackColor;
Settings.Default.OutlinePrintVolumeBoundsColor = btnOutlinePrintVolumeBoundsColor.BackColor;
Settings.Default.OutlineLayerBoundsColor = btnOutlineLayerBoundsColor.BackColor;
Settings.Default.OutlineHollowAreasColor = btnOutlineHollowAreasColor.BackColor;
Settings.Default.OutlinePrintVolumeBoundsLineThickness = (byte) nmOutlinePrintVolumeBoundsLineThickness.Value;
Settings.Default.OutlineLayerBoundsLineThickness = (byte) nmOutlineLayerBoundsLineThickness.Value;
Settings.Default.OutlineHollowAreasLineThickness = (sbyte) nmOutlineHollowAreasLineThickness.Value;
Settings.Default.OutlinePrintVolumeBounds = cbOutlinePrintVolumeBounds.Checked;
Settings.Default.OutlineLayerBounds = cbOutlineLayerBounds.Checked;
Settings.Default.OutlineHollowAreas = cbOutlineHollowAreas.Checked;
Settings.Default.LayerAutoRotateBestView = cbLayerAutoRotateBestView.Checked;
Settings.Default.LayerZoomToFit = cbLayerZoomToFit.Checked;
Settings.Default.ZoomToFitPrintVolumeBounds = cbZoomToFitPrintVolumeBounds.Checked;
Settings.Default.AutoZoomIssues = cbAutoZoomIssues.Checked;
Settings.Default.LayerDifferenceDefault = cbLayerDifferenceDefault.Checked;
Settings.Default.ComputeIssuesOnLoad = cbComputeIssuesOnLoad.Checked;
Settings.Default.ComputeIslands = cbComputeIslands.Checked;
Settings.Default.ComputeResinTraps = cbComputeResinTraps.Checked;
Settings.Default.AutoComputeIssuesClickOnTab = cbAutoComputeIssuesClickOnTab.Checked;
Settings.Default.IslandBinaryThreshold = (byte)nmIslandBinaryThreshold.Value;
Settings.Default.IslandRequiredAreaToProcessCheck = (byte) nmIslandRequiredAreaToProcessCheck.Value;
Settings.Default.IslandRequiredPixelBrightnessToProcessCheck = (byte)nmIslandRequiredPixelBrightnessToProcessCheck.Value;
Settings.Default.IslandRequiredPixelsToSupport = (byte)nmIslandRequiredPixelsToSupport.Value;
Settings.Default.IslandRequiredPixelBrightnessToSupport = (byte)nmIslandRequiredPixelBrightnessToSupport.Value;
Settings.Default.ResinTrapBinaryThreshold = (byte) nmResinTrapBinaryThreshold.Value;
Settings.Default.ResinTrapRequiredAreaToProcessCheck = (byte)nmResinTrapRequiredAreaToProcessCheck.Value;
Settings.Default.ResinTrapRequiredBlackPixelsToDrain = (byte)nmResinTrapRequiredBlackPixelsToDrain.Value;
Settings.Default.ResinTrapMaximumPixelBrightnessToDrain = (byte)nmResinTrapMaximumPixelBrightnessToDrain.Value;
Settings.Default.PixelEditorAddPixelColor = btnPixelEditorAddPixelColor.BackColor;
Settings.Default.PixelEditorRemovePixelColor = btnPixelEditorRemovePixelColor.BackColor;
Settings.Default.PixelEditorSupportColor = btnPixelEditorSupportColor.BackColor;
Settings.Default.PixelEditorDrainHoleColor = btnPixelEditorDrainHoleColor.BackColor;
Settings.Default.Save();
DialogResult = DialogResult.OK;
return;
}
}
}
}
|