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