public void Save(INiKeyboardMappings mappings) { if (mappings == null) { throw new ArgumentNullException("mappings"); } // Update the registry with the new mappings. var newMappings = ((NiKeyboardMappings)mappings).Mappings; var seen = new HashSet <Guid>(); using (var key = OpenRegistryKey(true)) { foreach (string name in key.GetValueNames()) { Guid guid; if (!Guid.TryParse(name, out guid)) { key.DeleteValue(name); } else { seen.Add(guid); Keys[] keys; if (newMappings.TryGetValue(guid, out keys)) { key.SetValue(name, CreateKeysValue(keys)); } else { key.DeleteValue(name); } } } foreach (var item in newMappings) { if (seen.Contains(item.Key)) { continue; } key.SetValue(item.Key.ToString("B"), CreateKeysValue(item.Value)); } } // Reload the mappings from the registry. LoadMappings(); }
public HResult LoadKeyboardMappings(out INiKeyboardMappings mappings) { mappings = null; try { mappings = _keyboardMappingManager.Load(); return(HResult.OK); } catch (Exception ex) { return(ErrorUtil.GetHResult(ex)); } }
public HResult LoadKeyboardMappings(out INiKeyboardMappings mappings) { mappings = null; try { mappings = _keyboardMappingManager.Load(); return HResult.OK; } catch (Exception ex) { return ErrorUtil.GetHResult(ex); } }
public HResult SaveKeyboardMappings(INiKeyboardMappings mappings) { try { if (mappings == null) throw new ArgumentNullException("mappings"); _keyboardMappingManager.Save(mappings); return HResult.OK; } catch (Exception ex) { return ErrorUtil.GetHResult(ex); } }
public HResult SaveKeyboardMappings(INiKeyboardMappings mappings) { try { if (mappings == null) { throw new ArgumentNullException("mappings"); } _keyboardMappingManager.Save(mappings); return(HResult.OK); } catch (Exception ex) { return(ErrorUtil.GetHResult(ex)); } }
public void Save(INiKeyboardMappings mappings) { if (mappings == null) throw new ArgumentNullException("mappings"); // Update the registry with the new mappings. var newMappings = ((NiKeyboardMappings)mappings).Mappings; var seen = new HashSet<Guid>(); using (var key = OpenRegistryKey(true)) { foreach (string name in key.GetValueNames()) { Guid guid; if (!Guid.TryParse(name, out guid)) { key.DeleteValue(name); } else { seen.Add(guid); Keys[] keys; if (newMappings.TryGetValue(guid, out keys)) key.SetValue(name, CreateKeysValue(keys)); else key.DeleteValue(name); } } foreach (var item in newMappings) { if (seen.Contains(item.Key)) continue; key.SetValue(item.Key.ToString("B"), CreateKeysValue(item.Value)); } } // Reload the mappings from the registry. LoadMappings(); }