aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-10-16 03:37:30 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-10-16 03:37:30 +0300
commite02200b716c3c83bdd95e202c0d1bcae56882037 (patch)
treec940bc0d50ee90c9b5f17a501534829bc618c4b0 /Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity
parent3dad2354fa07e71210bb0308406558ae3b96b54c (diff)
downloadTango-e02200b716c3c83bdd95e202c0d1bcae56882037.tar.gz
Tango-e02200b716c3c83bdd95e202c0d1bcae56882037.zip
Implemented PPC LAN connectivity indicator.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs44
1 files changed, 43 insertions, 1 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs
index 53e143def..d35e7e184 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs
@@ -4,6 +4,7 @@ using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Net;
+using System.Net.NetworkInformation;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -29,7 +30,9 @@ namespace Tango.PPC.UI.Connectivity
private IMachineProvider _machineProvider;
private Rfc2898Cryptographer _cryptographer;
private System.Timers.Timer _updateTimer;
+ private System.Timers.Timer _lanUpdateTimer;
private WiFiNetwork _connectedNetwork;
+ private PPCSettings _settings;
/// <summary>
/// Occurs when the connectivity provider state has changed (e.g network connected/disconnected).
@@ -43,7 +46,17 @@ namespace Tango.PPC.UI.Connectivity
public bool IsConnected
{
get { return _isConnected; }
- set { _isConnected = value; RaisePropertyChangedAuto(); }
+ private set { _isConnected = value; RaisePropertyChangedAuto(); }
+ }
+
+ private bool _isLanConnected;
+ /// <summary>
+ /// Gets a value indicating whether there is LAN connection.
+ /// </summary>
+ public bool IsLanConnected
+ {
+ get { return _isLanConnected; }
+ private set { _isLanConnected = value; RaisePropertyChangedAuto(); }
}
private bool _isHotspoActive;
@@ -116,6 +129,8 @@ namespace Tango.PPC.UI.Connectivity
{
await RefreshAvailableWiFiNetworks();
});
+
+ _settings = SettingsManager.Default.GetOrCreate<PPCSettings>();
}
/// <summary>
@@ -153,6 +168,28 @@ namespace Tango.PPC.UI.Connectivity
_updateTimer = new System.Timers.Timer(TimeSpan.FromSeconds(30).TotalMilliseconds);
_updateTimer.Elapsed += _updateTimer_Elapsed;
_updateTimer.Start();
+
+ _lanUpdateTimer = new System.Timers.Timer(TimeSpan.FromSeconds(10).TotalMilliseconds);
+ _lanUpdateTimer.Elapsed += _lanUpdateTimer_Elapsed;
+ _lanUpdateTimer.Start();
+ }
+
+ private void _lanUpdateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
+ {
+ foreach (NetworkInterface net in NetworkInterface.GetAllNetworkInterfaces())
+ {
+ if ((net.NetworkInterfaceType == NetworkInterfaceType.Ethernet
+ || net.NetworkInterfaceType == NetworkInterfaceType.Ethernet3Megabit
+ || net.NetworkInterfaceType == NetworkInterfaceType.FastEthernetFx
+ || net.NetworkInterfaceType == NetworkInterfaceType.FastEthernetT
+ || net.NetworkInterfaceType == NetworkInterfaceType.GigabitEthernet) && net.OperationalStatus == OperationalStatus.Up)
+ {
+ IsLanConnected = true;
+ return;
+ }
+ }
+
+ IsLanConnected = false;
}
/// <summary>
@@ -223,6 +260,11 @@ namespace Tango.PPC.UI.Connectivity
/// <returns></returns>
public Task<bool> CheckInternetConnection()
{
+ if (_settings.BypassInternetConnectivityCheck)
+ {
+ return Task.FromResult(true);
+ }
+
return Task.Factory.StartNew<bool>(() =>
{
try