private ResourceDictionary LoadResource(ThemeStyle style) { var res = new ResourceDictionary(); res.Source = GetResourceUri(style); return(res); }
public void ShouldSetThemeBasedOnTime(int inputHour, ThemeStyle expectedTheme) { // input var inputDate = new System.DateTime(2015, 1, 1, inputHour, 0, 0); // mock var context = new ApplicationContext(); var mockClock = new Mock <Clock>(context) { CallBase = true }; mockClock.Setup(x => x.CurrentTime).Returns(inputDate); var mockTheme = new Mock <Theme>(context) { CallBase = true }; mockTheme.Setup(x => x.UpdateResources(It.IsAny <ThemeStyle>())); // setup with no implementation = dont run anything // work context.Clock = mockClock.Object; context.Environment = new Environment(context); context.Theme = mockTheme.Object; context.Theme.Initialise(); // compare var actualTheme = context.Theme.Current; Assert.AreEqual(expectedTheme, actualTheme); }
/// <summary> /// Change app theme /// </summary> /// <param name="accent">Accent</param> /// <param name="style">New theme</param> public void ChangeAppStyle(MahApps.Metro.Accent accent, ThemeStyle style) { // set the accent and theme to the window MahApps.Metro.ThemeManager.ChangeAppStyle(Application.Current, MahApps.Metro.ThemeManager.GetAccent(accent.Name), MahApps.Metro.ThemeManager.GetAppTheme(style.ToString())); }
public virtual void UpdateResources(ThemeStyle style) { RemovePreviousStyle(GetOtherStyle(style)); // apply new style var res = LoadResource(style); Application.Current.Resources.MergedDictionaries.Add(res); }
public static Color Normal(ThemeStyle theme) { if (theme == ThemeStyle.Dark) { return(Color.FromArgb(153, 153, 153)); } return(Color.FromArgb(153, 153, 153)); }
public static Color Normal(ThemeStyle theme) { if (theme == ThemeStyle.Dark) { return(Color.FromArgb(51, 51, 51)); } return(Color.FromArgb(221, 221, 221)); }
public static Color Form(ThemeStyle theme) { if (theme == ThemeStyle.Dark) { return(Color.FromArgb(68, 68, 68)); } return(Color.FromArgb(204, 204, 204)); }
public static Color Disabled(ThemeStyle theme) { if (theme == ThemeStyle.Dark) { return(Color.FromArgb(34, 34, 34)); } return(Color.FromArgb(230, 230, 230)); }
public static Color Press(ThemeStyle theme) { if (theme == ThemeStyle.Dark) { return(Color.FromArgb(238, 238, 238)); } return(Color.FromArgb(51, 51, 51)); }
public static Color Press(ThemeStyle theme) { if (theme == ThemeStyle.Dark) { return(Color.FromArgb(204, 204, 204)); } return(Color.FromArgb(96, 96, 96)); }
public static Color Press(ThemeStyle theme) { if (theme == ThemeStyle.Dark) { return(Color.FromArgb(255, 255, 255)); } return(Color.FromArgb(255, 255, 255)); }
public static Color Press(ThemeStyle theme) { if (theme == ThemeStyle.Dark) { return(Color.FromArgb(93, 93, 93)); } return(Color.FromArgb(128, 128, 128)); }
public static Color Normal(ThemeStyle theme) { if (theme == ThemeStyle.Dark) { return(Color.FromArgb(204, 204, 204)); } return(Color.FromArgb(0, 0, 0)); }
public static Color Title(ThemeStyle theme) { if (theme == ThemeStyle.Dark) { return(Color.FromArgb(255, 255, 255)); } return(Color.FromArgb(0, 0, 0)); }
public static Color Disabled(ThemeStyle theme) { if (theme == ThemeStyle.Dark) { return(Color.FromArgb(93, 93, 93)); } return(Color.FromArgb(136, 136, 136)); }
public static Color Hover(ThemeStyle theme) { if (theme == ThemeStyle.Dark) { return(Color.FromArgb(38, 38, 38)); } return(Color.FromArgb(234, 234, 234)); }
public static Color Hover(ThemeStyle theme) { if (theme == ThemeStyle.Dark) { return(Color.FromArgb(170, 170, 170)); } return(Color.FromArgb(17, 17, 17)); }
public static Color Disabled(ThemeStyle theme) { if (theme == ThemeStyle.Dark) { return(Color.FromArgb(109, 109, 109)); } return(Color.FromArgb(155, 155, 155)); }
public static Color Hover(ThemeStyle theme) { if (theme == ThemeStyle.Dark) { return(Color.FromArgb(51, 51, 51)); } return(Color.FromArgb(204, 204, 204)); }
public static Color Disabled(ThemeStyle theme) { if (theme == ThemeStyle.Dark) { return(Color.FromArgb(51, 51, 51)); } return(Color.FromArgb(209, 209, 209)); }
public static Color Disabled(ThemeStyle theme) { if (theme == ThemeStyle.Dark) { return(Color.FromArgb(85, 85, 85)); } return(Color.FromArgb(179, 179, 179)); }
public static Color Disabled(ThemeStyle theme) { if (theme == ThemeStyle.Dark) { return(Color.FromArgb(80, 80, 80)); } return(Color.FromArgb(204, 204, 204)); }
public static Color Normal(ThemeStyle theme) { if (theme == ThemeStyle.Dark) { return(Color.FromArgb(34, 34, 34)); } return(Color.FromArgb(238, 238, 238)); }
public static Color Form(ThemeStyle theme) { if (theme == ThemeStyle.Dark) { return(Color.FromArgb(17, 17, 17)); } return(Color.FromArgb(255, 255, 255)); }
private void Themes_SelectionChangeCommitted(object sender, EventArgs e) { ThemeStyle selectedTheme = (ThemeStyle)Enum.Parse(typeof(ThemeStyle), cbxThemes.SelectedItem.ToString()); SkinManager.Init(selectedTheme); Properties.Settings.Default.Theme = cbxThemes.SelectedItem.ToString(); if (ParentForm != null) { ParentForm.Invalidate(true); } }
private void RemovePreviousStyle(ThemeStyle newStyle) { var previousResUri = GetResourceUri(newStyle); var previousRes = Application.Current.Resources.MergedDictionaries .SingleOrDefault(x => x.Source == previousResUri); if (previousRes != null) { Application.Current.Resources.MergedDictionaries.Remove(previousRes); } }
private Uri GetResourceUri(ThemeStyle style) { string path = ""; if (style == ThemeStyle.Light) { path = LightStyleResource; } else { path = DarkStyleResource; } return(new Uri(path, UriKind.Relative)); }
private ThemeStyle GetOtherStyle(ThemeStyle style) { if (style == ThemeStyle.Light) { return(ThemeStyle.Dark); } else if (style == ThemeStyle.Dark) { return(ThemeStyle.Light); } else { throw new InvalidOperationException(String.Format("Unexpected style called on Theme.GetOtherStyle '0'", style.ToString())); } }
public Personalization() { InitializeComponent(); //Load Theme Style var _themeval = Enum.GetValues(typeof(ThemeStyle)).Cast <ThemeStyle>(); ThemeChooser.ItemsSource = _themeval.ToList(); Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; if (localSettings.Values["theme"] != null) { ThemeStyle _selectedTheme = localSettings.Values["theme"].ToString().Equals("Default") ? ThemeStyle.System : Enum.Parse <ThemeStyle>(localSettings.Values["theme"].ToString()); ThemeChooser.SelectedIndex = _themeval.ToList().IndexOf(_selectedTheme); ThemeChooser.Loaded += (s, e) => { ThemeChooser.SelectionChanged += async(s1, e1) => { localSettings.Values["theme"] = e1.AddedItems[0].Equals("System") ? "Default" : e1.AddedItems[0].ToString(); await RestartReminder.Fade(value : 1.0f, duration : 1500, delay : 0).StartAsync(); await RestartReminder.Fade(value : 0.0f, duration : 1500, delay : 0).StartAsync(); }; }; } //Load App Time Style var _dateformatval = Enum.GetValues(typeof(TimeStyle)).Cast <TimeStyle>(); DateFormatChooser.ItemsSource = _dateformatval.ToList(); if (localSettings.Values["datetimeformat"] != null) { TimeStyle _selectedFormat = Enum.Parse <TimeStyle>(localSettings.Values["datetimeformat"].ToString()); DateFormatChooser.SelectedIndex = _dateformatval.ToList().IndexOf(_selectedFormat); DateFormatChooser.Loaded += (s, e) => { DateFormatChooser.SelectionChanged += async(s1, e1) => { localSettings.Values["datetimeformat"] = e1.AddedItems[0].ToString(); TimeFormatReminder.Visibility = Visibility.Visible; await TimeFormatReminder.Fade(value : 1.0f, duration : 1500, delay : 0).StartAsync(); await TimeFormatReminder.Fade(value : 0.0f, duration : 1500, delay : 0).StartAsync(); }; }; } }
private void LoadAppearanceSettings() { var currentTheme = NeoTheme.Current; // Set theme style this.currentThemeStyle = currentTheme.Style; this.SelectedThemeStyle = currentTheme.Style; // Set color values, without transparency as these colors do not require transparency var accentBaseColorHex = ColorHelper.ColorToHex(currentTheme.AccentBaseColor); this.currentThemeAccentBaseColorHex = accentBaseColorHex; this.ThemeAccentBaseColorHex = accentBaseColorHex; var highlightColorHex = ColorHelper.ColorToHex(currentTheme.HighlightColor); this.currentThemeHighlightColorHex = highlightColorHex; this.ThemeHighlightColorHex = highlightColorHex; var windowBorderColorHex = ColorHelper.ColorToHex(currentTheme.WindowBorderColor); this.currentThemeWindowBorderColorHex = windowBorderColorHex; this.ThemeWindowBorderColorHex = windowBorderColorHex; }