Published v0.6.1.0.
Fixing CEC TV power on issue.
2 // Copyright (C) 2014-2015 Stéphane Lenclud.
4 // This file is part of SharpDisplayManager.
6 // SharpDisplayManager is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
11 // SharpDisplayManager is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with SharpDisplayManager. If not, see <http://www.gnu.org/licenses/>.
21 using System.Runtime.InteropServices.ComTypes;
22 using System.Diagnostics;
25 namespace SharpDisplayManager
27 public class NetworkManager: INetworkListManagerEvents, IDisposable
29 public delegate void OnConnectivityChangedDelegate(NetworkManager aNetworkManager, NLM_CONNECTIVITY aConnectivity);
30 public event OnConnectivityChangedDelegate OnConnectivityChanged;
32 private int iCookie = 0;
33 private IConnectionPoint iConnectionPoint;
34 private INetworkListManager iNetworkListManager;
37 public NetworkManager()
39 iNetworkListManager = new NetworkListManager();
40 ConnectToNetworkListManagerEvents();
45 //Not sure why this is not working form here
46 //Possibly because something is doing automatically before we get there
47 //DisconnectFromNetworkListManagerEvents();
51 public INetworkListManager NetworkListManager
53 get { return iNetworkListManager; }
56 public void ConnectivityChanged(NLM_CONNECTIVITY newConnectivity)
59 OnConnectivityChanged(this, newConnectivity);
62 public void ConnectToNetworkListManagerEvents()
64 Debug.WriteLine("Subscribing to INetworkListManagerEvents");
65 IConnectionPointContainer icpc = (IConnectionPointContainer)iNetworkListManager;
66 //similar event subscription can be used for INetworkEvents and INetworkConnectionEvents
67 Guid tempGuid = typeof(INetworkListManagerEvents).GUID;
68 icpc.FindConnectionPoint(ref tempGuid, out iConnectionPoint);
69 iConnectionPoint.Advise(this, out iCookie);
73 public void DisconnectFromNetworkListManagerEvents()
75 Debug.WriteLine("Un-subscribing to INetworkListManagerEvents");
76 iConnectionPoint.Unadvise(iCookie);