public void AddMapping(IEnumerable<int> data, ButtonMapping mapping) { string s = GetString(data); if (m_mappings.ContainsKey(s)) { throw new Exception("Mapping already exists for that button"); } Mappings.Add(mapping); m_mappings[s] = mapping; Save(); }
private void ButtonPressed(ButtonMapping mapping) { if (mapping.ButtonType == ButtonType.Target) { ButtonMappingTarget target = (ButtonMappingTarget)mapping; m_currentDevice = m_devices.FirstOrDefault(device => device.NodeID == target.DeviceID); } else { ButtonMappingAction action = (ButtonMappingAction)mapping; if (null == m_currentDevice) { m_devices.ForEach(device => ApplyAction(device, action.Action)); } else { ApplyAction(m_currentDevice, action.Action); } } }