corrade-vassal – Diff between revs 8 and 13
?pathlinks?
Rev 8 | Rev 13 | |||
---|---|---|---|---|
1 | /////////////////////////////////////////////////////////////////////////// |
1 | /////////////////////////////////////////////////////////////////////////// |
|
2 | // Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 // |
2 | // Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 // |
|
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 | /////////////////////////////////////////////////////////////////////////// |
|
6 | |
6 | |
|
7 | using System; |
7 | using System; |
|
8 | using System.Collections.Generic; |
8 | using System.Collections.Generic; |
|
9 | using System.Drawing; |
9 | using System.Drawing; |
|
10 | using System.IO; |
10 | using System.IO; |
|
11 | using System.Linq; |
11 | using System.Linq; |
|
12 | using System.Text; |
12 | using System.Text; |
|
13 | using System.Threading; |
13 | using System.Threading; |
|
14 | using System.Windows.Forms; |
14 | using System.Windows.Forms; |
|
15 | using OpenMetaverse; |
15 | using OpenMetaverse; |
|
- | 16 | using wasSharp; |
||
16 | |
17 | |
|
17 | namespace Vassal |
18 | namespace Vassal |
|
18 | { |
19 | { |
|
19 | public partial class RegionEditForm : Form |
20 | public partial class RegionEditForm : Form |
|
20 | { |
21 | { |
|
21 | private static RegionEditForm mainForm; |
22 | private static RegionEditForm mainForm; |
|
22 | |
23 | |
|
23 | public RegionEditForm() |
24 | public RegionEditForm() |
|
24 | { |
25 | { |
|
25 | InitializeComponent(); |
26 | InitializeComponent(); |
|
26 | mainForm = this; |
27 | mainForm = this; |
|
27 | } |
28 | } |
|
28 | |
29 | |
|
29 | private void LoadRegionsRequested(object sender, EventArgs e) |
30 | private void LoadRegionsRequested(object sender, EventArgs e) |
|
30 | { |
31 | { |
|
31 | mainForm.BeginInvoke((MethodInvoker) (() => |
32 | mainForm.BeginInvoke((MethodInvoker) (() => |
|
32 | { |
33 | { |
|
33 | switch (mainForm.LoadRegionsDialog.ShowDialog()) |
34 | switch (mainForm.LoadRegionsDialog.ShowDialog()) |
|
34 | { |
35 | { |
|
35 | case DialogResult.OK: |
36 | case DialogResult.OK: |
|
36 | string file = mainForm.LoadRegionsDialog.FileName; |
37 | string file = mainForm.LoadRegionsDialog.FileName; |
|
37 | new Thread(() => |
38 | new Thread(() => |
|
38 | { |
39 | { |
|
39 | mainForm.BeginInvoke((MethodInvoker) (() => |
40 | mainForm.BeginInvoke((MethodInvoker) (() => |
|
40 | { |
41 | { |
|
41 | try |
42 | try |
|
42 | { |
43 | { |
|
43 | mainForm.StatusText.Text = @"loading regions..."; |
44 | mainForm.StatusText.Text = @"loading regions..."; |
|
44 | mainForm.StatusProgress.Value = 0; |
45 | mainForm.StatusProgress.Value = 0; |
|
45 | |
46 | |
|
46 | // import CSV regions |
47 | // import CSV regions |
|
47 | Vector3 localPosition; |
48 | Vector3 localPosition; |
|
48 | List<KeyValuePair<string, Vector3>> ConfiguredRegions = new List |
49 | List<KeyValuePair<string, Vector3>> ConfiguredRegions = new List |
|
49 | <KeyValuePair<string, Vector3>>( |
50 | <KeyValuePair<string, Vector3>>( |
|
50 | File.ReadAllLines(file) |
51 | File.ReadAllLines(file) |
|
51 | .AsParallel() |
52 | .AsParallel() |
|
52 | .Select(o => new List<string>(Vassal.wasCSVToEnumerable(o))) |
53 | .Select(o => new List<string>(CSV.ToEnumerable(o))) |
|
53 | .Where(o => o.Count == 2) |
54 | .Where(o => o.Count == 2) |
|
54 | .ToDictionary(o => o.First(), |
55 | .ToDictionary(o => o.First(), |
|
55 | p => |
56 | p => |
|
56 | Vector3.TryParse(p.Last(), out localPosition) |
57 | Vector3.TryParse(p.Last(), out localPosition) |
|
57 | ? localPosition |
58 | ? localPosition |
|
58 | : Vector3.Zero)); |
59 | : Vector3.Zero)); |
|
59 | |
60 | |
|
60 | Vassal.vassalForm.BeginInvoke((MethodInvoker) (() => |
61 | Vassal.vassalForm.BeginInvoke((MethodInvoker) (() => |
|
61 | { |
62 | { |
|
62 | Vassal.vassalForm.LoadedRegionsBox.Items.Clear(); |
63 | Vassal.vassalForm.LoadedRegionsBox.Items.Clear(); |
|
63 | Vassal.vassalForm.LoadedRegionsBox.Items.AddRange( |
64 | Vassal.vassalForm.LoadedRegionsBox.Items.AddRange( |
|
64 | ConfiguredRegions.Select( |
65 | ConfiguredRegions.Select( |
|
65 | o => (object) new ListViewItem {Text = o.Key, Tag = o.Value}) |
66 | o => (object) new ListViewItem {Text = o.Key, Tag = o.Value}) |
|
66 | .ToArray()); |
67 | .ToArray()); |
|
67 | // Update batch restart grid view. |
68 | // Update batch restart grid view. |
|
68 | Vassal.vassalForm.BatchRestartGridView.Rows.Clear(); |
69 | Vassal.vassalForm.BatchRestartGridView.Rows.Clear(); |
|
69 | foreach (KeyValuePair<string, Vector3> data in ConfiguredRegions) |
70 | foreach (KeyValuePair<string, Vector3> data in ConfiguredRegions) |
|
70 | { |
71 | { |
|
71 | Vassal.vassalForm.BatchRestartGridView.Rows.Add(data.Key, data.Value); |
72 | Vassal.vassalForm.BatchRestartGridView.Rows.Add(data.Key, data.Value); |
|
72 | } |
73 | } |
|
73 | // Update region state grid view. |
74 | // Update region state grid view. |
|
74 | Vassal.vassalForm.RegionsStateGridView.Rows.Clear(); |
75 | Vassal.vassalForm.RegionsStateGridView.Rows.Clear(); |
|
75 | foreach (KeyValuePair<string, Vector3> data in ConfiguredRegions) |
76 | foreach (KeyValuePair<string, Vector3> data in ConfiguredRegions) |
|
76 | { |
77 | { |
|
77 | Vassal.vassalForm.RegionsStateGridView.Rows.Add(data.Key, "Check pending...", |
78 | Vassal.vassalForm.RegionsStateGridView.Rows.Add(data.Key, "Check pending...", |
|
78 | DateTime.Now.ToUniversalTime() |
79 | DateTime.Now.ToUniversalTime() |
|
79 | .ToString(Vassal.LINDEN_CONSTANTS.LSL.DATE_TIME_STAMP)); |
80 | .ToString(Vassal.LINDEN_CONSTANTS.LSL.DATE_TIME_STAMP)); |
|
80 | } |
81 | } |
|
81 | })); |
82 | })); |
|
82 | |
83 | |
|
83 | Regions.Items.Clear(); |
84 | Regions.Items.Clear(); |
|
84 | Regions.Items.AddRange( |
85 | Regions.Items.AddRange( |
|
85 | ConfiguredRegions.Select( |
86 | ConfiguredRegions.Select( |
|
86 | o => |
87 | o => |
|
87 | (object) |
88 | (object) |
|
88 | new ListViewItem |
89 | new ListViewItem |
|
89 | { |
90 | { |
|
90 | Text = o.Key + @" " + @"(" + o.Value.ToString() + @")", |
91 | Text = o.Key + @" " + @"(" + o.Value.ToString() + @")", |
|
91 | Tag = o |
92 | Tag = o |
|
92 | }) |
93 | }) |
|
93 | .ToArray()); |
94 | .ToArray()); |
|
94 | |
95 | |
|
95 | mainForm.StatusText.Text = @"regions loaded"; |
96 | mainForm.StatusText.Text = @"regions loaded"; |
|
96 | mainForm.StatusProgress.Value = 100; |
97 | mainForm.StatusProgress.Value = 100; |
|
97 | } |
98 | } |
|
98 | catch (Exception ex) |
99 | catch (Exception ex) |
|
99 | { |
100 | { |
|
100 | mainForm.StatusText.Text = ex.Message; |
101 | mainForm.StatusText.Text = ex.Message; |
|
101 | } |
102 | } |
|
102 | })); |
103 | })); |
|
103 | }) |
104 | }) |
|
104 | {IsBackground = true, Priority = ThreadPriority.Normal}.Start(); |
105 | {IsBackground = true, Priority = ThreadPriority.Normal}.Start(); |
|
105 | break; |
106 | break; |
|
106 | } |
107 | } |
|
107 | })); |
108 | })); |
|
108 | } |
109 | } |
|
109 | |
110 | |
|
110 | private void SaveRegionsRequested(object sender, EventArgs e) |
111 | private void SaveRegionsRequested(object sender, EventArgs e) |
|
111 | { |
112 | { |
|
112 | mainForm.BeginInvoke((MethodInvoker) (() => |
113 | mainForm.BeginInvoke((MethodInvoker) (() => |
|
113 | { |
114 | { |
|
114 | switch (mainForm.SaveRegionsDialog.ShowDialog()) |
115 | switch (mainForm.SaveRegionsDialog.ShowDialog()) |
|
115 | { |
116 | { |
|
116 | case DialogResult.OK: |
117 | case DialogResult.OK: |
|
117 | string file = mainForm.SaveRegionsDialog.FileName; |
118 | string file = mainForm.SaveRegionsDialog.FileName; |
|
118 | new Thread(() => |
119 | new Thread(() => |
|
119 | { |
120 | { |
|
120 | mainForm.BeginInvoke((MethodInvoker) (() => |
121 | mainForm.BeginInvoke((MethodInvoker) (() => |
|
121 | { |
122 | { |
|
122 | try |
123 | try |
|
123 | { |
124 | { |
|
124 | mainForm.StatusText.Text = @"saving regions..."; |
125 | mainForm.StatusText.Text = @"saving regions..."; |
|
125 | mainForm.StatusProgress.Value = 0; |
126 | mainForm.StatusProgress.Value = 0; |
|
126 | |
127 | |
|
127 | // Save the regions to CSV. |
128 | // Save the regions to CSV. |
|
128 | using ( |
129 | using ( |
|
129 | StreamWriter streamWriter = |
130 | StreamWriter streamWriter = |
|
130 | new StreamWriter(file, false, |
131 | new StreamWriter(file, false, |
|
131 | Encoding.UTF8)) |
132 | Encoding.UTF8)) |
|
132 | { |
133 | { |
|
133 | foreach ( |
134 | foreach ( |
|
134 | KeyValuePair<string, Vector3> region in |
135 | KeyValuePair<string, Vector3> region in |
|
135 | Regions.Items.Cast<ListViewItem>() |
136 | Regions.Items.Cast<ListViewItem>() |
|
136 | .Select(o => (KeyValuePair<string, Vector3>) o.Tag)) |
137 | .Select(o => (KeyValuePair<string, Vector3>) o.Tag)) |
|
137 | { |
138 | { |
|
138 | streamWriter.Write( |
139 | streamWriter.Write( |
|
139 | Vassal.wasEnumerableToCSV(new[] {region.Key, region.Value.ToString()})); |
140 | CSV.FromEnumerable(new[] {region.Key, region.Value.ToString()})); |
|
140 | streamWriter.Write(Environment.NewLine); |
141 | streamWriter.Write(Environment.NewLine); |
|
141 | } |
142 | } |
|
142 | } |
143 | } |
|
143 | |
144 | |
|
144 | mainForm.StatusText.Text = @"regions saved"; |
145 | mainForm.StatusText.Text = @"regions saved"; |
|
145 | mainForm.StatusProgress.Value = 100; |
146 | mainForm.StatusProgress.Value = 100; |
|
146 | } |
147 | } |
|
147 | catch (Exception ex) |
148 | catch (Exception ex) |
|
148 | { |
149 | { |
|
149 | mainForm.StatusText.Text = ex.Message; |
150 | mainForm.StatusText.Text = ex.Message; |
|
150 | } |
151 | } |
|
151 | })); |
152 | })); |
|
152 | }) |
153 | }) |
|
153 | {IsBackground = true, Priority = ThreadPriority.Normal}.Start(); |
154 | {IsBackground = true, Priority = ThreadPriority.Normal}.Start(); |
|
154 | break; |
155 | break; |
|
155 | } |
156 | } |
|
156 | })); |
157 | })); |
|
157 | } |
158 | } |
|
158 | |
159 | |
|
159 | private void RegionEditShown(object sender, EventArgs e) |
160 | private void RegionEditShown(object sender, EventArgs e) |
|
160 | { |
161 | { |
|
161 | Regions.Items.Clear(); |
162 | Regions.Items.Clear(); |
|
162 | // Get all the regions if they exist. |
163 | // Get all the regions if they exist. |
|
163 | if (File.Exists(Vassal.VASSAL_CONSTANTS.VASSAL_REGIONS)) |
164 | if (File.Exists(Vassal.VASSAL_CONSTANTS.VASSAL_REGIONS)) |
|
164 | { |
165 | { |
|
165 | Vector3 localPosition; |
166 | Vector3 localPosition; |
|
166 | List<KeyValuePair<string, Vector3>> ConfiguredRegions = new List<KeyValuePair<string, Vector3>>( |
167 | List<KeyValuePair<string, Vector3>> ConfiguredRegions = new List<KeyValuePair<string, Vector3>>( |
|
167 | File.ReadAllLines(Vassal.VASSAL_CONSTANTS.VASSAL_REGIONS) |
168 | File.ReadAllLines(Vassal.VASSAL_CONSTANTS.VASSAL_REGIONS) |
|
168 | .Select(o => new List<string>(Vassal.wasCSVToEnumerable(o))) |
169 | .Select(o => new List<string>(CSV.ToEnumerable(o))) |
|
169 | .Where(o => o.Count == 2) |
170 | .Where(o => o.Count == 2) |
|
170 | .ToDictionary(o => o.First(), |
171 | .ToDictionary(o => o.First(), |
|
171 | p => |
172 | p => |
|
172 | Vector3.TryParse(p.Last(), out localPosition) |
173 | Vector3.TryParse(p.Last(), out localPosition) |
|
173 | ? localPosition |
174 | ? localPosition |
|
174 | : Vector3.Zero).OrderBy(o => o.Key).ToDictionary(o => o.Key, o => o.Value)); |
175 | : Vector3.Zero).OrderBy(o => o.Key).ToDictionary(o => o.Key, o => o.Value)); |
|
175 | Regions.Items.AddRange( |
176 | Regions.Items.AddRange( |
|
176 | ConfiguredRegions.Select( |
177 | ConfiguredRegions.Select( |
|
177 | o => (object) new ListViewItem {Text = o.Key + @" " + @"(" + o.Value.ToString() + @")", Tag = o}) |
178 | o => (object) new ListViewItem {Text = o.Key + @" " + @"(" + o.Value.ToString() + @")", Tag = o}) |
|
178 | .ToArray()); |
179 | .ToArray()); |
|
179 | } |
180 | } |
|
180 | } |
181 | } |
|
181 | |
182 | |
|
182 | private void RequestAddRegion(object sender, EventArgs e) |
183 | private void RequestAddRegion(object sender, EventArgs e) |
|
183 | { |
184 | { |
|
184 | mainForm.BeginInvoke((MethodInvoker) (() => |
185 | mainForm.BeginInvoke((MethodInvoker) (() => |
|
185 | { |
186 | { |
|
186 | if (string.IsNullOrEmpty(RegionName.Text)) |
187 | if (string.IsNullOrEmpty(RegionName.Text)) |
|
187 | { |
188 | { |
|
188 | RegionName.BackColor = Color.MistyRose; |
189 | RegionName.BackColor = Color.MistyRose; |
|
189 | return; |
190 | return; |
|
190 | } |
191 | } |
|
191 | Vector3 position; |
192 | Vector3 position; |
|
192 | if (!Vector3.TryParse(RegionPosition.Text, out position)) |
193 | if (!Vector3.TryParse(RegionPosition.Text, out position)) |
|
193 | { |
194 | { |
|
194 | RegionPosition.BackColor = Color.MistyRose; |
195 | RegionPosition.BackColor = Color.MistyRose; |
|
195 | return; |
196 | return; |
|
196 | } |
197 | } |
|
197 | RegionName.BackColor = Color.Empty; |
198 | RegionName.BackColor = Color.Empty; |
|
198 | RegionPosition.BackColor = Color.Empty; |
199 | RegionPosition.BackColor = Color.Empty; |
|
199 | Regions.Items.Add(new ListViewItem |
200 | Regions.Items.Add(new ListViewItem |
|
200 | { |
201 | { |
|
201 | Text = RegionName.Text + @" " + @"(" + position + @")", |
202 | Text = RegionName.Text + @" " + @"(" + position + @")", |
|
202 | Tag = new KeyValuePair<string, Vector3>(RegionName.Text, position) |
203 | Tag = new KeyValuePair<string, Vector3>(RegionName.Text, position) |
|
203 | }); |
204 | }); |
|
204 | |
205 | |
|
205 | // Update drop down box. |
206 | // Update drop down box. |
|
206 | Vassal.vassalForm.BeginInvoke((MethodInvoker) (() => |
207 | Vassal.vassalForm.BeginInvoke((MethodInvoker) (() => |
|
207 | { |
208 | { |
|
208 | Vassal.vassalForm.LoadedRegionsBox.Items.Add(new ListViewItem |
209 | Vassal.vassalForm.LoadedRegionsBox.Items.Add(new ListViewItem |
|
209 | { |
210 | { |
|
210 | Text = RegionName.Text, |
211 | Text = RegionName.Text, |
|
211 | Tag = position |
212 | Tag = position |
|
212 | }); |
213 | }); |
|
213 | // Add the row to the batch restart grid view. |
214 | // Add the row to the batch restart grid view. |
|
214 | Vassal.vassalForm.BatchRestartGridView.Rows.Add(RegionName.Text, position.ToString()); |
215 | Vassal.vassalForm.BatchRestartGridView.Rows.Add(RegionName.Text, position.ToString()); |
|
215 | Vassal.vassalForm.RegionsStateGridView.Rows.Add(RegionName.Text, "Check pending...", |
216 | Vassal.vassalForm.RegionsStateGridView.Rows.Add(RegionName.Text, "Check pending...", |
|
216 | DateTime.Now.ToUniversalTime() |
217 | DateTime.Now.ToUniversalTime() |
|
217 | .ToString(Vassal.LINDEN_CONSTANTS.LSL.DATE_TIME_STAMP)); |
218 | .ToString(Vassal.LINDEN_CONSTANTS.LSL.DATE_TIME_STAMP)); |
|
218 | })); |
219 | })); |
|
219 | })); |
220 | })); |
|
220 | } |
221 | } |
|
221 | |
222 | |
|
222 | private void RequestRemoveRegion(object sender, EventArgs e) |
223 | private void RequestRemoveRegion(object sender, EventArgs e) |
|
223 | { |
224 | { |
|
224 | mainForm.BeginInvoke((MethodInvoker) (() => |
225 | mainForm.BeginInvoke((MethodInvoker) (() => |
|
225 | { |
226 | { |
|
226 | ListViewItem listViewItem = Regions.SelectedItem as ListViewItem; |
227 | ListViewItem listViewItem = Regions.SelectedItem as ListViewItem; |
|
227 | if (listViewItem == null) |
228 | if (listViewItem == null) |
|
228 | { |
229 | { |
|
229 | Regions.BackColor = Color.MistyRose; |
230 | Regions.BackColor = Color.MistyRose; |
|
230 | return; |
231 | return; |
|
231 | } |
232 | } |
|
232 | |
233 | |
|
233 | int selectedItemIndex = Regions.SelectedIndex; |
234 | int selectedItemIndex = Regions.SelectedIndex; |
|
234 | if (selectedItemIndex == -1) |
235 | if (selectedItemIndex == -1) |
|
235 | return; |
236 | return; |
|
236 | |
237 | |
|
237 | Regions.BackColor = Color.Empty; |
238 | Regions.BackColor = Color.Empty; |
|
238 | |
239 | |
|
239 | Vassal.vassalForm.BeginInvoke((MethodInvoker) (() => |
240 | Vassal.vassalForm.BeginInvoke((MethodInvoker) (() => |
|
240 | { |
241 | { |
|
241 | Vassal.vassalForm.LoadedRegionsBox.Items.RemoveAt(selectedItemIndex); |
242 | Vassal.vassalForm.LoadedRegionsBox.Items.RemoveAt(selectedItemIndex); |
|
242 | // Update the batch restart grid view. |
243 | // Update the batch restart grid view. |
|
243 | Vassal.vassalForm.BatchRestartGridView.Rows.RemoveAt(selectedItemIndex); |
244 | Vassal.vassalForm.BatchRestartGridView.Rows.RemoveAt(selectedItemIndex); |
|
244 | Vassal.vassalForm.RegionsStateGridView.Rows.RemoveAt(selectedItemIndex); |
245 | Vassal.vassalForm.RegionsStateGridView.Rows.RemoveAt(selectedItemIndex); |
|
245 | })); |
246 | })); |
|
246 | |
247 | |
|
247 | Regions.Items.RemoveAt(Regions.SelectedIndex); |
248 | Regions.Items.RemoveAt(Regions.SelectedIndex); |
|
248 | })); |
249 | })); |
|
249 | } |
250 | } |
|
250 | |
251 | |
|
251 | private void RegionSettingChanged(object sender, EventArgs e) |
252 | private void RegionSettingChanged(object sender, EventArgs e) |
|
252 | { |
253 | { |
|
253 | mainForm.BeginInvoke((MethodInvoker) (() => |
254 | mainForm.BeginInvoke((MethodInvoker) (() => |
|
254 | { |
255 | { |
|
255 | ListViewItem listViewItem = Regions.SelectedItem as ListViewItem; |
256 | ListViewItem listViewItem = Regions.SelectedItem as ListViewItem; |
|
256 | if (listViewItem == null) |
257 | if (listViewItem == null) |
|
257 | return; |
258 | return; |
|
258 | |
259 | |
|
259 | int selectedItemIndex = Regions.SelectedIndex; |
260 | int selectedItemIndex = Regions.SelectedIndex; |
|
260 | if (selectedItemIndex == -1) |
261 | if (selectedItemIndex == -1) |
|
261 | return; |
262 | return; |
|
262 | |
263 | |
|
263 | if (string.IsNullOrEmpty(RegionName.Text)) |
264 | if (string.IsNullOrEmpty(RegionName.Text)) |
|
264 | { |
265 | { |
|
265 | RegionName.BackColor = Color.MistyRose; |
266 | RegionName.BackColor = Color.MistyRose; |
|
266 | RegionPosition.BackColor = Color.MistyRose; |
267 | RegionPosition.BackColor = Color.MistyRose; |
|
267 | return; |
268 | return; |
|
268 | } |
269 | } |
|
269 | |
270 | |
|
270 | Vector3 position; |
271 | Vector3 position; |
|
271 | if (!Vector3.TryParse(RegionPosition.Text, out position)) |
272 | if (!Vector3.TryParse(RegionPosition.Text, out position)) |
|
272 | { |
273 | { |
|
273 | RegionPosition.BackColor = Color.MistyRose; |
274 | RegionPosition.BackColor = Color.MistyRose; |
|
274 | return; |
275 | return; |
|
275 | } |
276 | } |
|
276 | |
277 | |
|
277 | RegionName.BackColor = Color.Empty; |
278 | RegionName.BackColor = Color.Empty; |
|
278 | RegionPosition.BackColor = Color.Empty; |
279 | RegionPosition.BackColor = Color.Empty; |
|
279 | |
280 | |
|
280 | |
281 | |
|
281 | Vassal.vassalForm.BeginInvoke((MethodInvoker) (() => |
282 | Vassal.vassalForm.BeginInvoke((MethodInvoker) (() => |
|
282 | { |
283 | { |
|
283 | if (Vassal.vassalForm.LoadedRegionsBox.Items.Count > selectedItemIndex) |
284 | if (Vassal.vassalForm.LoadedRegionsBox.Items.Count > selectedItemIndex) |
|
284 | { |
285 | { |
|
285 | Vassal.vassalForm.LoadedRegionsBox.Items[selectedItemIndex] = new ListViewItem |
286 | Vassal.vassalForm.LoadedRegionsBox.Items[selectedItemIndex] = new ListViewItem |
|
286 | { |
287 | { |
|
287 | Text = RegionName.Text, |
288 | Text = RegionName.Text, |
|
288 | Tag = position |
289 | Tag = position |
|
289 | }; |
290 | }; |
|
290 | } |
291 | } |
|
291 | // Update the batch restart grid view. |
292 | // Update the batch restart grid view. |
|
292 | if (Vassal.vassalForm.BatchRestartGridView.Rows.Count > selectedItemIndex) |
293 | if (Vassal.vassalForm.BatchRestartGridView.Rows.Count > selectedItemIndex) |
|
293 | { |
294 | { |
|
294 | Vassal.vassalForm.BatchRestartGridView.Rows[selectedItemIndex].Cells["BatchRestartRegionName"] |
295 | Vassal.vassalForm.BatchRestartGridView.Rows[selectedItemIndex].Cells["BatchRestartRegionName"] |
|
295 | .Value |
296 | .Value |
|
296 | = RegionName.Text; |
297 | = RegionName.Text; |
|
297 | Vassal.vassalForm.BatchRestartGridView.Rows[selectedItemIndex].Cells["BatchRestartPosition"] |
298 | Vassal.vassalForm.BatchRestartGridView.Rows[selectedItemIndex].Cells["BatchRestartPosition"] |
|
298 | .Value |
299 | .Value |
|
299 | = position.ToString(); |
300 | = position.ToString(); |
|
300 | } |
301 | } |
|
301 | // Update the region state grid view. |
302 | // Update the region state grid view. |
|
302 | if (Vassal.vassalForm.RegionsStateGridView.Rows.Count > selectedItemIndex) |
303 | if (Vassal.vassalForm.RegionsStateGridView.Rows.Count > selectedItemIndex) |
|
303 | { |
304 | { |
|
304 | Vassal.vassalForm.RegionsStateGridView.Rows[selectedItemIndex].Cells["RegionsStateRegionName"] |
305 | Vassal.vassalForm.RegionsStateGridView.Rows[selectedItemIndex].Cells["RegionsStateRegionName"] |
|
305 | .Value |
306 | .Value |
|
306 | = RegionName.Text; |
307 | = RegionName.Text; |
|
307 | Vassal.vassalForm.RegionsStateGridView.Rows[selectedItemIndex].Cells["RegionsStateLastState"] |
308 | Vassal.vassalForm.RegionsStateGridView.Rows[selectedItemIndex].Cells["RegionsStateLastState"] |
|
308 | .Value |
309 | .Value |
|
309 | = "Check pending..."; |
310 | = "Check pending..."; |
|
310 | Vassal.vassalForm.RegionsStateGridView.Rows[selectedItemIndex].Cells["RegionsStateLastCheck"] |
311 | Vassal.vassalForm.RegionsStateGridView.Rows[selectedItemIndex].Cells["RegionsStateLastCheck"] |
|
311 | .Value |
312 | .Value |
|
312 | = DateTime.Now.ToUniversalTime() |
313 | = DateTime.Now.ToUniversalTime() |
|
313 | .ToString(Vassal.LINDEN_CONSTANTS.LSL.DATE_TIME_STAMP); |
314 | .ToString(Vassal.LINDEN_CONSTANTS.LSL.DATE_TIME_STAMP); |
|
314 | } |
315 | } |
|
315 | })); |
316 | })); |
|
316 | |
317 | |
|
317 | Regions.Items[selectedItemIndex] = new ListViewItem |
318 | Regions.Items[selectedItemIndex] = new ListViewItem |
|
318 | { |
319 | { |
|
319 | Text = RegionName.Text + @" " + @"(" + position + @")", |
320 | Text = RegionName.Text + @" " + @"(" + position + @")", |
|
320 | Tag = new KeyValuePair<string, Vector3>(RegionName.Text, position) |
321 | Tag = new KeyValuePair<string, Vector3>(RegionName.Text, position) |
|
321 | }; |
322 | }; |
|
322 | })); |
323 | })); |
|
323 | } |
324 | } |
|
324 | |
325 | |
|
325 | private void RegionSelected(object sender, EventArgs e) |
326 | private void RegionSelected(object sender, EventArgs e) |
|
326 | { |
327 | { |
|
327 | mainForm.BeginInvoke((MethodInvoker) (() => |
328 | mainForm.BeginInvoke((MethodInvoker) (() => |
|
328 | { |
329 | { |
|
329 | ListViewItem listViewItem = Regions.SelectedItem as ListViewItem; |
330 | ListViewItem listViewItem = Regions.SelectedItem as ListViewItem; |
|
330 | if (listViewItem == null) |
331 | if (listViewItem == null) |
|
331 | return; |
332 | return; |
|
332 | |
333 | |
|
333 | int selectedItemIndex = Regions.SelectedIndex; |
334 | int selectedItemIndex = Regions.SelectedIndex; |
|
334 | if (selectedItemIndex == -1) |
335 | if (selectedItemIndex == -1) |
|
335 | return; |
336 | return; |
|
336 | |
337 | |
|
337 | KeyValuePair<string, Vector3> region = (KeyValuePair<string, Vector3>) listViewItem.Tag; |
338 | KeyValuePair<string, Vector3> region = (KeyValuePair<string, Vector3>) listViewItem.Tag; |
|
338 | RegionName.Text = region.Key; |
339 | RegionName.Text = region.Key; |
|
339 | RegionPosition.Text = region.Value.ToString(); |
340 | RegionPosition.Text = region.Value.ToString(); |
|
340 | })); |
341 | })); |
|
341 | } |
342 | } |
|
342 | } |
343 | } |
|
343 | } |
344 | } |
|
344 | |
345 | |
|
345 |
|
346 |
|
|
346 | |
347 | |
|
347 | |
348 | |
|
348 | |
349 | |