예제 #1
0
        private static Tuple <AppTheme, Accent> DetectAppStyle(ResourceDictionary resources)
        {
            if (resources == null)
            {
                throw new ArgumentNullException("resources");
            }
            AppTheme appTheme = null;
            Tuple <AppTheme, Accent> tuple = null;

            if (!ThemeManager.DetectThemeFromResources(ref appTheme, resources) || !ThemeManager.GetThemeFromResources(appTheme, resources, ref tuple))
            {
                return(null);
            }
            return(new Tuple <AppTheme, Accent>(tuple.Item1, tuple.Item2));
        }
예제 #2
0
        private static bool DetectThemeFromResources(ref AppTheme detectedTheme, ResourceDictionary dict)
        {
            IEnumerator <ResourceDictionary> enumerator = dict.MergedDictionaries.GetEnumerator();

            while (enumerator.MoveNext())
            {
                ResourceDictionary current   = enumerator.Current;
                AppTheme           appTheme  = ThemeManager.GetAppTheme(current);
                AppTheme           appTheme1 = appTheme;
                if (appTheme != null)
                {
                    detectedTheme = appTheme1;
                    enumerator.Dispose();
                    return(true);
                }
                if (!ThemeManager.DetectThemeFromResources(ref detectedTheme, current))
                {
                    continue;
                }
                return(true);
            }
            enumerator.Dispose();
            return(false);
        }
예제 #3
0
 internal static bool DetectThemeFromAppResources(out AppTheme detectedTheme)
 {
     detectedTheme = null;
     return(ThemeManager.DetectThemeFromResources(ref detectedTheme, Application.Current.Resources));
 }