예제 #1
0
        public ThemeManagerStyle GetThemeStyle(Type targetType)
        {
            var themeStyle = _themeManagerStyles.GetValueOrDefault(targetType);

            if (themeStyle != null)
            {
                return(themeStyle);
            }

            themeStyle = CreateThemeStyle(targetType);

            var rootType = DefaultStyleKeyHelper.GetDefaultStyleKeyType(targetType);
            var current  = themeStyle;

            while (targetType != null && targetType != rootType)
            {
                targetType = targetType.BaseType;
                rootType   = DefaultStyleKeyHelper.GetDefaultStyleKeyType(targetType);

                var style = _themeManagerStyles.GetValueOrDefault(targetType);

                if (style != null)
                {
                    current.BindThemeManagerStyle(style);

                    break;
                }

                style = CreateThemeStyle(targetType);
                current.BindThemeManagerStyle(style);
                current = style;
            }

            return(themeStyle);
        }
예제 #2
0
파일: ThemeKey.WPF.cs 프로젝트: Egaros/lib
        internal static Type GetDefaultType(FrameworkElement fre)
        {
            var elementType = fre.GetType();

            if (DefaultStyleKeyHelper.IsItsOwnDefaultStyleKey(elementType))
            {
                return(elementType);
            }

            var defKey = fre.GetValue(DefaultStyleKeyHelper.DefaultStyleKeyProperty);

            if (defKey is ThemeKey themeKey)
            {
                return(themeKey.ElementType);
            }

            return(defKey as Type ?? elementType);
        }