public void Copy(ControllerButtonState newState)
 {
     isSelected.Clear();
     foreach (KeyValuePair <string, ushort> entry in _values)
     {
         if (newState.isSelected.ContainsKey(entry.Key) && newState.isSelected[entry.Key])
         {
             isSelected[entry.Key] = true;
         }
     }
 }
        public WindowController(Settings settings, int index, Window owner)
        {
            InitializeComponent();

            // set owner
            Owner = owner;

            // create list of all controller buttons for later updates
            _controllerButtons = new List <Border>()
            {
                buttonPadUp,
                buttonPadDown,
                buttonPadLeft,
                buttonPadRight,
                buttonStart,
                buttonBack,
                buttonLeftThumb,
                buttonRightThumb,
                buttonLeftShoulder,
                buttonRightShoulder,
                buttonA,
                buttonB,
                buttonX,
                buttonY
            };

            // get settings
            _settings    = settings;
            _hotkeyIndex = index;
            if (_hotkeyIndex == -1)
            {
                // create new hotkey
                _hotkey                       = new Hotkey();
                _hotkey.isEnabled             = true;
                _hotkey.isCommandBatteryLevel = true;
            }
            else
            {
                // load existing hotkey
                _hotkey = _settings.hotkeys[_hotkeyIndex];
            }

            // set UI elements
            _checkEnabled  = false;
            inputName.Text = _hotkey.name;
            radioCommandTypeBatteryLevel.IsChecked = _hotkey.isCommandBatteryLevel;
            radioCommandTypeCustom.IsChecked       = !_hotkey.isCommandBatteryLevel;
            inputCommand.Text      = _hotkey.commandCustom;
            inputEnabled.IsChecked = _hotkey.isEnabled;
            _controllerButtonState = new ControllerButtonState();
            _controllerButtonState.Copy(_hotkey.buttonState);

            // set controlleer button colors
            foreach (Border controllerButton in _controllerButtons)
            {
                // remove "button" from control name
                string buttonStateName = controllerButton.Name.Substring(6);
                controllerButton.Background = (_controllerButtonState.GetButtonSelected(buttonStateName) ? COLOR_BUTTON_SELECTED : COLOR_BUTTON_DEFAULT);
            }

            _checkEnabled = true;
            Check();
        }