コード例 #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);
        }