Exemplo n.º 1
0
        private ResourceDictionary LoadResource(ThemeStyle style)
        {
            var res = new ResourceDictionary();

            res.Source = GetResourceUri(style);
            return(res);
        }
Exemplo n.º 2
0
        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()));
 }
Exemplo n.º 4
0
        public virtual void UpdateResources(ThemeStyle style)
        {
            RemovePreviousStyle(GetOtherStyle(style));

            // apply new style
            var res = LoadResource(style);

            Application.Current.Resources.MergedDictionaries.Add(res);
        }
Exemplo n.º 5
0
                public static Color Normal(ThemeStyle theme)
                {
                    if (theme == ThemeStyle.Dark)
                    {
                        return(Color.FromArgb(153, 153, 153));
                    }

                    return(Color.FromArgb(153, 153, 153));
                }
Exemplo n.º 6
0
                    public static Color Normal(ThemeStyle theme)
                    {
                        if (theme == ThemeStyle.Dark)
                        {
                            return(Color.FromArgb(51, 51, 51));
                        }

                        return(Color.FromArgb(221, 221, 221));
                    }
Exemplo n.º 7
0
            public static Color Form(ThemeStyle theme)
            {
                if (theme == ThemeStyle.Dark)
                {
                    return(Color.FromArgb(68, 68, 68));
                }

                return(Color.FromArgb(204, 204, 204));
            }
Exemplo n.º 8
0
                    public static Color Disabled(ThemeStyle theme)
                    {
                        if (theme == ThemeStyle.Dark)
                        {
                            return(Color.FromArgb(34, 34, 34));
                        }

                        return(Color.FromArgb(230, 230, 230));
                    }
Exemplo n.º 9
0
                public static Color Press(ThemeStyle theme)
                {
                    if (theme == ThemeStyle.Dark)
                    {
                        return(Color.FromArgb(238, 238, 238));
                    }

                    return(Color.FromArgb(51, 51, 51));
                }
Exemplo n.º 10
0
                    public static Color Press(ThemeStyle theme)
                    {
                        if (theme == ThemeStyle.Dark)
                        {
                            return(Color.FromArgb(204, 204, 204));
                        }

                        return(Color.FromArgb(96, 96, 96));
                    }
Exemplo n.º 11
0
                public static Color Press(ThemeStyle theme)
                {
                    if (theme == ThemeStyle.Dark)
                    {
                        return(Color.FromArgb(255, 255, 255));
                    }

                    return(Color.FromArgb(255, 255, 255));
                }
Exemplo n.º 12
0
                public static Color Press(ThemeStyle theme)
                {
                    if (theme == ThemeStyle.Dark)
                    {
                        return(Color.FromArgb(93, 93, 93));
                    }

                    return(Color.FromArgb(128, 128, 128));
                }
Exemplo n.º 13
0
                public static Color Normal(ThemeStyle theme)
                {
                    if (theme == ThemeStyle.Dark)
                    {
                        return(Color.FromArgb(204, 204, 204));
                    }

                    return(Color.FromArgb(0, 0, 0));
                }
Exemplo n.º 14
0
            public static Color Title(ThemeStyle theme)
            {
                if (theme == ThemeStyle.Dark)
                {
                    return(Color.FromArgb(255, 255, 255));
                }

                return(Color.FromArgb(0, 0, 0));
            }
Exemplo n.º 15
0
                public static Color Disabled(ThemeStyle theme)
                {
                    if (theme == ThemeStyle.Dark)
                    {
                        return(Color.FromArgb(93, 93, 93));
                    }

                    return(Color.FromArgb(136, 136, 136));
                }
Exemplo n.º 16
0
                    public static Color Hover(ThemeStyle theme)
                    {
                        if (theme == ThemeStyle.Dark)
                        {
                            return(Color.FromArgb(38, 38, 38));
                        }

                        return(Color.FromArgb(234, 234, 234));
                    }
Exemplo n.º 17
0
                public static Color Hover(ThemeStyle theme)
                {
                    if (theme == ThemeStyle.Dark)
                    {
                        return(Color.FromArgb(170, 170, 170));
                    }

                    return(Color.FromArgb(17, 17, 17));
                }
Exemplo n.º 18
0
                public static Color Disabled(ThemeStyle theme)
                {
                    if (theme == ThemeStyle.Dark)
                    {
                        return(Color.FromArgb(109, 109, 109));
                    }

                    return(Color.FromArgb(155, 155, 155));
                }
Exemplo n.º 19
0
                    public static Color Hover(ThemeStyle theme)
                    {
                        if (theme == ThemeStyle.Dark)
                        {
                            return(Color.FromArgb(51, 51, 51));
                        }

                        return(Color.FromArgb(204, 204, 204));
                    }
Exemplo n.º 20
0
                public static Color Disabled(ThemeStyle theme)
                {
                    if (theme == ThemeStyle.Dark)
                    {
                        return(Color.FromArgb(51, 51, 51));
                    }

                    return(Color.FromArgb(209, 209, 209));
                }
Exemplo n.º 21
0
                    public static Color Disabled(ThemeStyle theme)
                    {
                        if (theme == ThemeStyle.Dark)
                        {
                            return(Color.FromArgb(85, 85, 85));
                        }

                        return(Color.FromArgb(179, 179, 179));
                    }
Exemplo n.º 22
0
                public static Color Disabled(ThemeStyle theme)
                {
                    if (theme == ThemeStyle.Dark)
                    {
                        return(Color.FromArgb(80, 80, 80));
                    }

                    return(Color.FromArgb(204, 204, 204));
                }
Exemplo n.º 23
0
                public static Color Normal(ThemeStyle theme)
                {
                    if (theme == ThemeStyle.Dark)
                    {
                        return(Color.FromArgb(34, 34, 34));
                    }

                    return(Color.FromArgb(238, 238, 238));
                }
Exemplo n.º 24
0
            public static Color Form(ThemeStyle theme)
            {
                if (theme == ThemeStyle.Dark)
                {
                    return(Color.FromArgb(17, 17, 17));
                }

                return(Color.FromArgb(255, 255, 255));
            }
Exemplo n.º 25
0
        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);
            }
        }
Exemplo n.º 26
0
        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);
            }
        }
Exemplo n.º 27
0
        private Uri GetResourceUri(ThemeStyle style)
        {
            string path = "";

            if (style == ThemeStyle.Light)
            {
                path = LightStyleResource;
            }
            else
            {
                path = DarkStyleResource;
            }

            return(new Uri(path, UriKind.Relative));
        }
Exemplo n.º 28
0
 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()));
     }
 }
Exemplo n.º 29
0
        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;
        }