corrade-vassal
/Vassal/Vassal/SettingsForm.cs |
@@ -1,4 +1,10 @@ |
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; |
@@ -5,6 +11,8 @@ |
using System.Drawing; |
using System.IO; |
using System.Linq; |
using System.Net.Sockets; |
using System.Reflection; |
using System.Text; |
using System.Threading; |
using System.Threading.Tasks; |
@@ -421,6 +429,39 @@ |
} |
})); |
})); |
// Spawn a thread to check Corrade's connection status. |
new Thread(() => |
{ |
TcpClient tcpClient = new TcpClient(); |
try |
{ |
System.Uri uri = new System.Uri(Vassal.vassalConfiguration.HTTPServerURL); |
tcpClient.Connect(uri.Host, uri.Port); |
// port open |
Vassal.vassalForm.BeginInvoke((MethodInvoker)(() => { Vassal.vassalForm.Tabs.Enabled = true; })); |
// set the loading spinner |
Assembly thisAssembly = System.Reflection.Assembly.GetExecutingAssembly(); |
System.IO.Stream file = |
thisAssembly.GetManifestResourceStream("Vassal.img.loading.gif"); |
switch (file != null) |
{ |
case true: |
Vassal.vassalForm.BeginInvoke((MethodInvoker)(() => |
{ |
Vassal.vassalForm.RegionAvatarsMap.SizeMode = PictureBoxSizeMode.CenterImage; |
Vassal.vassalForm.RegionAvatarsMap.Image = Image.FromStream(file); |
Vassal.vassalForm.RegionAvatarsMap.Refresh(); |
})); |
break; |
} |
} |
catch (Exception) |
{ |
// port closed |
Vassal.vassalForm.BeginInvoke((MethodInvoker)(() => { Vassal.vassalForm.Tabs.Enabled = false; })); |
} |
}) |
{ IsBackground = true }.Start(); |
} |
} |
} |