updated copyright messages for 2013
[deb_libcec.git] / src / LibCecTray / controller / applications / CecButtonConfig.cs
index 63aba6c84616971c5206bf1142d7eccd59059294..2afa257cf8f2365e67f0b22d960333bdeadc92fc 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.
@@ -33,6 +33,7 @@
 using System.Collections.Generic;
 using CecSharp;
 using LibCECTray.settings;
+using System;
 
 namespace LibCECTray.controller.applications
 {
@@ -269,6 +270,27 @@ namespace LibCECTray.controller.applications
     public CecButtonConfig(ApplicationController controller)
     {
       _controller = controller;
+
+      foreach (CecUserControlCode key in Enum.GetValues(typeof(CecUserControlCode)))
+        AddConfigItem(new CecButtonConfigItem(controller, (new CecKeypress { Keycode = key })));
+
+      Load();
+    }
+
+    private void AddConfigItem(CecButtonConfigItem item)
+    {
+      if (!HasItem(item) && item.Key.Keycode != CecUserControlCode.Unknown)
+        Add(item);
+    }
+
+    public bool HasItem(CecButtonConfigItem item)
+    {
+      foreach (var entry in  this)
+      {
+        if (item.Key.Keycode == entry.Key.Keycode)
+          return true;
+      }
+      return false;
     }
 
     public void Load()