/Vassal/Vassal/RegionEditForm.cs |
@@ -34,7 +34,7 @@ |
switch (mainForm.LoadRegionsDialog.ShowDialog()) |
{ |
case DialogResult.OK: |
string file = mainForm.LoadRegionsDialog.FileName; |
var file = mainForm.LoadRegionsDialog.FileName; |
new Thread(() => |
{ |
mainForm.BeginInvoke((MethodInvoker) (() => |
@@ -46,7 +46,7 @@ |
|
// import CSV regions |
Vector3 localPosition; |
List<KeyValuePair<string, Vector3>> ConfiguredRegions = new List |
var ConfiguredRegions = new List |
<KeyValuePair<string, Vector3>>( |
File.ReadAllLines(file) |
.AsParallel() |
@@ -67,13 +67,13 @@ |
.ToArray()); |
// Update batch restart grid view. |
Vassal.vassalForm.BatchRestartGridView.Rows.Clear(); |
foreach (KeyValuePair<string, Vector3> data in ConfiguredRegions) |
foreach (var data in ConfiguredRegions) |
{ |
Vassal.vassalForm.BatchRestartGridView.Rows.Add(data.Key, data.Value); |
} |
// Update region state grid view. |
Vassal.vassalForm.RegionsStateGridView.Rows.Clear(); |
foreach (KeyValuePair<string, Vector3> data in ConfiguredRegions) |
foreach (var data in ConfiguredRegions) |
{ |
Vassal.vassalForm.RegionsStateGridView.Rows.Add(data.Key, "Check pending...", |
DateTime.Now.ToUniversalTime() |
@@ -115,7 +115,7 @@ |
switch (mainForm.SaveRegionsDialog.ShowDialog()) |
{ |
case DialogResult.OK: |
string file = mainForm.SaveRegionsDialog.FileName; |
var file = mainForm.SaveRegionsDialog.FileName; |
new Thread(() => |
{ |
mainForm.BeginInvoke((MethodInvoker) (() => |
@@ -127,12 +127,12 @@ |
|
// Save the regions to CSV. |
using ( |
StreamWriter streamWriter = |
var streamWriter = |
new StreamWriter(file, false, |
Encoding.UTF8)) |
{ |
foreach ( |
KeyValuePair<string, Vector3> region in |
var region in |
Regions.Items.Cast<ListViewItem>() |
.Select(o => (KeyValuePair<string, Vector3>) o.Tag)) |
{ |
@@ -164,7 +164,7 @@ |
if (File.Exists(Vassal.VASSAL_CONSTANTS.VASSAL_REGIONS)) |
{ |
Vector3 localPosition; |
List<KeyValuePair<string, Vector3>> ConfiguredRegions = new List<KeyValuePair<string, Vector3>>( |
var ConfiguredRegions = new List<KeyValuePair<string, Vector3>>( |
File.ReadAllLines(Vassal.VASSAL_CONSTANTS.VASSAL_REGIONS) |
.Select(o => new List<string>(CSV.ToEnumerable(o))) |
.Where(o => o.Count == 2) |
@@ -224,7 +224,7 @@ |
{ |
mainForm.BeginInvoke((MethodInvoker) (() => |
{ |
ListViewItem listViewItem = Regions.SelectedItem as ListViewItem; |
var listViewItem = Regions.SelectedItem as ListViewItem; |
if (listViewItem == null) |
{ |
Regions.BackColor = Color.MistyRose; |
@@ -231,7 +231,7 @@ |
return; |
} |
|
int selectedItemIndex = Regions.SelectedIndex; |
var selectedItemIndex = Regions.SelectedIndex; |
if (selectedItemIndex == -1) |
return; |
|
@@ -253,11 +253,11 @@ |
{ |
mainForm.BeginInvoke((MethodInvoker) (() => |
{ |
ListViewItem listViewItem = Regions.SelectedItem as ListViewItem; |
var listViewItem = Regions.SelectedItem as ListViewItem; |
if (listViewItem == null) |
return; |
|
int selectedItemIndex = Regions.SelectedIndex; |
var selectedItemIndex = Regions.SelectedIndex; |
if (selectedItemIndex == -1) |
return; |
|
@@ -327,18 +327,31 @@ |
{ |
mainForm.BeginInvoke((MethodInvoker) (() => |
{ |
ListViewItem listViewItem = Regions.SelectedItem as ListViewItem; |
var listViewItem = Regions.SelectedItem as ListViewItem; |
if (listViewItem == null) |
return; |
|
int selectedItemIndex = Regions.SelectedIndex; |
var selectedItemIndex = Regions.SelectedIndex; |
if (selectedItemIndex == -1) |
return; |
|
KeyValuePair<string, Vector3> region = (KeyValuePair<string, Vector3>) listViewItem.Tag; |
var region = (KeyValuePair<string, Vector3>) listViewItem.Tag; |
RegionName.Text = region.Key; |
RegionPosition.Text = region.Value.ToString(); |
})); |
} |
|
private void ShowToolTip(object sender, EventArgs e) |
{ |
mainForm.BeginInvoke( |
(Action) (() => |
{ |
var pictureBox = sender as PictureBox; |
if (pictureBox != null) |
{ |
toolTip1.Show(toolTip1.GetToolTip(pictureBox), pictureBox); |
} |
})); |
} |
} |
} |