# HG changeset patch
# User StephaneLenclud
# Date 1423508790 -3600
# Node ID 606c2239804525294992a5a5e08aa5fa436bbbf4
# Parent 9e48cc704a69fc107ef36b5bdf60a9151c6470b0
MDM166AA: Now showing local network connection and internet connection status.
Also having a cheap network signal animation.
diff -r 9e48cc704a69 -r 606c22398045 Server/Display.cs
--- a/Server/Display.cs Mon Feb 09 18:25:14 2015 +0100
+++ b/Server/Display.cs Mon Feb 09 20:06:30 2015 +0100
@@ -218,6 +218,17 @@
MiniDisplaySetIconStatus(iDevice, aIcon, aIndex, aStatus);
}
+ public void SetIconOn(TMiniDisplayIconType aIcon, int aIndex)
+ {
+ MiniDisplaySetIconStatus(iDevice, aIcon, aIndex, IconStatusCount(aIcon) - 1);
+ }
+
+ public void SetIconOff(TMiniDisplayIconType aIcon, int aIndex)
+ {
+ MiniDisplaySetIconStatus(iDevice, aIcon, aIndex, 0);
+ }
+
+
public void SetAllIconsStatus(int aStatus)
{
foreach (TMiniDisplayIconType icon in Enum.GetValues(typeof(TMiniDisplayIconType)))
@@ -353,7 +364,8 @@
///
public enum TMiniDisplayIconType
{
- EMiniDisplayIconNetwork=0,
+ EMiniDisplayIconNetworkSignal=0,
+ EMiniDisplayIconInternet,
EMiniDisplayIconEmail,
EMiniDisplayIconMute,
EMiniDisplayIconVolume,
diff -r 9e48cc704a69 -r 606c22398045 Server/MainForm.cs
--- a/Server/MainForm.cs Mon Feb 09 18:25:14 2015 +0100
+++ b/Server/MainForm.cs Mon Feb 09 20:06:30 2015 +0100
@@ -226,11 +226,44 @@
{
if (iDisplay.IsOpen())
{
- iDisplay.SetIconOnOff(Display.TMiniDisplayIconType.EMiniDisplayIconNetwork, iNetworkManager.NetworkListManager.IsConnectedToInternet);
+ iDisplay.SetIconOnOff(Display.TMiniDisplayIconType.EMiniDisplayIconInternet, iNetworkManager.NetworkListManager.IsConnectedToInternet);
+ iDisplay.SetIconOnOff(Display.TMiniDisplayIconType.EMiniDisplayIconNetworkSignal, iNetworkManager.NetworkListManager.IsConnected);
}
}
+ int iLastNetworkIconIndex = 0;
+ int iUpdateCountSinceLastNetworkAnimation = 0;
+
+ ///
+ ///
+ ///
+ private void UpdateNetworkSignal(DateTime aLastTickTime, DateTime aNewTickTime)
+ {
+ iUpdateCountSinceLastNetworkAnimation++;
+ iUpdateCountSinceLastNetworkAnimation = iUpdateCountSinceLastNetworkAnimation % 4;
+
+ if (iDisplay.IsOpen() && iNetworkManager.NetworkListManager.IsConnected && iUpdateCountSinceLastNetworkAnimation==0)
+ {
+ int iconCount=iDisplay.IconCount(Display.TMiniDisplayIconType.EMiniDisplayIconNetworkSignal);
+ iLastNetworkIconIndex++;
+ iLastNetworkIconIndex = iLastNetworkIconIndex % (iconCount+1);
+ for (int i=0;i
/// Receive volume change notification and reflect changes on our slider.
///
@@ -730,6 +763,8 @@
//Update our animations
DateTime NewTickTime = DateTime.Now;
+ UpdateNetworkSignal(LastTickTime, NewTickTime);
+
//Update animation for all our marquees
foreach (Control ctrl in tableLayoutPanel.Controls)
{
diff -r 9e48cc704a69 -r 606c22398045 Server/MiniDisplay.dll
Binary file Server/MiniDisplay.dll has changed
diff -r 9e48cc704a69 -r 606c22398045 Server/NetworkManager.cs
--- a/Server/NetworkManager.cs Mon Feb 09 18:25:14 2015 +0100
+++ b/Server/NetworkManager.cs Mon Feb 09 20:06:30 2015 +0100
@@ -62,70 +62,5 @@
Debug.WriteLine("Un-subscribing to INetworkListManagerEvents");
iConnectionPoint.Unadvise(iCookie);
}
-
- ///
- /// Indicates whether any network connection is available
- /// Filter connections below a specified speed, as well as virtual network cards.
- ///
- ///
- /// true if a network connection is available; otherwise, false.
- ///
- public static bool IsAvailable()
- {
- return IsAvailable(0);
- }
-
- ///
- /// Indicates whether any network connection is available.
- /// Filter connections below a specified speed, as well as virtual network cards.
- ///
- /// The minimum speed required. Passing 0 will not filter connection using speed.
- ///
- /// true if a network connection is available; otherwise, false.
- ///
- public static bool IsAvailable(long minimumSpeed)
- {
- if (!NetworkInterface.GetIsNetworkAvailable())
- return false;
-
- foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
- {
- // discard because of standard reasons
- if ((ni.OperationalStatus != OperationalStatus.Up) ||
- (ni.NetworkInterfaceType == NetworkInterfaceType.Loopback) ||
- (ni.NetworkInterfaceType == NetworkInterfaceType.Tunnel))
- continue;
-
- // this allow to filter modems, serial, etc.
- // I use 10000000 as a minimum speed for most cases
- if (ni.Speed < minimumSpeed)
- continue;
-
- // discard virtual cards (virtual box, virtual pc, etc.)
- if ((ni.Description.IndexOf("virtual", StringComparison.OrdinalIgnoreCase) >= 0) ||
- (ni.Name.IndexOf("virtual", StringComparison.OrdinalIgnoreCase) >= 0))
- continue;
-
- // discard "Microsoft Loopback Adapter", it will not show as NetworkInterfaceType.Loopback but as Ethernet Card.
- if (ni.Description.Equals("Microsoft Loopback Adapter", StringComparison.OrdinalIgnoreCase))
- continue;
-
- return true;
- }
- return false;
- }
-
- ///
- ///
- ///
- ///
- public static bool HasInternet()
- {
- return false;
- //ConnectionProfile connections = NetworkInformation.GetInternetConnectionProfile();
- //bool internet = connections != null && connections.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess;
- //return internet;
- }
-
}
}