private CecButtonConfig _buttonConfig;
public CecButtonConfig ButtonConfig
{
- get
- {
- if (_buttonConfig == null)
- {
- _buttonConfig = new CecButtonConfig(this);
- foreach (CecUserControlCode key in Enum.GetValues(typeof(CecUserControlCode)))
- _buttonConfig.Add(new CecButtonConfigItem(this, (new CecKeypress { Keycode = key })));
-
- _buttonConfig.Load();
- }
- return _buttonConfig;
- }
+ get { return _buttonConfig ?? (_buttonConfig = new CecButtonConfig(this)); }
}
public CECSettings Settings;
using System.Collections.Generic;
using CecSharp;
using LibCECTray.settings;
+using System;
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()