added ActivateSource action to cectray
[deb_libcec.git] / src / LibCecTray / controller / Actions.cs
index 2d065a94d192b705a7c929cf01af4074efbd0a5d..355f94ee4c5b6fa2bf8d5604482636d252028c10 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the libCEC(R) library.
  *
- * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited.  All rights reserved.
+ * libCEC(R) is Copyright (C) 2011-2013 Pulse-Eight Limited.  All rights reserved.
  * libCEC(R) is an original work, containing original code.
  *
  * libCEC(R) is a trademark of Pulse-Eight Limited.
@@ -94,7 +94,7 @@ namespace LibCECTray.controller
           _controller.CheckActiveDevices();
           break;
         case UpdateEventType.ProcessCompleted:
-          if (!(_activeProcess is GetCurrentPhysicalAddress))
+          if (!(_activeProcess is GetCurrentPhysicalAddress) && !SuppressUpdates)
           {
             _activeProcess = new GetCurrentPhysicalAddress(_controller.Lib);
             _activeProcess.EventHandler += ProcessEventHandler;
@@ -123,6 +123,7 @@ namespace LibCECTray.controller
 
           break;
         case UpdateEventType.ExitApplication:
+          SuppressUpdates = true;
           _activeProcess = null;
           Application.Exit();
           break;
@@ -207,7 +208,7 @@ namespace LibCECTray.controller
     /// Activate the source at the given logical address. 
     /// </summary>
     /// <param name="address">The logical address of the device to activate</param>
-    public void ActivateSource(CecLogicalAddress address)
+    public void SetStreamPath(CecLogicalAddress address)
     {
       if (SuppressUpdates || _activeProcess != null) return;
 
@@ -217,6 +218,16 @@ namespace LibCECTray.controller
       (new Thread(_activeProcess.Run)).Start();
     }
 
+    public void ActivateSource()
+    {
+      if (SuppressUpdates || _activeProcess != null) return;
+
+      _controller.SetControlsEnabled(false);
+      _activeProcess = new ActivateSource(_controller.Lib);
+      _activeProcess.EventHandler += ProcessEventHandler;
+      (new Thread(_activeProcess.Run)).Start();
+    }
+
     /// <summary>
     /// Send a standby command to the device at the given logical address
     /// </summary>