MDM166AA: Now showing local network connection and internet connection status.
Also having a cheap network signal animation.
1.1 --- a/Server/Display.cs Mon Feb 09 18:25:14 2015 +0100
1.2 +++ b/Server/Display.cs Mon Feb 09 20:06:30 2015 +0100
1.3 @@ -218,6 +218,17 @@
1.4 MiniDisplaySetIconStatus(iDevice, aIcon, aIndex, aStatus);
1.5 }
1.6
1.7 + public void SetIconOn(TMiniDisplayIconType aIcon, int aIndex)
1.8 + {
1.9 + MiniDisplaySetIconStatus(iDevice, aIcon, aIndex, IconStatusCount(aIcon) - 1);
1.10 + }
1.11 +
1.12 + public void SetIconOff(TMiniDisplayIconType aIcon, int aIndex)
1.13 + {
1.14 + MiniDisplaySetIconStatus(iDevice, aIcon, aIndex, 0);
1.15 + }
1.16 +
1.17 +
1.18 public void SetAllIconsStatus(int aStatus)
1.19 {
1.20 foreach (TMiniDisplayIconType icon in Enum.GetValues(typeof(TMiniDisplayIconType)))
1.21 @@ -353,7 +364,8 @@
1.22 /// </summary>
1.23 public enum TMiniDisplayIconType
1.24 {
1.25 - EMiniDisplayIconNetwork=0,
1.26 + EMiniDisplayIconNetworkSignal=0,
1.27 + EMiniDisplayIconInternet,
1.28 EMiniDisplayIconEmail,
1.29 EMiniDisplayIconMute,
1.30 EMiniDisplayIconVolume,
2.1 --- a/Server/MainForm.cs Mon Feb 09 18:25:14 2015 +0100
2.2 +++ b/Server/MainForm.cs Mon Feb 09 20:06:30 2015 +0100
2.3 @@ -226,11 +226,44 @@
2.4 {
2.5 if (iDisplay.IsOpen())
2.6 {
2.7 - iDisplay.SetIconOnOff(Display.TMiniDisplayIconType.EMiniDisplayIconNetwork, iNetworkManager.NetworkListManager.IsConnectedToInternet);
2.8 + iDisplay.SetIconOnOff(Display.TMiniDisplayIconType.EMiniDisplayIconInternet, iNetworkManager.NetworkListManager.IsConnectedToInternet);
2.9 + iDisplay.SetIconOnOff(Display.TMiniDisplayIconType.EMiniDisplayIconNetworkSignal, iNetworkManager.NetworkListManager.IsConnected);
2.10 }
2.11 }
2.12
2.13
2.14 + int iLastNetworkIconIndex = 0;
2.15 + int iUpdateCountSinceLastNetworkAnimation = 0;
2.16 +
2.17 + /// <summary>
2.18 + ///
2.19 + /// </summary>
2.20 + private void UpdateNetworkSignal(DateTime aLastTickTime, DateTime aNewTickTime)
2.21 + {
2.22 + iUpdateCountSinceLastNetworkAnimation++;
2.23 + iUpdateCountSinceLastNetworkAnimation = iUpdateCountSinceLastNetworkAnimation % 4;
2.24 +
2.25 + if (iDisplay.IsOpen() && iNetworkManager.NetworkListManager.IsConnected && iUpdateCountSinceLastNetworkAnimation==0)
2.26 + {
2.27 + int iconCount=iDisplay.IconCount(Display.TMiniDisplayIconType.EMiniDisplayIconNetworkSignal);
2.28 + iLastNetworkIconIndex++;
2.29 + iLastNetworkIconIndex = iLastNetworkIconIndex % (iconCount+1);
2.30 + for (int i=0;i<iconCount;i++)
2.31 + {
2.32 + if (i < iLastNetworkIconIndex)
2.33 + {
2.34 + iDisplay.SetIconOn(Display.TMiniDisplayIconType.EMiniDisplayIconNetworkSignal,i);
2.35 + }
2.36 + else
2.37 + {
2.38 + iDisplay.SetIconOff(Display.TMiniDisplayIconType.EMiniDisplayIconNetworkSignal,i);
2.39 + }
2.40 + }
2.41 + }
2.42 + }
2.43 +
2.44 +
2.45 +
2.46 /// <summary>
2.47 /// Receive volume change notification and reflect changes on our slider.
2.48 /// </summary>
2.49 @@ -730,6 +763,8 @@
2.50 //Update our animations
2.51 DateTime NewTickTime = DateTime.Now;
2.52
2.53 + UpdateNetworkSignal(LastTickTime, NewTickTime);
2.54 +
2.55 //Update animation for all our marquees
2.56 foreach (Control ctrl in tableLayoutPanel.Controls)
2.57 {
3.1 Binary file Server/MiniDisplay.dll has changed
4.1 --- a/Server/NetworkManager.cs Mon Feb 09 18:25:14 2015 +0100
4.2 +++ b/Server/NetworkManager.cs Mon Feb 09 20:06:30 2015 +0100
4.3 @@ -62,70 +62,5 @@
4.4 Debug.WriteLine("Un-subscribing to INetworkListManagerEvents");
4.5 iConnectionPoint.Unadvise(iCookie);
4.6 }
4.7 -
4.8 - /// <summary>
4.9 - /// Indicates whether any network connection is available
4.10 - /// Filter connections below a specified speed, as well as virtual network cards.
4.11 - /// </summary>
4.12 - /// <returns>
4.13 - /// <c>true</c> if a network connection is available; otherwise, <c>false</c>.
4.14 - /// </returns>
4.15 - public static bool IsAvailable()
4.16 - {
4.17 - return IsAvailable(0);
4.18 - }
4.19 -
4.20 - /// <summary>
4.21 - /// Indicates whether any network connection is available.
4.22 - /// Filter connections below a specified speed, as well as virtual network cards.
4.23 - /// </summary>
4.24 - /// <param name="minimumSpeed">The minimum speed required. Passing 0 will not filter connection using speed.</param>
4.25 - /// <returns>
4.26 - /// <c>true</c> if a network connection is available; otherwise, <c>false</c>.
4.27 - /// </returns>
4.28 - public static bool IsAvailable(long minimumSpeed)
4.29 - {
4.30 - if (!NetworkInterface.GetIsNetworkAvailable())
4.31 - return false;
4.32 -
4.33 - foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
4.34 - {
4.35 - // discard because of standard reasons
4.36 - if ((ni.OperationalStatus != OperationalStatus.Up) ||
4.37 - (ni.NetworkInterfaceType == NetworkInterfaceType.Loopback) ||
4.38 - (ni.NetworkInterfaceType == NetworkInterfaceType.Tunnel))
4.39 - continue;
4.40 -
4.41 - // this allow to filter modems, serial, etc.
4.42 - // I use 10000000 as a minimum speed for most cases
4.43 - if (ni.Speed < minimumSpeed)
4.44 - continue;
4.45 -
4.46 - // discard virtual cards (virtual box, virtual pc, etc.)
4.47 - if ((ni.Description.IndexOf("virtual", StringComparison.OrdinalIgnoreCase) >= 0) ||
4.48 - (ni.Name.IndexOf("virtual", StringComparison.OrdinalIgnoreCase) >= 0))
4.49 - continue;
4.50 -
4.51 - // discard "Microsoft Loopback Adapter", it will not show as NetworkInterfaceType.Loopback but as Ethernet Card.
4.52 - if (ni.Description.Equals("Microsoft Loopback Adapter", StringComparison.OrdinalIgnoreCase))
4.53 - continue;
4.54 -
4.55 - return true;
4.56 - }
4.57 - return false;
4.58 - }
4.59 -
4.60 - /// <summary>
4.61 - ///
4.62 - /// </summary>
4.63 - /// <returns></returns>
4.64 - public static bool HasInternet()
4.65 - {
4.66 - return false;
4.67 - //ConnectionProfile connections = NetworkInformation.GetInternetConnectionProfile();
4.68 - //bool internet = connections != null && connections.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess;
4.69 - //return internet;
4.70 - }
4.71 -
4.72 }
4.73 }