//Add this method override protected override void OnStartup(StartupEventArgs e) { m_Mutex = new Mutex(true, "HomeGenieManagerMutex", out createdNew); //e.Args is the string[] of command line argruments // upnpService = new Dictionary<string, UPnPDevice>(); upnpControl = new UPnPControlPoint(); upnpControl.OnSearch += upnpcontrol_OnSearch; upnpControl.OnCreateDevice += upnpcontrol_OnCreateDevice; upnpControl.FindDeviceAsync("urn:schemas-upnp-org:device:HomeAutomationServer:1"); // Application.Current.ShutdownMode = System.Windows.ShutdownMode.OnLastWindowClose; var myDialogWindow = new LoadingDialog(); myDialogWindow.Show(); // Task loader = new Task(() => { int t = 0; while (t < 10) { if (upnpService.Count > 0) { Thread.Sleep(2000); for (int s = 0; s < UPnPDevices.Count; s++) { var dev = UPnPDevices.ElementAt(s).Value; if (dev.StandardDeviceType == "HomeAutomationServer") { System.Diagnostics.Process.Start(dev.PresentationURL); t = 10; break; } } } t++; Thread.Sleep(1000); } // Thread.Sleep(2000); // myDialogWindow.Dispatcher.BeginInvoke(new Action(() => { if (!createdNew) { myDialogWindow.Close(); Application.Current.Shutdown(); } else { var window = new MainWindow(); window.Show(); myDialogWindow.Close(); } }), null); }); loader.Start(); }
//"ssdp:all"; // public UpnpSmartControlPoint() { this.deviceFactory.OnDevice += this.DeviceFactoryCreationSink; this.deviceLifeTimeClock.OnExpired += this.DeviceLifeTimeClockSink; this.deviceUpdateClock.OnExpired += this.DeviceUpdateClockSink; this.hostNetworkInfo = new NetworkInfo(new NetworkInfo.InterfaceHandler(this.NetworkInfoNewInterfaceSink)); this.hostNetworkInfo.OnInterfaceDisabled += this.NetworkInfoOldInterfaceSink; this.genericControlPoint = new UPnPControlPoint(this.hostNetworkInfo); this.genericControlPoint.OnSearch += this.UPnPControlPointSearchSink; this.genericControlPoint.OnNotify += this.SSDPNotifySink; this.genericControlPoint.FindDeviceAsync(searchFilter); }
public UPnPInternalSmartControlPoint() { deviceFactory.OnDevice += new UPnPDeviceFactory.UPnPDeviceHandler(DeviceFactoryCreationSink); deviceFactory.OnFailed += new UPnPDeviceFactory.UPnPDeviceFailedHandler(DeviceFactoryFailedSink); deviceLifeTimeClock.OnExpired += new LifeTimeMonitor.LifeTimeHandler(DeviceLifeTimeClockSink); deviceUpdateClock.OnExpired += new LifeTimeMonitor.LifeTimeHandler(DeviceUpdateClockSink); hostNetworkInfo = new NetworkInfo(new NetworkInfo.InterfaceHandler(NetworkInfoNewInterfaceSink)); hostNetworkInfo.OnInterfaceDisabled += new NetworkInfo.InterfaceHandler(NetworkInfoOldInterfaceSink); // Launch a search for all devices and start populating the // internal smart control point device list. genericControlPoint = new UPnPControlPoint(); genericControlPoint.OnSearch += new UPnPControlPoint.SearchHandler(UPnPControlPointSearchSink); genericControlPoint.OnNotify += new SSDP.NotifyHandler(SSDPNotifySink); genericControlPoint.FindDeviceAsync("upnp:rootdevice"); }
public void ShutDown() { this.deviceFactory.OnDevice -= this.DeviceFactoryCreationSink; this.deviceLifeTimeClock.OnExpired -= this.DeviceLifeTimeClockSink; this.deviceUpdateClock.OnExpired -= this.DeviceUpdateClockSink; this.hostNetworkInfo.OnInterfaceDisabled -= this.NetworkInfoOldInterfaceSink; this.genericControlPoint.OnSearch -= this.UPnPControlPointSearchSink; this.genericControlPoint.OnNotify -= this.SSDPNotifySink; this.deviceFactory.Shutdown(); this.deviceFactory = null; this.hostNetworkInfo = null; this.genericControlPoint = null; }