Example #1
0
        private static object GetRelativeColorDef(IPropertiesProvider propertiesProvider, string themeParameterName, HslColor baseHslColor, Color currentColor, IValueProvider originalValueProvider)
        {
            ColorBlendExtension extension = originalValueProvider as ColorBlendExtension;

            if (extension == null)
            {
                return(new ColorBlendExtension(propertiesProvider, themeParameterName, baseHslColor, currentColor, currentColor));
            }
            else
            {
                return(new ColorBlendExtension(propertiesProvider, themeParameterName, baseHslColor, currentColor, extension.OriginalColor));
            }
        }
Example #2
0
            public PartiallyLoadedStyleSheetHelper(PartiallyLoadableStyleSheet plSS, Theme theme, HslColor baseColor, string themeParameterName)
            {
                this.theme              = theme;
                this.baseColor          = baseColor;
                this.themeParameterName = themeParameterName;

                plSS.LoadedCompletely += plSS_LoadedCompletely;
            }
Example #3
0
        public static void ApplyColorBlendToGroups(PropertySettingGroupCollection groups, HslColor baseColor, string themeParameterName, IPropertiesProvider propertiesProvider)
        {
            foreach (PropertySettingGroup group in groups)
            {
                foreach (IPropertySetting setting in group.PropertySettings)
                {
                    RadProperty prop = setting.Property;
                    if (prop.PropertyType == typeof(Color))
                    {
                        if (setting is AnimatedPropertySetting)
                        {
                            AnimatedPropertySetting animatedSetting = (AnimatedPropertySetting)setting;

                            object value = animatedSetting.StartValue;
                            if (value != null)
                            {
                                Color color = (Color)value;
                                if (ShouldApplyBaseColor(baseColor, color))
                                {
                                    object relativeColorDef =
                                        GetRelativeColorDef(propertiesProvider, themeParameterName, baseColor, color,
                                                            animatedSetting.GetStartValueProvider());
                                    animatedSetting.StartValue = relativeColorDef;
                                }
                            }

                            object endValue = animatedSetting.EndValue;
                            if (endValue != null)
                            {
                                Color color = (Color)endValue;
                                if (ShouldApplyBaseColor(baseColor, color))
                                {
                                    animatedSetting.EndValue =
                                        GetRelativeColorDef(propertiesProvider, themeParameterName, baseColor, color,
                                                            animatedSetting.GetEndValueProvider());
                                }
                            }
                        }
                        else //actualSetting is PropertySetting
                        {
                            PropertySetting propertySetting = (PropertySetting)setting;
                            object          value           = propertySetting.Value;
                            if (value != null)
                            {
                                Color color = (Color)value;
                                if (ShouldApplyBaseColor(baseColor, color))
                                {
                                    propertySetting.Value =
                                        GetRelativeColorDef(propertiesProvider, themeParameterName, baseColor, color,
                                                            propertySetting.GetValueProvider());
                                }
                            }
                        }
                    }
                }
            }
        }
Example #4
0
        //public static void ApplyColorBlendToStyle(HslColor baseColor, string themeParameterName, StyleSheet style)
        //{
        //    PropertySettingGroupCollection groups = style.PropertySettingGroups;
        //    ApplyColorBlendToGroups(groups, baseColor, themeParameterName);
        //}

        public void ApplyColorBlendToGroups(PropertySettingGroupCollection groups, HslColor baseColor, string themeParameterName)
        {
            ApplyColorBlendToGroups(groups, baseColor, themeParameterName, this);
        }
Example #5
0
        public static void ApplyColorBlendToStyleSheet(HslColor baseColor, string themeParameterName, IPropertiesProvider propertiesProvider, StyleSheet style)
        {
            PropertySettingGroupCollection groups = style.PropertySettingGroups;

            ApplyColorBlendToGroups(groups, baseColor, themeParameterName, propertiesProvider);
        }
Example #6
0
 /// <summary>
 /// Applys color blend to all colors in the current theme, based on the given baseColor and notifies all controls that theme has changed. ThemeNameParameter will be
 /// automatically added to the <see cref="ThemeProperties"/> collection.
 /// </summary>
 /// <remarks>
 /// When AddColorBlend is used, themeparamter will be added to ThemeProperties collection. Then the theme will be processed and
 /// color values will be substituted by the value of ThemeParameter specified.
 /// Changing the value of the theme parameter will allow you to dynamically modify the HSL components
 /// of the corresponding color values.
 /// </remarks>
 /// <param name="themeParameterName">theme parameter name to be populated</param>
 /// <param name="baseColor">THe Hue setting of the base color will be used to determine wich colours will be affected by the colorblend. L and S values of the color will be used to calculate new color values</param>
 public void AddColorBlend(string themeParameterName, HslColor baseColor)
 {
     this.AddColorBlend(themeParameterName, baseColor, true);
 }