private ExtendedControls.Theme GetThemeFromDB() { if (EliteDangerousCore.DB.UserDatabase.Instance.KeyExists("ThemeNameOf")) // { // we convert into JSON and then let the JSON reader do the job, of course, if we were doing this again, the JSON would just be in the DB JObject jo = new JObject(); string name = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString("ThemeNameOf", "Custom"); jo["windowsframe"] = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingBool("ThemeWindowsFrame", true); jo["formopacity"] = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingDouble("ThemeFormOpacity", 100); jo["fontname"] = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString("ThemeFont", ExtendedControls.Theme.DefaultFont); jo["fontsize"] = (float)EliteDangerousCore.DB.UserDatabase.Instance.GetSettingDouble("ThemeFontSize", ExtendedControls.Theme.DefaultFontSize); jo["buttonstyle"] = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString("ButtonStyle", ExtendedControls.Theme.ButtonstyleSystem); jo["textboxborderstyle"] = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString("TextBoxBorderStyle", ExtendedControls.Theme.TextboxborderstyleFixed3D); // pick a default, based on the name. This is useful when new names are introduced, as if we are using a default theme, we will pick the new colour from the theme var defaulttheme = ThemeList.FindTheme(name) ?? ThemeList.FindTheme("Windows Default"); foreach (ExtendedControls.Theme.CI ci in Enum.GetValues(typeof(ExtendedControls.Theme.CI))) { var cname = "ThemeColor" + ci.ToString(); int d = defaulttheme.GetColor(ci).ToArgb(); int dbv = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt(cname, d); jo[ci.ToString()] = dbv; } ExtendedControls.Theme theme = new ExtendedControls.Theme(); return(theme.FromJSON(jo, name, defaulttheme) ? theme : null); } else { return(null); } }
private void extButtonVerdana_Click(object sender, EventArgs e) { Theme.Current = stdthemes.FindTheme("Elite Verdana"); Theme.Current.ApplyStd(this); labelName.Text = Theme.Current.Name; }