/// <summary>Sets the and reloads the theme colors based on the passed in enum.</summary> public static void SetTheme(OdTheme themeCur) { if (_themeCur == themeCur) { return; } _locker.EnterWriteLock(); try { _themeCur = themeCur; ODColorTheme themeSetter = null; switch (themeCur) { case OdTheme.Standard: themeSetter = new OdThemeStandard(); break; case OdTheme.Flat: themeSetter = new OdThemeFlat(); break; default: themeSetter = new OdThemeStandard(); break; } themeSetter.SetTheme(); } finally { _locker.ExitWriteLock(); } foreach (Action action in _dictOnThemeChangedActions.Values) { action.Invoke(); } }
///<summary>This should be called when the user is changed (excluding temporay logins such as job review logins). ///In the future, we could also call this if we detect the office theme has changed via signal preference cache refresh or if ///another person using the same login information changes the theme for a group of users.</summary> public static void SetThemeForUserIfNeeded() { OdTheme themeDefault = OdTheme.Standard; try { themeDefault = (OdTheme)PrefC.GetInt(PrefName.ColorTheme); } catch { //try/catch in case you are trying to convert from an older version of OD and need to update the DB. } if (Security.CurUser == null) //no current user, set to the default practice theme. { ODColorTheme.SetTheme(themeDefault); return; } UserOdPref themePref = UserOdPrefs.GetByUserAndFkeyType(Security.CurUser.UserNum, UserOdFkeyType.UserTheme).FirstOrDefault(); //user theme not allowed or hasn't been set if (!PrefC.GetBool(PrefName.ThemeSetByUser) || themePref == null) { ODColorTheme.SetTheme(themeDefault); } else if (themePref != null) //user theme allowed but needs to update for user pref { ODColorTheme.SetTheme((OdTheme)themePref.Fkey); } }