Spring – Blame information for rev 2
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | using System; |
2 | using System.ComponentModel; |
||
3 | using System.Drawing; |
||
4 | using System.Text.RegularExpressions; |
||
5 | using System.Windows.Forms; |
||
6 | using Spring.Properties; |
||
7 | |||
8 | namespace Spring.Settings |
||
9 | { |
||
10 | public partial class SettingsForm : Form |
||
11 | { |
||
12 | #region Public Enums, Properties and Fields |
||
13 | |||
14 | public BindingList<string> WhitelistBinding { get; set; } |
||
15 | |||
16 | #endregion |
||
17 | |||
18 | #region Private Delegates, Events, Enums, Properties, Indexers and Fields |
||
19 | |||
20 | private Region PanelRegion { get; set; } |
||
21 | |||
22 | private Graphics PanelGraphics { get; set; } |
||
23 | |||
24 | private SolidBrush PanelSolidColorBrush { get; set; } |
||
25 | |||
26 | private RectangleF PanelBounds { get; } |
||
27 | |||
28 | private Configuration.Configuration Configuration { get; } |
||
29 | |||
30 | #endregion |
||
31 | |||
32 | #region Constructors, Destructors and Finalizers |
||
33 | |||
34 | /// <summary> |
||
35 | /// Clean up any resources being used. |
||
36 | /// </summary> |
||
37 | /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> |
||
38 | protected override void Dispose(bool disposing) |
||
39 | { |
||
40 | if (disposing && components != null) |
||
41 | { |
||
42 | PanelRegion?.Dispose(); |
||
43 | PanelRegion = null; |
||
44 | |||
45 | PanelGraphics?.Dispose(); |
||
46 | PanelGraphics = null; |
||
47 | |||
48 | PanelSolidColorBrush?.Dispose(); |
||
49 | PanelSolidColorBrush = null; |
||
50 | |||
51 | components.Dispose(); |
||
52 | } |
||
53 | |||
54 | base.Dispose(disposing); |
||
55 | } |
||
56 | |||
57 | public SettingsForm(Configuration.Configuration springConfiguration) : this() |
||
58 | { |
||
59 | Configuration = springConfiguration; |
||
60 | |||
61 | WhitelistBinding = new BindingList<string>(Configuration.HUD.WhiteList.Whitelist); |
||
62 | windowWhiteListListBox.DataSource = WhitelistBinding; |
||
63 | |||
64 | enableWindowWhiteListCheckBox.DataBindings.Add(nameof(enableWindowWhiteListCheckBox.Checked), |
||
65 | Configuration.HUD, |
||
66 | nameof(Configuration.HUD.EnableWhiteList), |
||
67 | false, |
||
68 | DataSourceUpdateMode.OnPropertyChanged); |
||
69 | |||
70 | fuzzTrackBar.DataBindings.Add(nameof(fuzzTrackBar.Value), |
||
71 | Configuration.Spring, |
||
72 | nameof(Configuration.Spring.Fuzz), |
||
73 | false, |
||
74 | DataSourceUpdateMode.OnPropertyChanged); |
||
75 | |||
76 | textBox2.Text = Configuration.Spring.Fuzz.ToString(); |
||
77 | |||
78 | hudColorLabel.DataBindings.Add(nameof(hudColorLabel.BackColor), |
||
79 | Configuration.HUD, |
||
80 | nameof(Configuration.HUD.Color), |
||
81 | false, |
||
82 | DataSourceUpdateMode.OnPropertyChanged); |
||
83 | |||
84 | enableHudCheckBox.DataBindings.Add(nameof(enableHudCheckBox.Checked), |
||
85 | Configuration.HUD, |
||
86 | nameof(Configuration.HUD.Enable), |
||
87 | false, |
||
88 | DataSourceUpdateMode.OnPropertyChanged); |
||
89 | |||
90 | enableKeyboardCheckbox.DataBindings.Add(nameof(enableKeyboardCheckbox.Checked), |
||
91 | Configuration.Spring.Charge, |
||
92 | nameof(Configuration.Spring.Charge.Keyboard), |
||
93 | false, |
||
94 | DataSourceUpdateMode.OnPropertyChanged); |
||
95 | |||
96 | useRelativeMouseMovementCheckbox.DataBindings.Add(nameof(useRelativeMouseMovementCheckbox.Checked), |
||
97 | Configuration.Spring.Discharge, |
||
98 | nameof(Configuration.Spring.Discharge.UseRelativeMouseMovement), |
||
99 | false, |
||
100 | DataSourceUpdateMode.OnPropertyChanged); |
||
101 | |||
102 | enableMouseMoveCheckBox.DataBindings.Add(nameof(enableMouseMoveCheckBox.Checked), |
||
103 | Configuration.Spring.Charge, |
||
104 | nameof(Configuration.Spring.Charge.MouseMove), |
||
105 | false, |
||
106 | DataSourceUpdateMode.OnPropertyChanged); |
||
107 | |||
108 | enableMouseClickCheckBox.DataBindings.Add(nameof(enableMouseClickCheckBox.Checked), |
||
109 | Configuration.Spring.Charge, |
||
110 | nameof(Configuration.Spring.Charge.MouseClick), |
||
111 | false, |
||
112 | DataSourceUpdateMode.OnPropertyChanged); |
||
113 | |||
114 | chargeDelayTrackBar.DataBindings.Add(nameof(chargeDelayTrackBar.Value), |
||
115 | Configuration.Spring.Charge, |
||
116 | nameof(Configuration.Spring.Charge.ChargeSeconds), |
||
117 | false, |
||
118 | DataSourceUpdateMode.OnPropertyChanged); |
||
119 | |||
120 | textBox3.Text = Configuration.Spring.Charge.ChargeSeconds.ToString(); |
||
121 | |||
122 | maximumRepeatsTrackBar.DataBindings.Add(nameof(maximumRepeatsTrackBar.Value), |
||
123 | Configuration.Spring.Charge, |
||
124 | nameof(Configuration.Spring.Charge.MaximumRepeats), |
||
125 | false, |
||
126 | DataSourceUpdateMode.OnPropertyChanged); |
||
127 | |||
128 | textBox1.Text = Configuration.Spring.Charge.MaximumRepeats.ToString(); |
||
129 | } |
||
130 | |||
131 | private SettingsForm() |
||
132 | { |
||
133 | InitializeComponent(); |
||
134 | |||
135 | PanelGraphics = hudPostionPanel.CreateGraphics(); |
||
136 | PanelBounds = PanelGraphics.VisibleClipBounds; |
||
137 | PanelSolidColorBrush = new SolidBrush(hudPostionPanel.BackColor); |
||
138 | PanelRegion = new Region(PanelBounds); |
||
139 | } |
||
140 | |||
2 | office | 141 | #endregion |
1 | office | 142 | |
2 | office | 143 | #region Event Handlers |
144 | private void SettingsForm_Load(object sender, EventArgs e) |
||
145 | { |
||
146 | Utilities.WindowState.FormTracker.Track(this); |
||
147 | } |
||
1 | office | 148 | private void ListBox1_SelectedIndexChanged(object sender, EventArgs e) |
149 | { |
||
150 | var listBox = (ListBox) sender; |
||
151 | var item = listBox.SelectedItem; |
||
152 | |||
153 | if (item == null) |
||
154 | { |
||
155 | return; |
||
156 | } |
||
157 | |||
158 | whiteListEntryTextBox.Text = item.ToString(); |
||
159 | } |
||
160 | |||
161 | private void Button2_Click(object sender, EventArgs e) |
||
162 | { |
||
163 | var text = whiteListEntryTextBox.Text; |
||
164 | |||
165 | if (string.IsNullOrEmpty(text)) |
||
166 | { |
||
167 | return; |
||
168 | } |
||
169 | |||
170 | try |
||
171 | { |
||
172 | var _ = new Regex(text, RegexOptions.Compiled); |
||
173 | } |
||
174 | catch |
||
175 | { |
||
176 | return; |
||
177 | } |
||
178 | |||
179 | if (!WhitelistBinding.Contains(text)) |
||
180 | { |
||
181 | WhitelistBinding.Add(text); |
||
182 | } |
||
183 | } |
||
184 | |||
185 | private void Button3_Click(object sender, EventArgs e) |
||
186 | { |
||
187 | var item = windowWhiteListListBox.SelectedItem; |
||
188 | |||
189 | if (item == null) |
||
190 | { |
||
191 | return; |
||
192 | } |
||
193 | |||
194 | var text = item.ToString(); |
||
195 | |||
196 | if (string.IsNullOrEmpty(text)) |
||
197 | { |
||
198 | return; |
||
199 | } |
||
200 | |||
201 | if (WhitelistBinding.Contains(text)) |
||
202 | { |
||
203 | WhitelistBinding.Remove(text); |
||
204 | } |
||
205 | } |
||
206 | |||
207 | private void Button1_Click(object sender, EventArgs e) |
||
208 | { |
||
209 | if (colorDialog1.ShowDialog() != DialogResult.OK) |
||
210 | { |
||
211 | return; |
||
212 | } |
||
213 | |||
214 | Configuration.HUD.Color = colorDialog1.Color; |
||
215 | hudColorLabel.BackColor = colorDialog1.Color; |
||
216 | } |
||
217 | |||
218 | private void SpringSettingsForm_Shown(object sender, EventArgs e) |
||
219 | { |
||
220 | var x = Configuration.HUD.Position.X * PanelBounds.Width / 100f; |
||
221 | var y = Configuration.HUD.Position.Y * PanelBounds.Height / 100f; |
||
222 | |||
223 | PanelGraphics.FillRegion(PanelSolidColorBrush, PanelRegion); |
||
224 | |||
225 | PanelGraphics.DrawIcon(Resources.x, |
||
226 | (int) (x - Resources.x.Width / 2f), |
||
227 | (int) (y - Resources.x.Height / 2f)); |
||
228 | } |
||
229 | |||
230 | private void HUDPositionPanel_MouseClick(object sender, MouseEventArgs e) |
||
231 | { |
||
232 | var x = e.Location.X; |
||
233 | var y = e.Location.Y; |
||
234 | |||
235 | Configuration.HUD.Position.X = (int) (100f * x / PanelBounds.Width); |
||
236 | Configuration.HUD.Position.Y = (int) (100f * y / PanelBounds.Height); |
||
237 | |||
238 | PanelGraphics.FillRegion(PanelSolidColorBrush, PanelRegion); |
||
239 | |||
240 | PanelGraphics.DrawIcon(Resources.x, |
||
241 | (int) (x - Resources.x.Width / 2f), |
||
242 | (int) (y - Resources.x.Height / 2f)); |
||
243 | } |
||
244 | |||
245 | private void HUDColorLabel_Click(object sender, EventArgs e) |
||
246 | { |
||
247 | if (colorDialog1.ShowDialog() != DialogResult.OK) |
||
248 | { |
||
249 | return; |
||
250 | } |
||
251 | |||
252 | Configuration.HUD.Color = colorDialog1.Color; |
||
253 | hudColorLabel.BackColor = colorDialog1.Color; |
||
254 | } |
||
255 | |||
256 | private void TabControl1_SelectedIndexChanged(object sender, EventArgs e) |
||
257 | { |
||
258 | var x = Configuration.HUD.Position.X * PanelBounds.Width / 100f; |
||
259 | var y = Configuration.HUD.Position.Y * PanelBounds.Height / 100f; |
||
260 | |||
261 | PanelGraphics.FillRegion(PanelSolidColorBrush, PanelRegion); |
||
262 | |||
263 | PanelGraphics.DrawIcon(Resources.x, |
||
264 | (int) (x - Resources.x.Width / 2f), |
||
265 | (int) (y - Resources.x.Height / 2f)); |
||
266 | } |
||
267 | |||
268 | private void FuzzTrackBar_Scroll(object sender, EventArgs e) |
||
269 | { |
||
270 | var trackBar = (TrackBar) sender; |
||
271 | |||
272 | textBox2.Text = trackBar.Value.ToString(); |
||
273 | } |
||
274 | |||
275 | private void TextBox2_TextChanged(object sender, EventArgs e) |
||
276 | { |
||
277 | var textBox = (TextBox) sender; |
||
278 | |||
279 | if (!int.TryParse(textBox.Text, out var value) || |
||
280 | value < fuzzTrackBar.Minimum || |
||
281 | value > fuzzTrackBar.Maximum) |
||
282 | { |
||
283 | return; |
||
284 | } |
||
285 | |||
286 | fuzzTrackBar.Value = value; |
||
287 | } |
||
288 | |||
289 | private void MaximumRepeatsTrackBar_Scroll(object sender, EventArgs e) |
||
290 | { |
||
291 | var trackBar = (TrackBar) sender; |
||
292 | |||
293 | textBox1.Text = trackBar.Value.ToString(); |
||
294 | } |
||
295 | |||
296 | private void TextBox3_TextChanged(object sender, EventArgs e) |
||
297 | { |
||
298 | var textBox = (TextBox) sender; |
||
299 | |||
300 | if (!int.TryParse(textBox.Text, out var value) || |
||
301 | value < chargeDelayTrackBar.Minimum || |
||
302 | value > chargeDelayTrackBar.Maximum) |
||
303 | { |
||
304 | return; |
||
305 | } |
||
306 | |||
307 | chargeDelayTrackBar.Value = value; |
||
308 | } |
||
309 | |||
310 | private void ChargeDelayTrackBar_Scroll(object sender, EventArgs e) |
||
311 | { |
||
312 | var trackBar = (TrackBar) sender; |
||
313 | |||
314 | textBox3.Text = trackBar.Value.ToString(); |
||
315 | } |
||
316 | |||
317 | private void TextBox1_TextChanged(object sender, EventArgs e) |
||
318 | { |
||
319 | var textBox = (TextBox) sender; |
||
320 | |||
321 | if (!int.TryParse(textBox.Text, out var value) || |
||
322 | value < maximumRepeatsTrackBar.Minimum || |
||
323 | value > maximumRepeatsTrackBar.Maximum) |
||
324 | { |
||
325 | return; |
||
326 | } |
||
327 | |||
328 | maximumRepeatsTrackBar.Value = value; |
||
329 | } |
||
330 | |||
2 | office | 331 | #endregion |
332 | |||
333 | |||
1 | office | 334 | } |
335 | } |