corrade-vassal – Diff between revs 13 and 16

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 13 Rev 16
Line 32... Line 32...
32 mainForm.BeginInvoke((MethodInvoker) (() => 32 mainForm.BeginInvoke((MethodInvoker) (() =>
33 { 33 {
34 switch (mainForm.LoadRegionsDialog.ShowDialog()) 34 switch (mainForm.LoadRegionsDialog.ShowDialog())
35 { 35 {
36 case DialogResult.OK: 36 case DialogResult.OK:
37 string file = mainForm.LoadRegionsDialog.FileName; 37 var file = mainForm.LoadRegionsDialog.FileName;
38 new Thread(() => 38 new Thread(() =>
39 { 39 {
40 mainForm.BeginInvoke((MethodInvoker) (() => 40 mainForm.BeginInvoke((MethodInvoker) (() =>
41 { 41 {
42 try 42 try
Line 44... Line 44...
44 mainForm.StatusText.Text = @"loading regions..."; 44 mainForm.StatusText.Text = @"loading regions...";
45 mainForm.StatusProgress.Value = 0; 45 mainForm.StatusProgress.Value = 0;
Line 46... Line 46...
46   46  
47 // import CSV regions 47 // import CSV regions
48 Vector3 localPosition; 48 Vector3 localPosition;
49 List<KeyValuePair<string, Vector3>> ConfiguredRegions = new List 49 var ConfiguredRegions = new List
50 <KeyValuePair<string, Vector3>>( 50 <KeyValuePair<string, Vector3>>(
51 File.ReadAllLines(file) 51 File.ReadAllLines(file)
52 .AsParallel() 52 .AsParallel()
53 .Select(o => new List<string>(CSV.ToEnumerable(o))) 53 .Select(o => new List<string>(CSV.ToEnumerable(o)))
Line 65... Line 65...
65 ConfiguredRegions.Select( 65 ConfiguredRegions.Select(
66 o => (object) new ListViewItem {Text = o.Key, Tag = o.Value}) 66 o => (object) new ListViewItem {Text = o.Key, Tag = o.Value})
67 .ToArray()); 67 .ToArray());
68 // Update batch restart grid view. 68 // Update batch restart grid view.
69 Vassal.vassalForm.BatchRestartGridView.Rows.Clear(); 69 Vassal.vassalForm.BatchRestartGridView.Rows.Clear();
70 foreach (KeyValuePair<string, Vector3> data in ConfiguredRegions) 70 foreach (var data in ConfiguredRegions)
71 { 71 {
72 Vassal.vassalForm.BatchRestartGridView.Rows.Add(data.Key, data.Value); 72 Vassal.vassalForm.BatchRestartGridView.Rows.Add(data.Key, data.Value);
73 } 73 }
74 // Update region state grid view. 74 // Update region state grid view.
75 Vassal.vassalForm.RegionsStateGridView.Rows.Clear(); 75 Vassal.vassalForm.RegionsStateGridView.Rows.Clear();
76 foreach (KeyValuePair<string, Vector3> data in ConfiguredRegions) 76 foreach (var data in ConfiguredRegions)
77 { 77 {
78 Vassal.vassalForm.RegionsStateGridView.Rows.Add(data.Key, "Check pending...", 78 Vassal.vassalForm.RegionsStateGridView.Rows.Add(data.Key, "Check pending...",
79 DateTime.Now.ToUniversalTime() 79 DateTime.Now.ToUniversalTime()
80 .ToString(Vassal.LINDEN_CONSTANTS.LSL.DATE_TIME_STAMP)); 80 .ToString(Vassal.LINDEN_CONSTANTS.LSL.DATE_TIME_STAMP));
81 } 81 }
Line 113... Line 113...
113 mainForm.BeginInvoke((MethodInvoker) (() => 113 mainForm.BeginInvoke((MethodInvoker) (() =>
114 { 114 {
115 switch (mainForm.SaveRegionsDialog.ShowDialog()) 115 switch (mainForm.SaveRegionsDialog.ShowDialog())
116 { 116 {
117 case DialogResult.OK: 117 case DialogResult.OK:
118 string file = mainForm.SaveRegionsDialog.FileName; 118 var file = mainForm.SaveRegionsDialog.FileName;
119 new Thread(() => 119 new Thread(() =>
120 { 120 {
121 mainForm.BeginInvoke((MethodInvoker) (() => 121 mainForm.BeginInvoke((MethodInvoker) (() =>
122 { 122 {
123 try 123 try
Line 125... Line 125...
125 mainForm.StatusText.Text = @"saving regions..."; 125 mainForm.StatusText.Text = @"saving regions...";
126 mainForm.StatusProgress.Value = 0; 126 mainForm.StatusProgress.Value = 0;
Line 127... Line 127...
127   127  
128 // Save the regions to CSV. 128 // Save the regions to CSV.
129 using ( 129 using (
130 StreamWriter streamWriter = 130 var streamWriter =
131 new StreamWriter(file, false, 131 new StreamWriter(file, false,
132 Encoding.UTF8)) 132 Encoding.UTF8))
133 { 133 {
134 foreach ( 134 foreach (
135 KeyValuePair<string, Vector3> region in 135 var region in
136 Regions.Items.Cast<ListViewItem>() 136 Regions.Items.Cast<ListViewItem>()
137 .Select(o => (KeyValuePair<string, Vector3>) o.Tag)) 137 .Select(o => (KeyValuePair<string, Vector3>) o.Tag))
138 { 138 {
139 streamWriter.Write( 139 streamWriter.Write(
Line 162... Line 162...
162 Regions.Items.Clear(); 162 Regions.Items.Clear();
163 // Get all the regions if they exist. 163 // Get all the regions if they exist.
164 if (File.Exists(Vassal.VASSAL_CONSTANTS.VASSAL_REGIONS)) 164 if (File.Exists(Vassal.VASSAL_CONSTANTS.VASSAL_REGIONS))
165 { 165 {
166 Vector3 localPosition; 166 Vector3 localPosition;
167 List<KeyValuePair<string, Vector3>> ConfiguredRegions = new List<KeyValuePair<string, Vector3>>( 167 var ConfiguredRegions = new List<KeyValuePair<string, Vector3>>(
168 File.ReadAllLines(Vassal.VASSAL_CONSTANTS.VASSAL_REGIONS) 168 File.ReadAllLines(Vassal.VASSAL_CONSTANTS.VASSAL_REGIONS)
169 .Select(o => new List<string>(CSV.ToEnumerable(o))) 169 .Select(o => new List<string>(CSV.ToEnumerable(o)))
170 .Where(o => o.Count == 2) 170 .Where(o => o.Count == 2)
171 .ToDictionary(o => o.First(), 171 .ToDictionary(o => o.First(),
172 p => 172 p =>
Line 222... Line 222...
222   222  
223 private void RequestRemoveRegion(object sender, EventArgs e) 223 private void RequestRemoveRegion(object sender, EventArgs e)
224 { 224 {
225 mainForm.BeginInvoke((MethodInvoker) (() => 225 mainForm.BeginInvoke((MethodInvoker) (() =>
226 { 226 {
227 ListViewItem listViewItem = Regions.SelectedItem as ListViewItem; 227 var listViewItem = Regions.SelectedItem as ListViewItem;
228 if (listViewItem == null) 228 if (listViewItem == null)
229 { 229 {
230 Regions.BackColor = Color.MistyRose; 230 Regions.BackColor = Color.MistyRose;
231 return; 231 return;
Line 232... Line 232...
232 } 232 }
233   233  
234 int selectedItemIndex = Regions.SelectedIndex; 234 var selectedItemIndex = Regions.SelectedIndex;
Line 235... Line 235...
235 if (selectedItemIndex == -1) 235 if (selectedItemIndex == -1)
Line 251... Line 251...
251   251  
252 private void RegionSettingChanged(object sender, EventArgs e) 252 private void RegionSettingChanged(object sender, EventArgs e)
253 { 253 {
254 mainForm.BeginInvoke((MethodInvoker) (() => 254 mainForm.BeginInvoke((MethodInvoker) (() =>
255 { 255 {
256 ListViewItem listViewItem = Regions.SelectedItem as ListViewItem; 256 var listViewItem = Regions.SelectedItem as ListViewItem;
257 if (listViewItem == null) 257 if (listViewItem == null)
Line 258... Line 258...
258 return; 258 return;
259   259  
260 int selectedItemIndex = Regions.SelectedIndex; 260 var selectedItemIndex = Regions.SelectedIndex;
Line 261... Line 261...
261 if (selectedItemIndex == -1) 261 if (selectedItemIndex == -1)
262 return; 262 return;
Line 325... Line 325...
325   325  
326 private void RegionSelected(object sender, EventArgs e) 326 private void RegionSelected(object sender, EventArgs e)
327 { 327 {
328 mainForm.BeginInvoke((MethodInvoker) (() => 328 mainForm.BeginInvoke((MethodInvoker) (() =>
329 { 329 {
330 ListViewItem listViewItem = Regions.SelectedItem as ListViewItem; 330 var listViewItem = Regions.SelectedItem as ListViewItem;
331 if (listViewItem == null) 331 if (listViewItem == null)
Line 332... Line 332...
332 return; 332 return;
333   333  
334 int selectedItemIndex = Regions.SelectedIndex; 334 var selectedItemIndex = Regions.SelectedIndex;
Line 335... Line 335...
335 if (selectedItemIndex == -1) 335 if (selectedItemIndex == -1)
336 return; 336 return;
337   337  
338 KeyValuePair<string, Vector3> region = (KeyValuePair<string, Vector3>) listViewItem.Tag; 338 var region = (KeyValuePair<string, Vector3>) listViewItem.Tag;
339 RegionName.Text = region.Key; 339 RegionName.Text = region.Key;
-   340 RegionPosition.Text = region.Value.ToString();
-   341 }));
-   342 }
-   343  
-   344 private void ShowToolTip(object sender, EventArgs e)
-   345 {
-   346 mainForm.BeginInvoke(
-   347 (Action) (() =>
-   348 {
-   349 var pictureBox = sender as PictureBox;
-   350 if (pictureBox != null)
-   351 {
-   352 toolTip1.Show(toolTip1.GetToolTip(pictureBox), pictureBox);
340 RegionPosition.Text = region.Value.ToString(); 353 }
341 })); 354 }));
342 } 355 }