/Vassal/Vassal/RegionEditForm.cs |
@@ -1,13 +1,16 @@ |
using System; |
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 // |
// Please see: http://www.gnu.org/licenses/gpl.html for legal details, // |
// rights of fair usage, the disclaimer and warranty conditions. // |
/////////////////////////////////////////////////////////////////////////// |
|
using System; |
using System.Collections.Generic; |
using System.ComponentModel; |
using System.Data; |
using System.Drawing; |
using System.IO; |
using System.Linq; |
using System.Text; |
using System.Threading; |
using System.Threading.Tasks; |
using System.Windows.Forms; |
using OpenMetaverse; |
|
@@ -25,7 +28,7 @@ |
|
private void LoadRegionsRequested(object sender, EventArgs e) |
{ |
mainForm.BeginInvoke((MethodInvoker)(() => |
mainForm.BeginInvoke((MethodInvoker) (() => |
{ |
switch (mainForm.LoadRegionsDialog.ShowDialog()) |
{ |
@@ -33,7 +36,7 @@ |
string file = mainForm.LoadRegionsDialog.FileName; |
new Thread(() => |
{ |
mainForm.BeginInvoke((MethodInvoker)(() => |
mainForm.BeginInvoke((MethodInvoker) (() => |
{ |
try |
{ |
@@ -42,7 +45,8 @@ |
|
// import CSV regions |
Vector3 localPosition; |
List<KeyValuePair<string, Vector3>> ConfiguredRegions = new List<KeyValuePair<string, Vector3>>( |
List<KeyValuePair<string, Vector3>> ConfiguredRegions = new List |
<KeyValuePair<string, Vector3>>( |
File.ReadAllLines(file) |
.AsParallel() |
.Select(o => new List<string>(Vassal.wasCSVToEnumerable(o))) |
@@ -55,8 +59,8 @@ |
|
Vassal.vassalForm.BeginInvoke((MethodInvoker) (() => |
{ |
Vassal.vassalForm.LoadedRegions.Items.Clear(); |
Vassal.vassalForm.LoadedRegions.Items.AddRange( |
Vassal.vassalForm.LoadedRegionsBox.Items.Clear(); |
Vassal.vassalForm.LoadedRegionsBox.Items.AddRange( |
ConfiguredRegions.Select( |
o => (object) new ListViewItem {Text = o.Key, Tag = o.Value}) |
.ToArray()); |
@@ -78,7 +82,14 @@ |
|
Regions.Items.Clear(); |
Regions.Items.AddRange( |
ConfiguredRegions.Select(o => (object)new ListViewItem { Text = o.Key + @" " + @"(" + o.Value.ToString() + @")", Tag = o }) |
ConfiguredRegions.Select( |
o => |
(object) |
new ListViewItem |
{ |
Text = o.Key + @" " + @"(" + o.Value.ToString() + @")", |
Tag = o |
}) |
.ToArray()); |
|
mainForm.StatusText.Text = @"regions loaded"; |
@@ -90,7 +101,7 @@ |
} |
})); |
}) |
{ IsBackground = true, Priority = ThreadPriority.Normal }.Start(); |
{IsBackground = true, Priority = ThreadPriority.Normal}.Start(); |
break; |
} |
})); |
@@ -98,7 +109,7 @@ |
|
private void SaveRegionsRequested(object sender, EventArgs e) |
{ |
mainForm.BeginInvoke((MethodInvoker)(() => |
mainForm.BeginInvoke((MethodInvoker) (() => |
{ |
switch (mainForm.SaveRegionsDialog.ShowDialog()) |
{ |
@@ -106,7 +117,7 @@ |
string file = mainForm.SaveRegionsDialog.FileName; |
new Thread(() => |
{ |
mainForm.BeginInvoke((MethodInvoker)(() => |
mainForm.BeginInvoke((MethodInvoker) (() => |
{ |
try |
{ |
@@ -139,13 +150,12 @@ |
} |
})); |
}) |
{ IsBackground = true, Priority = ThreadPriority.Normal }.Start(); |
{IsBackground = true, Priority = ThreadPriority.Normal}.Start(); |
break; |
} |
})); |
} |
|
|
private void RegionEditShown(object sender, EventArgs e) |
{ |
Regions.Items.Clear(); |
@@ -171,7 +181,7 @@ |
|
private void RequestAddRegion(object sender, EventArgs e) |
{ |
mainForm.BeginInvoke((MethodInvoker)(() => |
mainForm.BeginInvoke((MethodInvoker) (() => |
{ |
if (string.IsNullOrEmpty(RegionName.Text)) |
{ |
@@ -195,7 +205,7 @@ |
// Update drop down box. |
Vassal.vassalForm.BeginInvoke((MethodInvoker) (() => |
{ |
Vassal.vassalForm.LoadedRegions.Items.Add(new ListViewItem |
Vassal.vassalForm.LoadedRegionsBox.Items.Add(new ListViewItem |
{ |
Text = RegionName.Text, |
Tag = position |
@@ -211,7 +221,7 @@ |
|
private void RequestRemoveRegion(object sender, EventArgs e) |
{ |
mainForm.BeginInvoke((MethodInvoker)(() => |
mainForm.BeginInvoke((MethodInvoker) (() => |
{ |
ListViewItem listViewItem = Regions.SelectedItem as ListViewItem; |
if (listViewItem == null) |
@@ -225,10 +235,10 @@ |
return; |
|
Regions.BackColor = Color.Empty; |
|
Vassal.vassalForm.BeginInvoke((MethodInvoker)(() => |
|
Vassal.vassalForm.BeginInvoke((MethodInvoker) (() => |
{ |
Vassal.vassalForm.LoadedRegions.Items.RemoveAt(selectedItemIndex); |
Vassal.vassalForm.LoadedRegionsBox.Items.RemoveAt(selectedItemIndex); |
// Update the batch restart grid view. |
Vassal.vassalForm.BatchRestartGridView.Rows.RemoveAt(selectedItemIndex); |
Vassal.vassalForm.RegionsStateGridView.Rows.RemoveAt(selectedItemIndex); |
@@ -235,13 +245,12 @@ |
})); |
|
Regions.Items.RemoveAt(Regions.SelectedIndex); |
|
})); |
} |
|
private void RegionSettingChanged(object sender, EventArgs e) |
{ |
mainForm.BeginInvoke((MethodInvoker)(() => |
mainForm.BeginInvoke((MethodInvoker) (() => |
{ |
ListViewItem listViewItem = Regions.SelectedItem as ListViewItem; |
if (listViewItem == null) |
@@ -267,13 +276,13 @@ |
|
RegionName.BackColor = Color.Empty; |
RegionPosition.BackColor = Color.Empty; |
|
|
Vassal.vassalForm.BeginInvoke((MethodInvoker)(() => |
|
Vassal.vassalForm.BeginInvoke((MethodInvoker) (() => |
{ |
if (Vassal.vassalForm.LoadedRegions.Items.Count > selectedItemIndex) |
if (Vassal.vassalForm.LoadedRegionsBox.Items.Count > selectedItemIndex) |
{ |
Vassal.vassalForm.LoadedRegions.Items[selectedItemIndex] = new ListViewItem |
Vassal.vassalForm.LoadedRegionsBox.Items[selectedItemIndex] = new ListViewItem |
{ |
Text = RegionName.Text, |
Tag = position |
@@ -310,13 +319,12 @@ |
Text = RegionName.Text + @" " + @"(" + position + @")", |
Tag = new KeyValuePair<string, Vector3>(RegionName.Text, position) |
}; |
|
})); |
} |
|
private void RegionSelected(object sender, EventArgs e) |
{ |
mainForm.BeginInvoke((MethodInvoker)(() => |
mainForm.BeginInvoke((MethodInvoker) (() => |
{ |
ListViewItem listViewItem = Regions.SelectedItem as ListViewItem; |
if (listViewItem == null) |
@@ -332,4 +340,4 @@ |
})); |
} |
} |
} |
} |