-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettingsForm.cs
97 lines (79 loc) · 2.79 KB
/
SettingsForm.cs
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
using System;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
using static MainLibrary.MainLib;
namespace AutoPixelArt
{
using strings = Resources.Strings;
public partial class SettingsForm : Form
{
private static readonly Properties.Settings settings = Properties.Settings.Default;
private bool recalcImg;
private readonly MainForm mainForm = (MainForm)Application.OpenForms["mainForm"];
public SettingsForm()
{
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(Lang == "ru" ? "ru" : "en-US");
InitializeComponent();
}
private void SettingsForm_Load(object sender, EventArgs e)
{
Bitmap saveIcon = new(20, 16);
using (Graphics g = Graphics.FromImage(saveIcon))
{
g.DrawImage(Properties.Resources.saveIcon, 0, 0, 16, 16);
}
saveSettingsButton.Image = saveIcon;
delayBar.Scroll -= delayBar_Scroll;
origImgCheckBox.CheckedChanged -= origImgCheckBox_CheckedChanged;
escCheckBox.CheckedChanged -= escCheckBox_CheckedChanged;
vanishMinecraftCheckBox.CheckedChanged -= vanishMinecraftCheckBox_CheckedChanged;
currentDelayLabel.Text = settings.delay.ToString();
delayBar.Value = settings.delay;
origImgCheckBox.Checked = settings.showOrigImg;
escCheckBox.Checked = settings.pressEsc;
vanishMinecraftCheckBox.Checked = settings.vanishMinecraft;
delayBar.Scroll += delayBar_Scroll;
origImgCheckBox.CheckedChanged += origImgCheckBox_CheckedChanged;
escCheckBox.CheckedChanged += escCheckBox_CheckedChanged;
vanishMinecraftCheckBox.CheckedChanged += vanishMinecraftCheckBox_CheckedChanged;
}
private void delayBar_Scroll(object sender, EventArgs e)
{
settings.delay = (byte)delayBar.Value;
currentDelayLabel.Text = delayBar.Value.ToString();
}
private void escCheckBox_CheckedChanged(object sender, EventArgs e)
{
settings.pressEsc = escCheckBox.Checked;
}
private void origImgCheckBox_CheckedChanged(object sender, EventArgs e)
{
settings.showOrigImg = origImgCheckBox.Checked;
recalcImg = !recalcImg;
}
private void vanishMinecraftCheckBox_CheckedChanged(object sender, EventArgs e)
{
if (!settings.vanishWarned)
{
Warning(strings.vanishWarning, false);
settings.vanishWarned = true;
}
settings.vanishMinecraft = vanishMinecraftCheckBox.Checked;
if (settings.vanishMinecraft)
mainForm.MouseClick += mainForm.MainForm_MouseClick;
else
mainForm.MouseClick -= mainForm.MainForm_MouseClick;
}
private void saveSettingsButton_Click(object sender, EventArgs e)
{
mainForm.autoMinCheckBox.Enabled = !settings.vanishMinecraft;
mainForm.autoMinCheckBox.Checked = settings.vanishMinecraft;
settings.Save();
if (recalcImg)
RecalculateImage();
Msg(strings.settingsSaved);
Dispose();
}
}
}