public static void NewScheme(ColorScheme colorScheme) { // Save new scheme to the registry RegistryKey newKey = colorSchemesKey.CreateSubKey(colorScheme.Name); colorScheme.WriteToRegistry(newKey); // Add to scheme dictionary colorSchemes.Add(colorScheme.Name, colorScheme); }
public static void UpdateScheme(ColorScheme colorScheme) { colorSchemes[colorScheme.Name] = colorScheme; RegistryKey currentKey = colorSchemesKey.OpenSubKey(colorScheme.Name, true); if (currentKey == null) { currentKey = colorSchemesKey.CreateSubKey(colorScheme.Name); } colorScheme.WriteToRegistry(currentKey); }
public void SaveToRegistry(RegistryKey key) { // save new color scheme to the game's registry key - either as a named scheme (if it // is one) or as a list of ad-hoc colors if (!ColorScheme.Modified) { // save the color scheme name in the game's registry key key.SetValue("ColorScheme", ColorScheme.Name); // since this is associated with a named scheme, delete any values in // the game's key that provide individual color elements string[] valueNames = key.GetValueNames(); foreach (string valuename in valueNames) { if ((valuename.Length == 11 && valuename.ToUpper() == "BORDERCOLOR") || (valuename.Length == 13 && valuename.ToUpper() == "BORDERTEXTURE") || (valuename.Length == 9 && valuename.ToUpper() == "TEXTCOLOR") || (valuename.Length == 14 && valuename.ToUpper() == "HIGHLIGHTCOLOR") || (valuename.Length > 11 && valuename.ToUpper().Substring(0, 11) == "SQUARECOLOR") || (valuename.Length > 13 && valuename.ToUpper().Substring(0, 13) == "SQUARETEXTURE") || (valuename.Length > 11 && valuename.ToUpper().Substring(0, 11) == "PLAYERCOLOR")) { // remove game-specific ad hoc element key.DeleteValue(valuename); } } } else { ColorScheme.WriteToRegistry(key); // since this is an ad-hoc scheme, delete the previous entry to named scheme if any key.DeleteValue("ColorScheme", false); } // save the piece set selection to the registry key.SetValue("PieceSet", PieceSet.Name); // save custom theme name (if any) if (CustomThemeName != null) { key.SetValue("CustomTheme", CustomThemeName); } else if (key.GetValue("CustomTheme") != null) { key.DeleteValue("CustomTheme"); } }