public static void ChangeTheme(IBaseTheme dark, Color Primary, Color Secondary) { var paletteHelper = new PaletteHelper(); ITheme theme = paletteHelper.GetTheme(); //Change the base theme to Dark theme.SetBaseTheme(dark); //or theme.SetBaseTheme(Theme.Light); //Change all of the primary colors to Red theme.SetPrimaryColor(Primary); //Change all of the secondary colors to Blue theme.SetSecondaryColor(Secondary); var pr = theme.PrimaryMid; pr.ForegroundColor = Colors.White; theme.PrimaryMid = pr; Color c = theme.PrimaryMid.Color; int whiteconti = (c.R + c.G + c.B) / 3; //theme.Paper = Colors.White; //Change the app's current theme paletteHelper.SetTheme(theme); Logger.LogInfo("Changed Theme:" + (dark == Theme.Dark ? "Dark" : "Light") + "#0" + c.R + "." + c.G + "." + c.B); }
private static void AssertThemeColorsInXaml(IBaseTheme baseTheme, string xaml) { var theme = new Theme(); theme.SetBaseTheme(baseTheme); var resourceDictionary = MdixHelper.GetResourceDictionary(xaml); var updatedDictionary = new ResourceDictionary(); updatedDictionary.SetTheme(theme); foreach (var property in theme.GetType().GetProperties().Where(p => p.PropertyType == typeof(Color))) { var propertyColor = (Color)property.GetValue(theme) !; var(nameBrush, nameColor) = property.Name == "ValidationError" ? ("MaterialDesignValidationErrorBrush", "MaterialDesignValidationErrorColor") : ("MaterialDesign" + property.Name, "MaterialDesign" + property.Name + "Color"); Assert.True(resourceDictionary.Contains(nameBrush), $"{nameBrush} from {theme.GetType()} not found in {xaml}"); var xamlValue = resourceDictionary[nameBrush]; Assert.True(xamlValue is SolidColorBrush, $"{nameBrush} in {xaml} is no SolidColorBrush"); Assert.Equal(propertyColor, ((SolidColorBrush)xamlValue).Color); Assert.True(updatedDictionary.Contains(nameColor), $"{nameColor} from {theme.GetType()} not set via ResourceDictionaryExtensions.SetTheme"); Assert.Equal(propertyColor, updatedDictionary[nameColor]); } }
private static void AssertXamlColorsInTheme(string xaml, IBaseTheme baseTheme) { var theme = new Theme(); theme.SetBaseTheme(baseTheme); var resourceDictionary = MdixHelper.GetResourceDictionary(xaml); foreach (var(key, solidColorBrush) in resourceDictionary .Cast <DictionaryEntry>() .Where(e => e.Value is SolidColorBrush) .Select(e => ((string)e.Key, (SolidColorBrush)e.Value)) .OrderBy(e => e.Item1)) { var baseThemePropertyName = key == "MaterialDesignValidationErrorBrush" ? "MaterialDesignValidationErrorColor" : key; var baseThemeProperty = baseTheme.GetType().GetProperty(baseThemePropertyName); Assert.False(baseThemeProperty == null, $"{baseThemePropertyName} from {xaml} not found in {baseTheme.GetType()}"); var themePropertyName = key == "MaterialDesignValidationErrorBrush" ? "ValidationError" : key.Replace("MaterialDesign", ""); var themeProperty = theme.GetType().GetProperty(themePropertyName); Assert.False(themeProperty == null, $"{themePropertyName} from {xaml} not found in {theme.GetType()}"); Assert.NotNull(themeProperty); Assert.Equal(solidColorBrush.Color, themeProperty.GetValue(theme)); } }
public static void SetBaseTheme(this ITheme theme, IBaseTheme baseTheme) { if (theme == null) { throw new ArgumentNullException(nameof(theme)); } theme.ValidationError = baseTheme.ValidationErrorColor; theme.Background = baseTheme.MaterialDesignBackground; theme.Paper = baseTheme.MaterialDesignPaper; theme.CardBackground = baseTheme.MaterialDesignCardBackground; theme.ToolBarBackground = baseTheme.MaterialDesignToolBarBackground; theme.Body = baseTheme.MaterialDesignBody; theme.BodyLight = baseTheme.MaterialDesignBodyLight; theme.ColumnHeader = baseTheme.MaterialDesignColumnHeader; theme.CheckBoxOff = baseTheme.MaterialDesignCheckBoxOff; theme.CheckBoxDisabled = baseTheme.MaterialDesignCheckBoxDisabled; theme.Divider = baseTheme.MaterialDesignDivider; theme.Selection = baseTheme.MaterialDesignSelection; theme.FlatButtonClick = baseTheme.MaterialDesignFlatButtonClick; theme.FlatButtonRipple = baseTheme.MaterialDesignFlatButtonRipple; theme.ToolTipBackground = baseTheme.MaterialDesignToolTipBackground; theme.ChipBackground = baseTheme.MaterialDesignChipBackground; theme.SnackbarBackground = baseTheme.MaterialDesignSnackbarBackground; theme.SnackbarMouseOver = baseTheme.MaterialDesignSnackbarMouseOver; theme.SnackbarRipple = baseTheme.MaterialDesignSnackbarRipple; theme.TextBoxBorder = baseTheme.MaterialDesignTextBoxBorder; theme.TextFieldBoxBackground = baseTheme.MaterialDesignTextFieldBoxBackground; theme.TextFieldBoxHoverBackground = baseTheme.MaterialDesignTextFieldBoxHoverBackground; theme.TextFieldBoxDisabledBackground = baseTheme.MaterialDesignTextFieldBoxDisabledBackground; theme.TextAreaBorder = baseTheme.MaterialDesignTextAreaBorder; theme.TextAreaInactiveBorder = baseTheme.MaterialDesignTextAreaInactiveBorder; }
private void Check() { IBaseTheme themeBase = Theme.Dark; if (radLightTheme.IsChecked == true) { themeBase = Theme.Light; } if (manifest.PeriodicChecking == chkPeriodicChecking.IsChecked && // manifest.PeriodicCheckingInterval == InteravalValue && // manifest.AutoConfirmMarketTransactions == chkAutoConfirm_Market.IsChecked && // manifest.AutoConfirmTrades == chkAutoConfirm_Trades.IsChecked && // manifest.AutoEntry == chkAutoEntry.IsChecked && // manifest.AutoRefreshSession == chkAutoRefreshSession.IsChecked && // manifest.CheckForUpdates == chkAutoCheckForUpdates.IsChecked && // manifest.AllowBetaUpdates == chkAllowBetaUpdates.IsChecked && // manifest.DeveloperMode == chkDevMode.IsChecked && // manifest.DisplaySearch == chkDisplaySearch.IsChecked && // //manifest.SortAlpha == chkSortAlpha.IsChecked manifest.BaseTheme == themeBase) { btnSave.IsEnabled = false; } else { btnSave.IsEnabled = true; } gridInterval.IsEnabled = (bool)chkPeriodicChecking.IsChecked; }
/// <summary> /// This function is used to apply the theme on the app, the parameter theme is retrieve through user's app's settings /// </summary> private void ApplyCurrentTheme() { ITheme theme = _paletteHelper.GetTheme(); IBaseTheme baseTheme = Properties.Settings.Default.isDark ? new MaterialDesignDarkTheme() : (IBaseTheme) new MaterialDesignLightTheme(); theme.SetBaseTheme(baseTheme); _paletteHelper.SetTheme(theme); }
private void ToggleBaseColour(bool isDark) { ITheme theme = _paletteHelper.GetTheme(); IBaseTheme baseTheme = isDark ? new MaterialDesignDarkTheme() : (IBaseTheme) new MaterialDesignLightTheme(); theme.SetBaseTheme(baseTheme); _paletteHelper.SetTheme(theme); }
/// <summary> /// Switches the theme to the data provided in the color object /// </summary> public static void SwitchTheme() { IBaseTheme baseTheme = Theme.Light; ITheme defaultTheme = Theme.Create(baseTheme, Color.FromRgb(147, 91, 249), Color.FromRgb(114, 124, 245)); ResourceDictionaryExtensions.SetTheme(Application.Current.Resources, defaultTheme); return; }
private void ApplyBase(bool isDark) { theme = paletteHelper.GetTheme(); IBaseTheme baseTheme = isDark ? new MaterialDesignDarkTheme() : (IBaseTheme) new MaterialDesignLightTheme(); theme.SetBaseTheme(baseTheme); paletteHelper.SetTheme(theme); }
public void ChangeTheme() { ITheme theme = _paletteHelper.GetTheme(); IBaseTheme baseTheme = IsDarkMode ? new MaterialDesignDarkTheme() : (IBaseTheme) new MaterialDesignLightTheme(); theme.SetBaseTheme(baseTheme); _paletteHelper.SetTheme(theme); }
public Theme(IBaseTheme baseTheme, Color primaryColor, Color secondaryColor, Color successColor, Color canceledColor, Color failedColor) { BaseTheme = baseTheme; PrimaryColor = primaryColor; SecondaryColor = secondaryColor; SuccessColor = successColor; CanceledColor = canceledColor; FailedColor = failedColor; }
public ThemeWrapper( IBaseTheme value, string themeName, ThemeKind kind) { Value = value.ThrowIfNull(nameof(value)); ThemeName = themeName.ThrowIfNull(nameof(themeName)); Kind = kind.ThrowIfEnumValueIsUndefined(nameof(kind)); }
private void EnableDarkMode(bool isDark) { ITheme theme = paletteHelper.GetTheme(); IBaseTheme baseTheme = isDark ? new MaterialDesignDarkTheme() : (IBaseTheme) new MaterialDesignLightTheme(); theme.SetBaseTheme(baseTheme); paletteHelper.SetTheme(theme); iniFile.Write("DarkMode", isDark.ToString(), "Theme"); }
public void RefreshTheme() { var paletteHelper = new PaletteHelper(); var theme = paletteHelper.GetTheme(); IBaseTheme baseTheme = DarkMode ? new MaterialDesignDarkTheme() : (IBaseTheme) new MaterialDesignLightTheme(); theme.SetBaseTheme(baseTheme); paletteHelper.SetTheme(theme); }
private void SetThemeApplication() { ITheme theme = _paletteHelper.GetTheme(); IBaseTheme baseTheme = _isCheckedDarkModeToggle ? new MaterialDesignDarkTheme() : (IBaseTheme) new MaterialDesignLightTheme(); theme.SetBaseTheme(baseTheme); _paletteHelper.SetTheme(theme); SetForegroundColorForMenu(_isCheckedDarkModeToggle); }
private void Green_Click(object sender, RoutedEventArgs e) { PaletteHelper paletteHelper = new PaletteHelper(); Color primaryColor = Color.FromRgb(102, 187, 106); Color secondaryColor = Color.FromRgb(102, 187, 106); IBaseTheme baseTheme = Theme.Light; ITheme theme = Theme.Create(baseTheme, primaryColor, secondaryColor); paletteHelper.SetTheme(theme); }
private void Black_Click(object sender, RoutedEventArgs e) { PaletteHelper paletteHelper = new PaletteHelper(); Color primaryColor = Colors.Black; Color secondaryColor = Colors.Black; IBaseTheme baseTheme = Theme.Light; ITheme theme = Theme.Create(baseTheme, primaryColor, secondaryColor); paletteHelper.SetTheme(theme); }
public static void SetTheme(bool isDark) { PaletteHelper paletteHelper = new PaletteHelper(); ITheme theme = paletteHelper.GetTheme(); IBaseTheme baseTheme = isDark ? (IBaseTheme) new MaterialDesignDarkTheme() : (IBaseTheme) new MaterialDesignLightTheme(); theme.SetBaseTheme(baseTheme); paletteHelper.SetTheme(theme); Settings.Default.isDarkTheme = isDark; }
public static void ChangeTheme(bool isDark, Color color) { IBaseTheme baseTheme = AWTheme.Light; if (isDark) { baseTheme = AWTheme.Dark; } ITheme theme = Theme.Create(baseTheme, color, color); new PaletteHelper().SetTheme(theme); }
public static void SetTheme(bool themeIsDark) { Settings.Default.MainWindowSettings.ThemeIsDark = themeIsDark; Settings.Default.Save(); PaletteHelper _paletteHelper = new PaletteHelper(); ITheme theme = _paletteHelper.GetTheme(); IBaseTheme baseTheme = themeIsDark ? new MaterialDesignDarkTheme() : (IBaseTheme) new MaterialDesignLightTheme(); theme.SetBaseTheme(baseTheme); _paletteHelper.SetTheme(theme); Logger.Log.Info($"Set dark theme: {themeIsDark}"); }
public MyProfile() { InitializeComponent(); IBaseTheme baseTheme = Theme.Light; string fname = Users.fname; string lname = Users.lname; string username = Users.username; int user_id = Users.userId; txtFirstName.Text = fname; txtLastName.Text = lname; txtUsername.Text = username; }
public static Theme Create(IBaseTheme baseTheme, Color primary, Color accent) { if (baseTheme is null) { throw new ArgumentNullException(nameof(baseTheme)); } var theme = new Theme(); theme.SetBaseTheme(baseTheme); theme.SetPrimaryColor(primary); theme.SetSecondaryColor(accent); return(theme); }
public MainWindow() { InitializeComponent(); overtoggle.IsChecked = Properties.Settings.Default.overing; theme.IsChecked = Properties.Settings.Default.theme; toggle.IsChecked = Properties.Settings.Default.txtdel; PrimaryColor primary = PrimaryColor.DeepPurple; Color primaryColor = SwatchHelper.Lookup[(MaterialDesignColor)primary]; SecondaryColor secondary = SecondaryColor.Teal; Color secondaryColor = SwatchHelper.Lookup[(MaterialDesignColor)secondary]; IBaseTheme baseTheme = Theme.Light; ITheme themee = Theme.Create(baseTheme, primaryColor, secondaryColor); }
//TOGGLEBASECOLOUR METHOD (LIGHT/DARK THEME) public static void ToggleBaseColour(bool isDark) { //GET THE THEME ITheme theme = paletteHelper.GetTheme(); //CREATE A BASE THEME BASED ON THE ISDARK PROPERTY IBaseTheme baseTheme = isDark ? new MaterialDesignDarkTheme() : (IBaseTheme) new MaterialDesignLightTheme(); //SET THE BASE THEME (LIGHT/DARK) theme.SetBaseTheme(baseTheme); //UPDATE THE THEME (REALTIME) paletteHelper.SetTheme(theme); }
private void SaveSettings() { manifest = Manifest.GetManifest(); manifest.PeriodicChecking = (bool)chkPeriodicChecking.IsChecked; manifest.PeriodicCheckingInterval = InteravalValue; manifest.AutoConfirmMarketTransactions = (bool)chkAutoConfirm_Market.IsChecked; manifest.AutoConfirmTrades = (bool)chkAutoConfirm_Trades.IsChecked; manifest.AutoEntry = (bool)chkAutoEntry.IsChecked; manifest.AutoRefreshSession = (bool)chkAutoRefreshSession.IsChecked; manifest.CheckForUpdates = (bool)chkAutoCheckForUpdates.IsChecked; manifest.AllowBetaUpdates = (bool)chkAllowBetaUpdates.IsChecked; manifest.DeveloperMode = (bool)chkDevMode.IsChecked; manifest.DisplaySearch = (bool)chkDisplaySearch.IsChecked; //manifest.SortAlpha = (bool)chkSortAlpha.IsChecked; IBaseTheme themeBase = Theme.Dark; if (radLightTheme.IsChecked == true) { themeBase = Theme.Light; } manifest.BaseTheme = themeBase; // apply the new theme Color primaryColor = manifest.PrimaryColor; Color secondaryColor = manifest.AccentColor; IBaseTheme baseTheme = manifest.BaseTheme; ITheme theme = Theme.Create(baseTheme, primaryColor, secondaryColor); PaletteHelper pHelper = new PaletteHelper(); pHelper.SetTheme(theme); // okay we good manifest.Save(); LoadSettings(); }
/// <summary> /// Switches the theme via some resource dictionary hackery /// </summary> /// <param name="primaryColor">Primary color brush</param> /// <param name="secondaryColor">Secondary color brush</param> /// <param name="darkMode">Application theme</param> public static void SwitchTheme(string primaryColor, string secondaryColor, bool darkMode) { try { IBaseTheme baseTheme = darkMode ? Theme.Dark : Theme.Light; Color pColor = primaryColor == "Default" ? Color.FromRgb(147, 91, 249) : (Color)ColorConverter.ConvertFromString(primaryColor); Color sColor = primaryColor == "Default" ? Color.FromRgb(114, 124, 245) : (Color)ColorConverter.ConvertFromString(secondaryColor); ITheme theme = Theme.Create(baseTheme, pColor, sColor); ResourceDictionaryExtensions.SetTheme(Application.Current.Resources, theme); } catch (Exception e) { logger.Write(e.ToString()); MessageBox.Show("Something went wrong when processing theme settings, please report this exception, and the log file to LightVPN support.", "LightVPN", MessageBoxButton.OK, MessageBoxImage.Error); Application.Current.Shutdown(); return; } }
private static void AssertThemeColorsReadFromXaml(IBaseTheme baseTheme, string xaml) { var resourceDictionary = new ResourceDictionary(); resourceDictionary.MergedDictionaries.Add(MdixHelper.GetResourceDictionary(xaml)); resourceDictionary.MergedDictionaries.Add(MdixHelper.GetPrimaryColorResourceDictionary("DeepPurple")); resourceDictionary.MergedDictionaries.Add(MdixHelper.GetSecondaryColorResourceDictionary("Lime")); ITheme theme = resourceDictionary.GetTheme(); foreach (var property in theme.GetType().GetProperties().Where(p => p.PropertyType == typeof(Color))) { var propertyColor = (Color)property.GetValue(theme) !; var(nameBrush, nameColor) = property.Name == "ValidationError" ? ("MaterialDesignValidationErrorBrush", "MaterialDesignValidationErrorColor") : ("MaterialDesign" + property.Name, "MaterialDesign" + property.Name + "Color"); var xamlColor = ((SolidColorBrush)resourceDictionary[nameBrush]).Color; Assert.Equal(xamlColor, propertyColor); } }
/// <summary> /// Sets current theme /// </summary> /// <param name="theme">New theme</param> /// <returns><see cref="BaseTheme"/> that was set</returns> internal static BaseTheme SetTheme(Theme theme) { IBaseTheme baseTheme = theme switch { Theme.Dark => new MaterialDesignDarkTheme(), _ => new MaterialDesignLightTheme() as IBaseTheme }; ITheme itheme = new MaterialDesignThemes.Wpf.Theme(); itheme.SetBaseTheme(baseTheme); itheme.SetPrimaryColor(SwatchHelper.Lookup[MaterialDesignColor.Cyan]); //itheme.SetSecondaryColor(SwatchHelper.Lookup[MaterialDesignColor.Teal]); PaletteHelper paletteHelper = new PaletteHelper(); paletteHelper.SetTheme(itheme); return(theme switch { Theme.Dark => BaseTheme.Dark, _ => BaseTheme.Light });
public static void ChangeTheme(IBaseTheme theme, Color primary, Color secondary) { ResourceDictionaryExtensions.SetTheme(Application.Current.Resources, Theme.Create(theme, primary, secondary)); }
public Login() { InitializeComponent(); IBaseTheme baseTheme = Theme.Light; }