corrade-vassal – Diff between revs 7 and 8
?pathlinks?
Rev 7 | Rev 8 | |||
---|---|---|---|---|
Line 3... | Line 3... | |||
3 | // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // |
3 | // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // |
|
4 | // rights of fair usage, the disclaimer and warranty conditions. // |
4 | // rights of fair usage, the disclaimer and warranty conditions. // |
|
5 | /////////////////////////////////////////////////////////////////////////// |
5 | /////////////////////////////////////////////////////////////////////////// |
|
Line 6... | Line 6... | |||
6 | |
6 | |
|
7 | using System; |
- | ||
8 | using System.Collections.Generic; |
7 | using System; |
|
9 | using System.ComponentModel; |
- | ||
10 | using System.Data; |
8 | using System.ComponentModel; |
|
11 | using System.Drawing; |
9 | using System.Drawing; |
|
12 | using System.IO; |
10 | using System.IO; |
|
13 | using System.Linq; |
11 | using System.Linq; |
|
14 | using System.Net.Sockets; |
12 | using System.Net.Sockets; |
|
15 | using System.Reflection; |
- | ||
16 | using System.Text; |
13 | using System.Reflection; |
|
17 | using System.Threading; |
- | ||
18 | using System.Threading.Tasks; |
14 | using System.Threading; |
|
19 | using System.Windows.Forms; |
- | ||
20 | using System.Xml.Serialization; |
15 | using System.Windows.Forms; |
|
Line 21... | Line 16... | |||
21 | using OpenMetaverse; |
16 | using OpenMetaverse; |
|
22 | |
17 | |
|
23 | namespace Vassal |
18 | namespace Vassal |
|
24 | { |
19 | { |
|
25 | public partial class SettingsForm : Form |
20 | public partial class SettingsForm : Form |
|
26 | { |
- | ||
27 | private static SettingsForm mainForm; |
- | ||
28 | |
- | ||
29 | /////////////////////////////////////////////////////////////////////////// |
- | ||
30 | // Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 // |
- | ||
31 | /////////////////////////////////////////////////////////////////////////// |
- | ||
32 | /// <summary> |
- | ||
33 | /// Get enumeration value from its description. |
- | ||
34 | /// </summary> |
- | ||
35 | /// <typeparam name="T">the enumeration type</typeparam> |
- | ||
36 | /// <param name="description">the description of a member</param> |
- | ||
37 | /// <returns>the value or the default of T if case no description found</returns> |
- | ||
38 | private static T wasGetEnumValueFromDescription<T>(string description) |
- | ||
39 | { |
- | ||
40 | var field = typeof(T).GetFields() |
- | ||
41 | .AsParallel().SelectMany(f => f.GetCustomAttributes( |
- | ||
42 | typeof(DescriptionAttribute), false), ( |
- | ||
43 | f, a) => new { Field = f, Att = a }).SingleOrDefault(a => ((DescriptionAttribute)a.Att) |
- | ||
44 | .Description.Equals(description)); |
- | ||
45 | return field != null ? (T)field.Field.GetRawConstantValue() : default(T); |
- | ||
46 | } |
- | ||
47 | |
- | ||
48 | /////////////////////////////////////////////////////////////////////////// |
- | ||
49 | // Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 // |
- | ||
50 | /////////////////////////////////////////////////////////////////////////// |
- | ||
51 | /// <summary> |
- | ||
52 | /// Get the description from an enumeration value. |
- | ||
53 | /// </summary> |
- | ||
54 | /// <param name="value">an enumeration value</param> |
- | ||
55 | /// <returns>the description or the empty string</returns> |
- | ||
56 | private static string wasGetDescriptionFromEnumValue(Enum value) |
- | ||
57 | { |
- | ||
58 | DescriptionAttribute attribute = value.GetType() |
- | ||
59 | .GetField(value.ToString()) |
- | ||
60 | .GetCustomAttributes(typeof(DescriptionAttribute), false) |
- | ||
61 | .SingleOrDefault() as DescriptionAttribute; |
- | ||
62 | return attribute != null ? attribute.Description : string.Empty; |
- | ||
63 | } |
- | ||
64 | |
- | ||
65 | private readonly Action SetUserConfiguration = () => |
- | ||
66 | { |
- | ||
67 | // general |
- | ||
68 | Vassal.vassalConfiguration.HTTPServerURL = mainForm.HTTPServerURL.Text; |
- | ||
69 | Vassal.vassalConfiguration.Group = mainForm.Group.Text; |
- | ||
70 | Vassal.vassalConfiguration.Password = mainForm.Password.Text; |
- | ||
71 | uint outUint; |
- | ||
72 | if (uint.TryParse(mainForm.TeleportTimeout.Text, out outUint)) |
- | ||
73 | { |
- | ||
74 | Vassal.vassalConfiguration.TeleportTimeout = outUint; |
- | ||
75 | } |
- | ||
76 | if (uint.TryParse(mainForm.DataTimeout.Text, out outUint)) |
- | ||
77 | { |
- | ||
78 | Vassal.vassalConfiguration.DataTimeout = outUint; |
- | ||
79 | } |
- | ||
80 | if (uint.TryParse(mainForm.RegionRestartDelay.Text, out outUint)) |
- | ||
81 | { |
- | ||
82 | Vassal.vassalConfiguration.RegionRestartDelay = outUint; |
- | ||
83 | } |
- | ||
84 | |
- | ||
85 | // filters |
- | ||
86 | Vassal.vassalConfiguration.InputFilters = |
- | ||
87 | mainForm.ActiveInputFilters.Items.Cast<ListViewItem>().Select(o => (Filter)o.Tag).ToList(); |
- | ||
88 | Vassal.vassalConfiguration.OutputFilters = |
- | ||
89 | mainForm.ActiveOutputFilters.Items.Cast<ListViewItem>().Select(o => (Filter)o.Tag).ToList(); |
- | ||
90 | |
- | ||
91 | // cryptography |
- | ||
92 | Vassal.vassalConfiguration.ENIGMA = new ENIGMA |
- | ||
93 | { |
- | ||
94 | rotors = mainForm.ENIGMARotorSequence.Items.Cast<ListViewItem>().Select(o => (char)o.Tag).ToArray(), |
- | ||
95 | plugs = mainForm.ENIGMAPlugSequence.Items.Cast<ListViewItem>().Select(o => (char)o.Tag).ToArray(), |
- | ||
96 | reflector = mainForm.ENIGMAReflector.Text[0] |
- | ||
97 | }; |
- | ||
98 | |
- | ||
99 | Vassal.vassalConfiguration.VIGENERESecret = mainForm.VIGENERESecret.Text; |
- | ||
Line 100... | Line 21... | |||
100 | |
21 | { |
|
101 | }; |
22 | private static SettingsForm mainForm; |
|
102 | |
23 | |
|
103 | private readonly Action GetUserConfiguration = () => |
24 | private readonly Action GetUserConfiguration = () => |
|
Line 155... | Line 76... | |||
155 | mainForm.ENIGMAPlugSequence.DisplayMember = "Text"; |
76 | mainForm.ENIGMAPlugSequence.DisplayMember = "Text"; |
|
156 | mainForm.ENIGMAReflector.Text = Vassal.vassalConfiguration.ENIGMA.reflector.ToString(); |
77 | mainForm.ENIGMAReflector.Text = Vassal.vassalConfiguration.ENIGMA.reflector.ToString(); |
|
157 | mainForm.VIGENERESecret.Text = Vassal.vassalConfiguration.VIGENERESecret; |
78 | mainForm.VIGENERESecret.Text = Vassal.vassalConfiguration.VIGENERESecret; |
|
158 | }; |
79 | }; |
|
Line -... | Line 80... | |||
- | 80 | |
||
- | 81 | private readonly Action SetUserConfiguration = () => |
||
- | 82 | { |
||
- | 83 | // general |
||
- | 84 | Vassal.vassalConfiguration.HTTPServerURL = mainForm.HTTPServerURL.Text; |
||
- | 85 | Vassal.vassalConfiguration.Group = mainForm.Group.Text; |
||
- | 86 | Vassal.vassalConfiguration.Password = mainForm.Password.Text; |
||
- | 87 | uint outUint; |
||
- | 88 | if (uint.TryParse(mainForm.TeleportTimeout.Text, out outUint)) |
||
- | 89 | { |
||
- | 90 | Vassal.vassalConfiguration.TeleportTimeout = outUint; |
||
- | 91 | } |
||
- | 92 | if (uint.TryParse(mainForm.DataTimeout.Text, out outUint)) |
||
- | 93 | { |
||
- | 94 | Vassal.vassalConfiguration.DataTimeout = outUint; |
||
- | 95 | } |
||
- | 96 | if (uint.TryParse(mainForm.RegionRestartDelay.Text, out outUint)) |
||
- | 97 | { |
||
- | 98 | Vassal.vassalConfiguration.RegionRestartDelay = outUint; |
||
- | 99 | } |
||
- | 100 | |
||
- | 101 | // filters |
||
- | 102 | Vassal.vassalConfiguration.InputFilters = |
||
- | 103 | mainForm.ActiveInputFilters.Items.Cast<ListViewItem>().Select(o => (Filter) o.Tag).ToList(); |
||
- | 104 | Vassal.vassalConfiguration.OutputFilters = |
||
- | 105 | mainForm.ActiveOutputFilters.Items.Cast<ListViewItem>().Select(o => (Filter) o.Tag).ToList(); |
||
- | 106 | |
||
- | 107 | // cryptography |
||
- | 108 | Vassal.vassalConfiguration.ENIGMA = new ENIGMA |
||
- | 109 | { |
||
- | 110 | rotors = mainForm.ENIGMARotorSequence.Items.Cast<ListViewItem>().Select(o => (char) o.Tag).ToArray(), |
||
- | 111 | plugs = mainForm.ENIGMAPlugSequence.Items.Cast<ListViewItem>().Select(o => (char) o.Tag).ToArray(), |
||
- | 112 | reflector = mainForm.ENIGMAReflector.Text[0] |
||
- | 113 | }; |
||
- | 114 | |
||
- | 115 | Vassal.vassalConfiguration.VIGENERESecret = mainForm.VIGENERESecret.Text; |
||
- | 116 | }; |
||
159 | |
117 | |
|
160 | public SettingsForm() |
118 | public SettingsForm() |
|
161 | { |
119 | { |
|
162 | InitializeComponent(); |
120 | InitializeComponent(); |
|
163 | mainForm = this; |
121 | mainForm = this; |
|
Line -... | Line 122... | |||
- | 122 | } |
||
- | 123 | |
||
- | 124 | /////////////////////////////////////////////////////////////////////////// |
||
- | 125 | // Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 // |
||
- | 126 | /////////////////////////////////////////////////////////////////////////// |
||
- | 127 | /// <summary> |
||
- | 128 | /// Get enumeration value from its description. |
||
- | 129 | /// </summary> |
||
- | 130 | /// <typeparam name="T">the enumeration type</typeparam> |
||
- | 131 | /// <param name="description">the description of a member</param> |
||
- | 132 | /// <returns>the value or the default of T if case no description found</returns> |
||
- | 133 | private static T wasGetEnumValueFromDescription<T>(string description) |
||
- | 134 | { |
||
- | 135 | var field = typeof (T).GetFields() |
||
- | 136 | .AsParallel().SelectMany(f => f.GetCustomAttributes( |
||
- | 137 | typeof (DescriptionAttribute), false), ( |
||
- | 138 | f, a) => new {Field = f, Att = a}).SingleOrDefault(a => ((DescriptionAttribute) a.Att) |
||
- | 139 | .Description.Equals(description)); |
||
- | 140 | return field != null ? (T) field.Field.GetRawConstantValue() : default(T); |
||
- | 141 | } |
||
- | 142 | |
||
- | 143 | /////////////////////////////////////////////////////////////////////////// |
||
- | 144 | // Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 // |
||
- | 145 | /////////////////////////////////////////////////////////////////////////// |
||
- | 146 | /// <summary> |
||
- | 147 | /// Get the description from an enumeration value. |
||
- | 148 | /// </summary> |
||
- | 149 | /// <param name="value">an enumeration value</param> |
||
- | 150 | /// <returns>the description or the empty string</returns> |
||
- | 151 | private static string wasGetDescriptionFromEnumValue(Enum value) |
||
- | 152 | { |
||
- | 153 | DescriptionAttribute attribute = value.GetType() |
||
- | 154 | .GetField(value.ToString()) |
||
- | 155 | .GetCustomAttributes(typeof (DescriptionAttribute), false) |
||
- | 156 | .SingleOrDefault() as DescriptionAttribute; |
||
- | 157 | return attribute != null ? attribute.Description : string.Empty; |
||
164 | } |
158 | } |
|
165 | |
159 | |
|
166 | private void LoadSettingsRequested(object sender, EventArgs e) |
160 | private void LoadSettingsRequested(object sender, EventArgs e) |
|
167 | { |
161 | { |
|
168 | mainForm.BeginInvoke((MethodInvoker)(() => |
162 | mainForm.BeginInvoke((MethodInvoker) (() => |
|
169 | { |
163 | { |
|
170 | switch (mainForm.LoadSettingsDialog.ShowDialog()) |
164 | switch (mainForm.LoadSettingsDialog.ShowDialog()) |
|
171 | { |
165 | { |
|
172 | case DialogResult.OK: |
166 | case DialogResult.OK: |
|
173 | string file = mainForm.LoadSettingsDialog.FileName; |
167 | string file = mainForm.LoadSettingsDialog.FileName; |
|
174 | new Thread(() => |
168 | new Thread(() => |
|
175 | { |
169 | { |
|
176 | mainForm.BeginInvoke((MethodInvoker)(() => |
170 | mainForm.BeginInvoke((MethodInvoker) (() => |
|
177 | { |
171 | { |
|
178 | try |
172 | try |
|
179 | { |
173 | { |
|
Line 192... | Line 186... | |||
192 | { |
186 | { |
|
193 | mainForm.StatusText.Text = ex.Message; |
187 | mainForm.StatusText.Text = ex.Message; |
|
194 | } |
188 | } |
|
195 | })); |
189 | })); |
|
196 | }) |
190 | }) |
|
197 | { IsBackground = true, Priority = ThreadPriority.Normal }.Start(); |
191 | {IsBackground = true, Priority = ThreadPriority.Normal}.Start(); |
|
198 | break; |
192 | break; |
|
199 | } |
193 | } |
|
200 | })); |
194 | })); |
|
201 | } |
195 | } |
|
Line 202... | Line 196... | |||
202 | |
196 | |
|
203 | private void SaveSettingsRequested(object sender, EventArgs e) |
197 | private void SaveSettingsRequested(object sender, EventArgs e) |
|
204 | { |
198 | { |
|
205 | mainForm.BeginInvoke((MethodInvoker)(() => |
199 | mainForm.BeginInvoke((MethodInvoker) (() => |
|
206 | { |
200 | { |
|
207 | switch (mainForm.SaveSettingsDialog.ShowDialog()) |
201 | switch (mainForm.SaveSettingsDialog.ShowDialog()) |
|
208 | { |
202 | { |
|
209 | case DialogResult.OK: |
203 | case DialogResult.OK: |
|
210 | string file = mainForm.SaveSettingsDialog.FileName; |
204 | string file = mainForm.SaveSettingsDialog.FileName; |
|
211 | new Thread(() => |
205 | new Thread(() => |
|
212 | { |
206 | { |
|
213 | mainForm.BeginInvoke((MethodInvoker)(() => |
207 | mainForm.BeginInvoke((MethodInvoker) (() => |
|
214 | { |
208 | { |
|
215 | try |
209 | try |
|
216 | { |
210 | { |
|
217 | mainForm.StatusText.Text = @"saving settings..."; |
211 | mainForm.StatusText.Text = @"saving settings..."; |
|
Line 231... | Line 225... | |||
231 | { |
225 | { |
|
232 | mainForm.StatusText.Text = ex.Message; |
226 | mainForm.StatusText.Text = ex.Message; |
|
233 | } |
227 | } |
|
234 | })); |
228 | })); |
|
235 | }) |
229 | }) |
|
236 | { IsBackground = true, Priority = ThreadPriority.Normal }.Start(); |
230 | {IsBackground = true, Priority = ThreadPriority.Normal}.Start(); |
|
237 | break; |
231 | break; |
|
238 | } |
232 | } |
|
239 | })); |
233 | })); |
|
240 | } |
234 | } |
|
Line 241... | Line 235... | |||
241 | |
235 | |
|
242 | private void AddInputDecoderRequested(object sender, EventArgs e) |
236 | private void AddInputDecoderRequested(object sender, EventArgs e) |
|
243 | { |
237 | { |
|
244 | mainForm.BeginInvoke((MethodInvoker)(() => |
238 | mainForm.BeginInvoke((MethodInvoker) (() => |
|
245 | { |
239 | { |
|
246 | if (string.IsNullOrEmpty(InputDecode.Text)) |
240 | if (string.IsNullOrEmpty(InputDecode.Text)) |
|
247 | { |
241 | { |
|
248 | InputDecode.BackColor = Color.MistyRose; |
242 | InputDecode.BackColor = Color.MistyRose; |
|
Line 257... | Line 251... | |||
257 | })); |
251 | })); |
|
258 | } |
252 | } |
|
Line 259... | Line 253... | |||
259 | |
253 | |
|
260 | private void AddInputDecryptionRequested(object sender, EventArgs e) |
254 | private void AddInputDecryptionRequested(object sender, EventArgs e) |
|
261 | { |
255 | { |
|
262 | mainForm.BeginInvoke((MethodInvoker)(() => |
256 | mainForm.BeginInvoke((MethodInvoker) (() => |
|
263 | { |
257 | { |
|
264 | if (string.IsNullOrEmpty(InputDecryption.Text)) |
258 | if (string.IsNullOrEmpty(InputDecryption.Text)) |
|
265 | { |
259 | { |
|
266 | InputDecryption.BackColor = Color.MistyRose; |
260 | InputDecryption.BackColor = Color.MistyRose; |
|
Line 275... | Line 269... | |||
275 | })); |
269 | })); |
|
276 | } |
270 | } |
|
Line 277... | Line 271... | |||
277 | |
271 | |
|
278 | private void AddOutputEncryptionRequested(object sender, EventArgs e) |
272 | private void AddOutputEncryptionRequested(object sender, EventArgs e) |
|
279 | { |
273 | { |
|
280 | mainForm.BeginInvoke((MethodInvoker)(() => |
274 | mainForm.BeginInvoke((MethodInvoker) (() => |
|
281 | { |
275 | { |
|
282 | if (string.IsNullOrEmpty(OutputEncrypt.Text)) |
276 | if (string.IsNullOrEmpty(OutputEncrypt.Text)) |
|
283 | { |
277 | { |
|
284 | OutputEncrypt.BackColor = Color.MistyRose; |
278 | OutputEncrypt.BackColor = Color.MistyRose; |
|
Line 293... | Line 287... | |||
293 | })); |
287 | })); |
|
294 | } |
288 | } |
|
Line 295... | Line 289... | |||
295 | |
289 | |
|
296 | private void AddOutputEncoderRequested(object sender, EventArgs e) |
290 | private void AddOutputEncoderRequested(object sender, EventArgs e) |
|
297 | { |
291 | { |
|
298 | mainForm.BeginInvoke((MethodInvoker)(() => |
292 | mainForm.BeginInvoke((MethodInvoker) (() => |
|
299 | { |
293 | { |
|
300 | if (string.IsNullOrEmpty(OutputEncode.Text)) |
294 | if (string.IsNullOrEmpty(OutputEncode.Text)) |
|
301 | { |
295 | { |
|
302 | OutputEncode.BackColor = Color.MistyRose; |
296 | OutputEncode.BackColor = Color.MistyRose; |
|
Line 311... | Line 305... | |||
311 | })); |
305 | })); |
|
312 | } |
306 | } |
|
Line 313... | Line 307... | |||
313 | |
307 | |
|
314 | private void DeleteSelectedOutputFilterRequested(object sender, EventArgs e) |
308 | private void DeleteSelectedOutputFilterRequested(object sender, EventArgs e) |
|
315 | { |
309 | { |
|
316 | mainForm.BeginInvoke((MethodInvoker)(() => |
310 | mainForm.BeginInvoke((MethodInvoker) (() => |
|
317 | { |
311 | { |
|
318 | ListViewItem listViewItem = ActiveOutputFilters.SelectedItem as ListViewItem; |
312 | ListViewItem listViewItem = ActiveOutputFilters.SelectedItem as ListViewItem; |
|
319 | if (listViewItem == null) |
313 | if (listViewItem == null) |
|
320 | { |
314 | { |
|
Line 326... | Line 320... | |||
326 | })); |
320 | })); |
|
327 | } |
321 | } |
|
Line 328... | Line 322... | |||
328 | |
322 | |
|
329 | private void DeleteSelectedInputFilterRequested(object sender, EventArgs e) |
323 | private void DeleteSelectedInputFilterRequested(object sender, EventArgs e) |
|
330 | { |
324 | { |
|
331 | mainForm.BeginInvoke((MethodInvoker)(() => |
325 | mainForm.BeginInvoke((MethodInvoker) (() => |
|
332 | { |
326 | { |
|
333 | ListViewItem listViewItem = ActiveInputFilters.SelectedItem as ListViewItem; |
327 | ListViewItem listViewItem = ActiveInputFilters.SelectedItem as ListViewItem; |
|
334 | if (listViewItem == null) |
328 | if (listViewItem == null) |
|
335 | { |
329 | { |
|
Line 341... | Line 335... | |||
341 | })); |
335 | })); |
|
342 | } |
336 | } |
|
Line 343... | Line 337... | |||
343 | |
337 | |
|
344 | private void AddENIGMARotorRequested(object sender, EventArgs e) |
338 | private void AddENIGMARotorRequested(object sender, EventArgs e) |
|
345 | { |
339 | { |
|
346 | mainForm.BeginInvoke((MethodInvoker)(() => |
340 | mainForm.BeginInvoke((MethodInvoker) (() => |
|
347 | { |
341 | { |
|
348 | if (string.IsNullOrEmpty(ENIGMARotor.Text)) |
342 | if (string.IsNullOrEmpty(ENIGMARotor.Text)) |
|
349 | { |
343 | { |
|
350 | ENIGMARotor.BackColor = Color.MistyRose; |
344 | ENIGMARotor.BackColor = Color.MistyRose; |
|
Line 359... | Line 353... | |||
359 | })); |
353 | })); |
|
360 | } |
354 | } |
|
Line 361... | Line 355... | |||
361 | |
355 | |
|
362 | private void DeleteENIGMARotorRequested(object sender, EventArgs e) |
356 | private void DeleteENIGMARotorRequested(object sender, EventArgs e) |
|
363 | { |
357 | { |
|
364 | mainForm.BeginInvoke((MethodInvoker)(() => |
358 | mainForm.BeginInvoke((MethodInvoker) (() => |
|
365 | { |
359 | { |
|
366 | ListViewItem listViewItem = ENIGMARotorSequence.SelectedItem as ListViewItem; |
360 | ListViewItem listViewItem = ENIGMARotorSequence.SelectedItem as ListViewItem; |
|
367 | if (listViewItem == null) |
361 | if (listViewItem == null) |
|
368 | { |
362 | { |
|
Line 374... | Line 368... | |||
374 | })); |
368 | })); |
|
375 | } |
369 | } |
|
Line 376... | Line 370... | |||
376 | |
370 | |
|
377 | private void AddENIGMAPlugRequested(object sender, EventArgs e) |
371 | private void AddENIGMAPlugRequested(object sender, EventArgs e) |
|
378 | { |
372 | { |
|
379 | mainForm.BeginInvoke((MethodInvoker)(() => |
373 | mainForm.BeginInvoke((MethodInvoker) (() => |
|
380 | { |
374 | { |
|
381 | if (string.IsNullOrEmpty(ENIGMARing.Text)) |
375 | if (string.IsNullOrEmpty(ENIGMARing.Text)) |
|
382 | { |
376 | { |
|
383 | ENIGMARing.BackColor = Color.MistyRose; |
377 | ENIGMARing.BackColor = Color.MistyRose; |
|
Line 392... | Line 386... | |||
392 | })); |
386 | })); |
|
393 | } |
387 | } |
|
Line 394... | Line 388... | |||
394 | |
388 | |
|
395 | private void DeleteENIGMAPlugRequested(object sender, EventArgs e) |
389 | private void DeleteENIGMAPlugRequested(object sender, EventArgs e) |
|
396 | { |
390 | { |
|
397 | mainForm.BeginInvoke((MethodInvoker)(() => |
391 | mainForm.BeginInvoke((MethodInvoker) (() => |
|
398 | { |
392 | { |
|
399 | ListViewItem listViewItem = ENIGMAPlugSequence.SelectedItem as ListViewItem; |
393 | ListViewItem listViewItem = ENIGMAPlugSequence.SelectedItem as ListViewItem; |
|
400 | if (listViewItem == null) |
394 | if (listViewItem == null) |
|
401 | { |
395 | { |
|
Line 416... | Line 410... | |||
416 | { |
410 | { |
|
417 | // apply configuration |
411 | // apply configuration |
|
418 | SetUserConfiguration.Invoke(); |
412 | SetUserConfiguration.Invoke(); |
|
419 | // save settings |
413 | // save settings |
|
420 | VassalConfiguration.Save(Vassal.VASSAL_CONSTANTS.VASSAL_CONFIGURATION_FILE, ref Vassal.vassalConfiguration); |
414 | VassalConfiguration.Save(Vassal.VASSAL_CONSTANTS.VASSAL_CONFIGURATION_FILE, ref Vassal.vassalConfiguration); |
|
421 | // set parameters for Vassal |
- | ||
422 | mainForm.Invoke((MethodInvoker) (() => |
- | ||
423 | { |
- | ||
424 | Vassal.vassalForm.Invoke((MethodInvoker) (() => |
- | ||
425 | { |
- | ||
426 | if (string.IsNullOrEmpty(Vassal.vassalForm.RegionRestartDelayBox.Text)) |
- | ||
427 | { |
- | ||
428 | Vassal.vassalForm.RegionRestartDelayBox.Text = mainForm.RegionRestartDelay.Text; |
- | ||
429 | } |
- | ||
430 | })); |
- | ||
431 | })); |
- | ||
432 | // Spawn a thread to check Corrade's connection status. |
415 | // Spawn a thread to check Corrade's connection status. |
|
433 | new Thread(() => |
416 | new Thread(() => |
|
434 | { |
417 | { |
|
435 | TcpClient tcpClient = new TcpClient(); |
418 | TcpClient tcpClient = new TcpClient(); |
|
436 | try |
419 | try |
|
437 | { |
420 | { |
|
438 | System.Uri uri = new System.Uri(Vassal.vassalConfiguration.HTTPServerURL); |
421 | Uri uri = new Uri(Vassal.vassalConfiguration.HTTPServerURL); |
|
439 | tcpClient.Connect(uri.Host, uri.Port); |
422 | tcpClient.Connect(uri.Host, uri.Port); |
|
440 | // port open |
423 | // port open |
|
441 | Vassal.vassalForm.BeginInvoke((MethodInvoker)(() => { Vassal.vassalForm.Tabs.Enabled = true; })); |
424 | Vassal.vassalForm.BeginInvoke((MethodInvoker) (() => { Vassal.vassalForm.Tabs.Enabled = true; })); |
|
442 | // set the loading spinner |
425 | // set the loading spinner |
|
443 | Assembly thisAssembly = System.Reflection.Assembly.GetExecutingAssembly(); |
- | ||
444 | System.IO.Stream file = |
- | ||
445 | thisAssembly.GetManifestResourceStream("Vassal.img.loading.gif"); |
426 | if (Vassal.vassalForm.RegionAvatarsMap.Image == null) |
|
446 | switch (file != null) |
- | ||
447 | { |
427 | { |
|
- | 428 | Assembly thisAssembly = Assembly.GetExecutingAssembly(); |
||
- | 429 | Stream file = |
||
- | 430 | thisAssembly.GetManifestResourceStream("Vassal.img.loading.gif"); |
||
- | 431 | switch (file != null) |
||
- | 432 | { |
||
448 | case true: |
433 | case true: |
|
449 | Vassal.vassalForm.BeginInvoke((MethodInvoker)(() => |
434 | Vassal.vassalForm.BeginInvoke((MethodInvoker) (() => |
|
450 | { |
435 | { |
|
451 | Vassal.vassalForm.RegionAvatarsMap.SizeMode = PictureBoxSizeMode.CenterImage; |
436 | Vassal.vassalForm.RegionAvatarsMap.SizeMode = PictureBoxSizeMode.CenterImage; |
|
452 | Vassal.vassalForm.RegionAvatarsMap.Image = Image.FromStream(file); |
437 | Vassal.vassalForm.RegionAvatarsMap.Image = Image.FromStream(file); |
|
453 | Vassal.vassalForm.RegionAvatarsMap.Refresh(); |
438 | Vassal.vassalForm.RegionAvatarsMap.Refresh(); |
|
454 | })); |
439 | })); |
|
455 | break; |
440 | break; |
|
- | 441 | } |
||
456 | } |
442 | } |
|
457 | } |
443 | } |
|
458 | catch (Exception) |
444 | catch (Exception) |
|
459 | { |
445 | { |
|
460 | // port closed |
446 | // port closed |
|
461 | Vassal.vassalForm.BeginInvoke((MethodInvoker)(() => { Vassal.vassalForm.Tabs.Enabled = false; })); |
447 | Vassal.vassalForm.BeginInvoke((MethodInvoker) (() => { Vassal.vassalForm.Tabs.Enabled = false; })); |
|
462 | } |
448 | } |
|
463 | }) |
449 | }) |
|
464 | { IsBackground = true }.Start(); |
450 | {IsBackground = true}.Start(); |
|
- | 451 | |
||
- | 452 | // set parameters for Vassal |
||
- | 453 | mainForm.Invoke((MethodInvoker)(() => |
||
- | 454 | { |
||
- | 455 | Vassal.vassalForm.Invoke((MethodInvoker)(() => |
||
- | 456 | { |
||
- | 457 | if (string.IsNullOrEmpty(Vassal.vassalForm.RegionRestartDelayBox.Text)) |
||
- | 458 | { |
||
- | 459 | Vassal.vassalForm.RegionRestartDelayBox.Text = mainForm.RegionRestartDelay.Text; |
||
- | 460 | } |
||
- | 461 | Vassal.vassalForm.VassalStatusGroup.Enabled = true; |
||
- | 462 | })); |
||
- | 463 | })); |
||
465 | } |
464 | } |
|
466 | } |
465 | } |
|
467 | } |
466 | } |
|
468 | |
467 | |