Esempio n. 1
0
        // 生成随机颜色名称
        private string RandomAccent()
        {
            Array      values       = Enum.GetValues(typeof(AccentEnum));
            Random     random       = new Random();
            AccentEnum randomAccent = (AccentEnum)values.GetValue(random.Next(values.Length));

            lastAccent = randomAccent.ToString();
            return(lastAccent);
        }
Esempio n. 2
0
        public static void ApplyAccent(AccentEnum accent)
        {
            if (_currentAccent == accent)
            {
                return;
            }

            var newAccentDictionary = new AccentResourceDictionary
            {
                Source = new Uri($"/Launcher.Theme;component/Accents/{accent}.xaml", UriKind.Relative)
            };

            _entryPoint.MergedDictionaries.Insert(0, newAccentDictionary);
            _entryPoint.MergedDictionaries.Remove(_currentAccentDictionary);

            _currentAccentDictionary = newAccentDictionary;
            _currentAccent           = accent;
        }