1.1 --- a/Server/MainForm.cs Mon Feb 09 11:09:33 2015 +0100
1.2 +++ b/Server/MainForm.cs Mon Feb 09 18:25:14 2015 +0100
1.3 @@ -19,6 +19,8 @@
1.4 using NAudio.CoreAudioApi;
1.5 using NAudio.CoreAudioApi.Interfaces;
1.6 using System.Runtime.InteropServices;
1.7 +//Network
1.8 +using NETWORKLIST;
1.9 //
1.10 using SharpDisplayClient;
1.11 using SharpDisplay;
1.12 @@ -64,6 +66,8 @@
1.13 //NAudio
1.14 private MMDeviceEnumerator iMultiMediaDeviceEnumerator;
1.15 private MMDevice iMultiMediaDevice;
1.16 + //Network
1.17 + private NetworkManager iNetworkManager;
1.18
1.19
1.20 /// <summary>
1.21 @@ -132,10 +136,14 @@
1.22
1.23 //NAudio
1.24 iMultiMediaDeviceEnumerator = new MMDeviceEnumerator();
1.25 - iMultiMediaDeviceEnumerator.RegisterEndpointNotificationCallback(this);
1.26 -
1.27 + iMultiMediaDeviceEnumerator.RegisterEndpointNotificationCallback(this);
1.28 UpdateAudioDeviceAndMasterVolumeThreadSafe();
1.29
1.30 + //Network
1.31 + iNetworkManager = new NetworkManager();
1.32 + iNetworkManager.OnConnectivityChanged += OnConnectivityChanged;
1.33 + UpdateNetworkStatus();
1.34 +
1.35 //Setup notification icon
1.36 SetupTrayIcon();
1.37
1.38 @@ -182,8 +190,10 @@
1.39 //Initiate asynchronous request
1.40 iDisplay.RequestFirmwareRevision();
1.41
1.42 - //
1.43 + //Audio
1.44 UpdateMasterVolumeThreadSafe();
1.45 + //Network
1.46 + UpdateNetworkStatus();
1.47
1.48 #if DEBUG
1.49 //Testing icon in debug, no arm done if icon not supported
1.50 @@ -202,7 +212,25 @@
1.51 //Our display was just closed, update our UI consequently
1.52 UpdateStatus();
1.53 }
1.54 -
1.55 +
1.56 + public void OnConnectivityChanged(NetworkManager aNetwork, NLM_CONNECTIVITY newConnectivity)
1.57 + {
1.58 + //Update network status
1.59 + UpdateNetworkStatus();
1.60 + }
1.61 +
1.62 + /// <summary>
1.63 + /// Update our Network Status
1.64 + /// </summary>
1.65 + private void UpdateNetworkStatus()
1.66 + {
1.67 + if (iDisplay.IsOpen())
1.68 + {
1.69 + iDisplay.SetIconOnOff(Display.TMiniDisplayIconType.EMiniDisplayIconNetwork, iNetworkManager.NetworkListManager.IsConnectedToInternet);
1.70 + }
1.71 + }
1.72 +
1.73 +
1.74 /// <summary>
1.75 /// Receive volume change notification and reflect changes on our slider.
1.76 /// </summary>
1.77 @@ -1077,6 +1105,7 @@
1.78
1.79 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
1.80 {
1.81 + iNetworkManager.Dispose();
1.82 CloseDisplayConnection();
1.83 StopServer();
1.84 e.Cancel = iClosing;