using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Drawing; using System.IO; using Newtonsoft.Json; namespace Optimizer { public class SettingsJson { public Theme Color { get; set; } } public static class Options { readonly static string flag = "themeable"; internal readonly static string SettingsFile = Required.CoreFolder + "\\Optimizer.json"; internal static SettingsJson CurrentOptions = new SettingsJson(); // use this to determine if changes have been made private static SettingsJson Flag = new SettingsJson(); internal static IEnumerable GetSelfAndChildrenRecursive(Control parent) { List controls = new List(); foreach (Control child in parent.Controls) { controls.AddRange(GetSelfAndChildrenRecursive(child)); } controls.Add(parent); return controls; } internal static void ApplyTheme(Form f) { switch (CurrentOptions.Color) { case Theme.Caramel: SetTheme(f, Color.DarkOrange, Color.Chocolate); break; case Theme.Lime: SetTheme(f, Color.LimeGreen, Color.ForestGreen); break; case Theme.Magma: SetTheme(f, Color.Tomato, Color.Red); break; case Theme.Minimal: SetTheme(f, Color.Gray, Color.DimGray); break; case Theme.Ocean: SetTheme(f, Color.DodgerBlue, Color.RoyalBlue); break; case Theme.Zerg: SetTheme(f, Color.MediumOrchid, Color.DarkOrchid); break; } } private static void SetTheme(Form f, Color c1, Color c2) { GetSelfAndChildrenRecursive(f).OfType