Beispiel #1
0
 internal void StyleBuilderRegistered(StyleBuilderRegistration styleBuilder)
 {
     if (this.colorBlendParameterNames.Count > 0)
     {
         foreach (KeyValuePair <string, HslColor> value in this.colorBlendParameterNames)
         {
             this.ApplyColorBlendToStyle(value.Key, value.Value, styleBuilder);
         }
     }
 }
        /// <summary>
        /// Registers a StyleSheet found in styleBuilderRegistration using also the registration details specified under the theme name specified.
        /// </summary>
        /// <param name="styleBuilderRegistration"></param>
        /// <param name="themeName"></param>
        public static void RegisterStyleBuilder(StyleBuilderRegistration styleBuilderRegistration, string themeName)
        {
            foreach (RadStylesheetRelation relation in styleBuilderRegistration.StylesheetRelations)
            {
                switch (relation.RegistrationType)
                {
                case BuilderRegistrationType.ElementTypeDefault:
                    ThemeResolutionService.RegisterElementTypeDefaultStyleBuilder(
                        themeName, relation.ElementType, styleBuilderRegistration.Builder);
                    break;

                case BuilderRegistrationType.ElementTypeControlType:
                    ThemeResolutionService.RegisterControlStyleBuilder(
                        relation.ControlType,
                        relation.ElementType,
                        styleBuilderRegistration.Builder,
                        themeName);
                    break;

                /*case BuilderRegistrationType.ElementNameControlType:
                 * ThemeResolutionService.RegisterControlStyleBuilder(
                 * styleBuilderRegistration.ControlType,
                 * styleBuilderRegistration.ElementName,
                 * styleBuilderRegistration.Builder,
                 * themeName);
                 * break;*/
                case BuilderRegistrationType.ElementTypeControlName:
                    ThemeResolutionService.RegisterStyleBuilderByControlName(
                        relation.ControlName,
                        relation.ElementType,
                        styleBuilderRegistration.Builder,
                        themeName);
                    break;    /*
                               * case BuilderRegistrationType.ElementNameControlName:
                               *        ThemeResolutionService.RegisterControlStyleBuilder(
                               *                styleBuilderRegistration.ControlName,
                               *                styleBuilderRegistration.ElementName,
                               *                styleBuilderRegistration.Builder,
                               *                themeName);
                               *        break;*/
                }
            }

            EnsureThemeRegistered(themeName);
            GetTheme(themeName).StyleBuilderRegistered(styleBuilderRegistration);
        }
        public XmlStyleBuilderRegistration(StyleBuilderRegistration toCopyFrom)
        {
            this.BuilderType = toCopyFrom.Builder.GetType();
            this.BuilderData = toCopyFrom.Builder.BuilderData;

            foreach (RadStylesheetRelation relationToCopy in toCopyFrom.StylesheetRelations)
            {
                RadStylesheetRelation relation = new RadStylesheetRelation();

                relation.RegistrationType = relationToCopy.RegistrationType;
                relation.ControlName      = relationToCopy.ControlName;
                relation.ControlType      = relationToCopy.ControlType;
                relation.ElementName      = relationToCopy.ElementName;
                relation.ElementType      = relationToCopy.ElementType;

                this.StylesheetRelations.Add(relation);
            }
        }
        private static void AddBuilderToList(ArrayList res, StyleBuilder builder, BuilderRegistrationType regType, string elementType, string controlType, string elementName, string controlName)
        {
            bool found = false;

            foreach (StyleBuilderRegistration reg in res)
            {
                if (reg.Builder == builder)
                {
                    RadStylesheetRelation relation = new RadStylesheetRelation(
                        regType, elementType, controlType, elementName, controlName);
                    reg.StylesheetRelations.Add(relation);
                    found = true;
                }
            }

            if (!found)
            {
                StyleBuilderRegistration registration = new StyleBuilderRegistration(
                    regType, elementType, controlType, elementName, controlName, builder);
                res.Add(registration);
            }
        }
        /// <summary>
        /// Retrieves the style builder registration.
        /// </summary>
        /// <returns></returns>
        public StyleBuilderRegistration GetRegistration()
        {
            Type actualBuilderType = typeof(DefaultStyleBuilder);

            if (this.BuilderType != null)
            {
                actualBuilderType = this.BuilderType;
            }

            StyleBuilder builder = (StyleBuilder)Activator.CreateInstance(actualBuilderType);

            builder.BuilderData = this.BuilderData;

            StyleBuilderRegistration reg = new StyleBuilderRegistration(
                builder
                );

            foreach (RadStylesheetRelation relation in this.StylesheetRelations)
            {
                string actualElementType = relation.ElementType;

                if (relation.RegistrationType == BuilderRegistrationType.ElementTypeControlType &&
                    relation.ElementType == null)
                {
                    actualElementType = typeof(RootRadElement).FullName;
                }

                reg.AddStylesheetRelation(relation.RegistrationType,
                                          actualElementType,
                                          relation.ControlType,
                                          relation.ElementName,
                                          relation.ControlName);
            }

            return(reg);
        }
        /// <summary>
        /// Gets all StyleSheets registered under a theme name.
        /// </summary>
        /// <param name="themeName"></param>
        /// <returns></returns>
        public static StyleBuilderRegistration[] GetStyleSheetBuilders(string themeName)
        {
            if (string.IsNullOrEmpty(themeName))
            {
                themeName = ControlDefaultThemeName;
            }

            ArrayList res = new ArrayList();

            foreach (DictionaryEntry entry in registeredBuildersDefaultByElementType)
            {
                TripleNameKey key = (TripleNameKey)entry.Key;
                if (string.Compare(key.Name2, themeName, true) == 0)
                {
                    StyleBuilder builder = (StyleBuilder)entry.Value;


                    BuilderRegistrationType regType = BuilderRegistrationType.ElementTypeDefault;
                    string elementType = key.Name3;
                    string controlType = null;
                    string elementName = null;
                    string controlName = null;

                    AddBuilderToList(res, builder, regType, elementType, controlType, elementName, controlName);
                }
            }

            foreach (DictionaryEntry entry in registeredBuildersByElementTypeControlType)
            {
                TripleNameKey key = (TripleNameKey)entry.Key;
                if (string.Compare(key.Name3, themeName, true) == 0)
                {
                    StyleBuilder            builder = (StyleBuilder)entry.Value;
                    BuilderRegistrationType regType = BuilderRegistrationType.ElementTypeControlType;
                    string elementType = key.Name2;
                    string controlType = key.Name1;
                    string elementName = null;
                    string controlName = null;

                    AddBuilderToList(res, builder, regType, elementType, controlType, elementName, controlName);
                }
            }

            foreach (DictionaryEntry entry in registeredBuildersName)
            {
                string key = (string)entry.Key;
                if (string.Compare(key, themeName, true) == 0)
                {
                    StyleBuilder            builder = (StyleBuilder)entry.Value;
                    BuilderRegistrationType regType = BuilderRegistrationType.ElementTypeGlobal;
                    string elementType = null;
                    string controlType = null;
                    string elementName = null;
                    string controlName = null;

                    AddBuilderToList(res, builder, regType, elementType, controlType, elementName, controlName);
                }
            }

            StyleBuilderRegistration[] resArray = new StyleBuilderRegistration[res.Count];
            res.CopyTo(resArray, 0);

            return(resArray);
        }
Beispiel #7
0
        private void ApplyColorBlendToStyle(string themeParameterName, HslColor baseColor, StyleBuilderRegistration registration)
        {
            PartiallyLoadableStyleSheet partiallyLoaded = ((DefaultStyleBuilder)registration.Builder).Style as PartiallyLoadableStyleSheet;

            //delay applying of color blend, to the moment stylesheet is requested by a control
            if (partiallyLoaded != null && !partiallyLoaded.IsLoadedCompletely)
            {
                PartiallyLoadedStyleSheetHelper helper =
                    new PartiallyLoadedStyleSheetHelper(partiallyLoaded, this, baseColor, themeParameterName);

                this.partiallyLoadedHelpers[partiallyLoaded] = helper;

                return;
            }

            StyleSheet style = ((DefaultStyleBuilder)registration.Builder).Style;

            ApplyColorBlendToStyleSheet(baseColor, themeParameterName, this, style);
        }