// From json. defcols is the colours to use if the json does not have it. public Settings(JObject jo, string settingsname, Settings defcols) { name = settingsname.Replace(".eddtheme", ""); colors = new Dictionary<CI, Color>(); foreach (CI ck in Enum.GetValues(typeof(CI))) // all enums { Color d = defcols.colors[ck]; colors.Add(ck, JGetColor(jo, ck.ToString(),d)); } windowsframe = GetBool(jo["windowsframe"],defcols.windowsframe); formopacity = GetFloat(jo["formopacity"],(float)defcols.formopacity); fontname = GetString(jo["fontname"], defcols.fontname); fontsize = GetFloat(jo["fontsize"], defcols.fontsize); buttonstyle = GetString(jo["buttonstyle"], defcols.buttonstyle); textboxborderstyle = GetString(jo["textboxborderstyle"], defcols.textboxborderstyle); }
// given a theme name, select it if possible public bool SetThemeByName(string themename) { int i = FindThemeIndex(themename); if (i != -1) { currentsettings = new Settings(themelist[i]); // do a copy, not a reference assign.. return true; } return false; }
public bool EditColor(Settings.CI ex) { ColorDialog MyDialog = new ColorDialog(); MyDialog.AllowFullOpen = true; MyDialog.FullOpen = true; MyDialog.Color = currentsettings.colors[ex]; if (MyDialog.ShowDialog() == DialogResult.OK) { currentsettings.colors[ex] = MyDialog.Color; SetCustom(); return true; } else return false; }
public EDDTheme() { toolstripRenderer = new EDDToolStripRenderer(); themelist = new List<Settings>(); // theme list in currentsettings = new Settings("Windows Default"); // this is our default }
// copy constructor, takes a real copy, with overrides public Settings(Settings other,string newname = null , string newfont = null, float newfontsize = 0, double opaque = 0) { name = (newname!=null) ? newname : other.name; fontname = (newfont != null) ? newfont : other.fontname; fontsize = (newfontsize != 0) ? newfontsize : other.fontsize; windowsframe = other.windowsframe; formopacity = other.formopacity; buttonstyle = other.buttonstyle; textboxborderstyle = other.textboxborderstyle; formopacity = (opaque > 0) ? opaque: other.formopacity; colors = new Dictionary<CI, Color>(); foreach (CI ck in other.colors.Keys) { colors.Add(ck, other.colors[ck]); } }