Beispiel #1
0
        public void InheritRepositoryItem(Telerik.WinControls.Styles.XmlRepositoryItem newItem)
        {
            for (int i = 0; i < newItem.DeserializedPropertySettings.Count; i++)
            {
                IPropertySetting newSetting = newItem.DeserializedPropertySettings[i];

                bool found = false;
                for (int k = 0; k < this.propertySettings.OriginalPropertySettings.Count; k++)
                {
                    PropertySetting existingSetting = this.propertySettings.OriginalPropertySettings[k] as PropertySetting;

                    if (existingSetting != null &&
                        existingSetting.Property == newSetting.Property)
                    {
                        //Settingd defined in inherited groups beat those from repository, so no value copy
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    this.propertySettings.AddInheritedPropertySetting(newSetting, newItem.ItemType);
                }
            }
        }
Beispiel #2
0
        public void ApplyValue(RadObject element)
        {
            string propertyName = this.Name;

            if (this.PropertyMapper != null)
            {
                propertyName = this.PropertyMapper(propertyName, element);
            }
            if (this.property == null)
            {
                this.property = PropertySetting.FindProperty(element.GetType(), propertyName, true);
            }
            if (this.property != null && (!this.property.OwnerType.IsAssignableFrom(element.GetType()) || this.property.Name != propertyName))
            {
                this.property = PropertySetting.FindProperty(element.GetType(), propertyName, true);
            }
            if (this.property == null)
            {
                return;
            }
            if (this.endValue != null)
            {
                if (this.animatedSetting == null)
                {
                    this.animatedSetting            = new AnimatedPropertySetting();
                    this.animatedSetting.Property   = this.property;
                    this.animatedSetting.StartValue = this.value;
                    this.animatedSetting.EndValue   = this.endValue;
                }
                this.animatedSetting.IsStyleSetting = true;
                this.animatedSetting.Property       = this.property;
                this.animatedSetting.ApplyValue(element);
            }
            int num = (int)element.AddStylePropertySetting((IPropertySetting)this);
        }
Beispiel #3
0
 public ThemeSettingOverride(RadProperty property, object value, string visualState)
 {
     this.property        = property;
     this.visualState     = visualState;
     this.value           = value;
     this.propertySetting = new PropertySetting(this.property, this.value);
 }
Beispiel #4
0
        public override object Clone()
        {
            PropertySetting result = new PropertySetting(this.Property, this.Value);

            result.valueProviderHelper = this.valueProviderHelper;

            return(result);
        }
Beispiel #5
0
 private void EnsureSetting(string name, PropertySetting setting)
 {
     if (setting == null || this.FindSetting(name) != null)
     {
         return;
     }
     this.settings.Add(new PropertySetting(setting));
 }
Beispiel #6
0
        private PropertySetting ReadPropertySettingCore(
            Theme theme,
            XmlTextReader reader)
        {
            string          fullName        = "";
            string          str1            = "";
            string          str2            = "";
            PropertySetting propertySetting = new PropertySetting();

            while (reader.MoveToNextAttribute())
            {
                if (reader.Name == "Property")
                {
                    fullName = reader.Value;
                }
                else if (reader.Name == "Value")
                {
                    str1 = reader.Value;
                }
                else if (reader.Name == "EndValue")
                {
                    str2 = reader.Value;
                }
            }
            if (!string.IsNullOrEmpty(fullName))
            {
                try
                {
                    string[] strArray     = fullName.Split('.');
                    string   propertyName = "";
                    if (strArray.Length > 1)
                    {
                        propertyName = strArray[strArray.Length - 1];
                        string.Join(".", strArray, 0, strArray.Length - 1);
                    }
                    if (this.storeFullPropertyName)
                    {
                        propertySetting.FullName = fullName;
                    }
                    else
                    {
                        propertySetting.Name = propertyName;
                    }
                    if (!string.IsNullOrEmpty(str1))
                    {
                        propertySetting.Value = PropertyReader.Deserialize(fullName, propertyName, str1);
                    }
                    if (!string.IsNullOrEmpty(str2))
                    {
                        propertySetting.EndValue = PropertyReader.Deserialize(fullName, propertyName, str2);
                    }
                }
                catch (Exception ex)
                {
                }
            }
            return(propertySetting);
        }
Beispiel #7
0
        protected virtual PropertySetting CreatePropertySetting(CSSItem item)
        {
            if (item.childItems.Count <= 0)
            {
                return(new PropertySetting(item.name, PropertyReader.Deserialize(item.name, item.value)));
            }
            PropertySetting propertySetting = new PropertySetting(item.name, (object)null)
            {
                Value           = PropertyReader.Deserialize(item.name, item["Value"]),
                EndValue        = PropertyReader.Deserialize(item.name, item["EndValue"]),
                AnimatedSetting = new AnimatedPropertySetting()
            };

            propertySetting.AnimatedSetting.StartValue     = propertySetting.Value;
            propertySetting.AnimatedSetting.EndValue       = propertySetting.EndValue;
            propertySetting.AnimatedSetting.IsStyleSetting = true;
            if (item["MaxValue"] != null)
            {
                propertySetting.AnimatedSetting.MaxValue = PropertyReader.Deserialize(item.name, item["MaxValue"]);
            }
            string str1 = item["EasingType"];

            if (!string.IsNullOrEmpty(str1))
            {
                propertySetting.AnimatedSetting.ApplyEasingType = (RadEasingType)Enum.Parse(typeof(RadEasingType), str1);
            }
            string s1 = item["Interval"];

            if (!string.IsNullOrEmpty(s1))
            {
                propertySetting.AnimatedSetting.Interval = int.Parse(s1);
            }
            string s2 = item["Frames"];

            if (!string.IsNullOrEmpty(s2))
            {
                propertySetting.AnimatedSetting.NumFrames = int.Parse(s2);
            }
            string s3 = item["ApplyDelay"];

            if (!string.IsNullOrEmpty(s3))
            {
                propertySetting.AnimatedSetting.ApplyDelay = int.Parse(s3);
            }
            string s4 = item["RandomDelay"];

            if (!string.IsNullOrEmpty(s4))
            {
                propertySetting.AnimatedSetting.RandomDelay = int.Parse(s4);
            }
            string str2 = item["RemoveAfterApply"];

            if (!string.IsNullOrEmpty(str2))
            {
                propertySetting.AnimatedSetting.RemoveAfterApply = bool.Parse(str2);
            }
            return(propertySetting);
        }
Beispiel #8
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());
                                }
                            }
                        }
                    }
                }
            }
        }
        public virtual IPropertySetting Deserialize()
        {
            if (string.IsNullOrEmpty(this.Property))
            {
                throw new InvalidOperationException("Property to deserialize is null or empty");
            }
            PropertySetting propertySetting = new PropertySetting()
            {
                Property = XmlPropertySetting.DeserializeProperty(this.Property)
            };

            propertySetting.Value = this.GetConvertedValue(propertySetting.Property, this.Value);
            return((IPropertySetting)propertySetting);
        }
Beispiel #10
0
        internal ValueUpdateResult OnAnimationFinished(AnimatedPropertySetting setting)
        {
            RadPropertyValue entry = this.propertyValues.GetEntry(setting.Property, false);

            if (entry == null)
            {
                return(ValueUpdateResult.NotUpdated);
            }
            object      propModifier;
            ValueSource source;

            if (setting.IsStyleSetting)
            {
                propModifier = (object)setting;
                source       = ValueSource.Style;
            }
            else
            {
                propModifier = (object)null;
                source       = ValueSource.Animation;
            }
            if (setting.RemoveAfterApply && setting.IsStyleSetting)
            {
                IStylableNode stylableNode = this as IStylableNode;
                if (stylableNode != null && stylableNode.Style != null)
                {
                    foreach (PropertySettingGroup propertySettingGroup in stylableNode.Style.PropertySettingGroups)
                    {
                        foreach (PropertySetting propertySetting in propertySettingGroup.PropertySettings)
                        {
                            if (propertySetting.AnimatedSetting == setting)
                            {
                                propertySettingGroup.PropertySettings.Remove(propertySetting);
                                break;
                            }
                        }
                    }
                }
                PropertySetting propertySetting1 = new PropertySetting(setting.Property, setting.EndValue);
                return(this.SetValueCore(entry, (object)propertySetting1, propertySetting1.Value, source));
            }
            if (!setting.RemoveAfterApply)
            {
                return(ValueUpdateResult.UpdatedNotChanged);
            }
            return(this.SetValueCore(entry, propModifier, (object)null, source));
        }
Beispiel #11
0
        public virtual IPropertySetting Deserialize()
        {
            if (string.IsNullOrEmpty(this.Property))
            {
                throw new InvalidOperationException("Property to deserialize is null or empty");
            }

            PropertySetting setting = new PropertySetting();

            setting.Property = DeserializeProperty(this.Property);

            //In previous verions of this class, Value used to be stored as string and deserialized upon retrieval
            //Now Value is the actual object, not string, and deserialization is no longer needed, at least for value types that are stored in System or Telerik assemblies
            //For Types in other assemblies ValueAsString should be used
            setting.Value = this.GetConvertedValue(setting.Property, this.Value); //DeserializeValue(setting.Property, this.Value);

            return(setting);
        }
Beispiel #12
0
        private void ReadPropertySetting(ReaderContext context, XmlTextReader reader)
        {
            PropertySetting propertySetting = this.ReadPropertySettingCore(context.theme, reader);

            if (context.parentNode == "Telerik.WinControls.Styles.XmlRepositoryItem")
            {
                if (context.currentRepository == null)
                {
                    return;
                }
                context.currentRepository.Settings.Add(propertySetting);
            }
            else
            {
                if (!(context.parentNode == "PropertySettings") || context.currentSettingGroup == null)
                {
                    return;
                }
                context.currentSettingGroup.PropertySettings.Add(propertySetting);
            }
        }
Beispiel #13
0
 public PropertySetting(PropertySetting setting)
 {
     this.property = setting.property;
     this.name     = setting.name;
     this.fullName = setting.fullName;
     this.value    = setting.value;
     this.endValue = setting.endValue;
     if (setting.animatedSetting == null)
     {
         return;
     }
     this.animatedSetting                  = new AnimatedPropertySetting();
     this.animatedSetting.StartValue       = setting.animatedSetting.EndValue;
     this.animatedSetting.EndValue         = setting.animatedSetting.EndValue;
     this.animatedSetting.ApplyDelay       = setting.animatedSetting.ApplyDelay;
     this.animatedSetting.RemoveAfterApply = setting.animatedSetting.RemoveAfterApply;
     this.animatedSetting.Step             = setting.animatedSetting.Step;
     this.animatedSetting.NumFrames        = setting.animatedSetting.NumFrames;
     this.animatedSetting.Interval         = setting.animatedSetting.Interval;
     this.animatedSetting.RandomDelay      = setting.animatedSetting.RandomDelay;
 }
Beispiel #14
0
        public void Initialize()
        {
            bool            flag     = true;
            PropertySetting setting1 = this.FindSetting("Visibility");

            if (setting1 != null)
            {
                flag = (ElementVisibility)setting1.Value == ElementVisibility.Visible;
            }
            if (this.ItemType == "Gradient")
            {
                PropertySetting setting2 = this.FindSetting("DrawFill");
                if (setting2 == null)
                {
                    this.Settings.Add(new PropertySetting("DrawFill", (object)flag));
                }
                else
                {
                    setting2.Value = (object)flag;
                }
            }
            else
            {
                if (!(this.ItemType == "Border"))
                {
                    return;
                }
                PropertySetting setting2 = this.FindSetting("DrawBorder");
                if (setting2 == null)
                {
                    this.Settings.Add(new PropertySetting("DrawBorder", (object)flag));
                }
                else
                {
                    setting2.Value = (object)flag;
                }
            }
        }
Beispiel #15
0
 public void Combine(StyleGroup group, bool replaceExistingStyles)
 {
     if (replaceExistingStyles)
     {
         this.PropertySettingGroups.Clear();
         this.PropertySettingGroups.AddRange((IEnumerable <PropertySettingGroup>)group.PropertySettingGroups);
     }
     else
     {
         foreach (PropertySettingGroup propertySettingGroup1 in group.PropertySettingGroups)
         {
             bool flag = false;
             foreach (PropertySettingGroup propertySettingGroup2 in this.PropertySettingGroups)
             {
                 if (propertySettingGroup2.Selector.IsCompatible(propertySettingGroup1.Selector))
                 {
                     flag = true;
                     using (List <PropertySetting> .Enumerator enumerator = propertySettingGroup1.PropertySettings.GetEnumerator())
                     {
                         while (enumerator.MoveNext())
                         {
                             PropertySetting current          = enumerator.Current;
                             PropertySetting propertySetting1 = (PropertySetting)null;
                             foreach (PropertySetting propertySetting2 in propertySettingGroup2.PropertySettings)
                             {
                                 if (propertySetting2.Name == current.Name)
                                 {
                                     propertySetting1 = propertySetting2;
                                     break;
                                 }
                             }
                             if (propertySetting1 != null)
                             {
                                 propertySettingGroup2.PropertySettings.Remove(propertySetting1);
                             }
                             propertySettingGroup2.PropertySettings.Add(current);
                         }
                         break;
                     }
                 }
             }
             if (!flag)
             {
                 this.PropertySettingGroups.Add(propertySettingGroup1);
             }
         }
     }
     foreach (StyleRegistration registration1 in group.Registrations)
     {
         bool flag = false;
         foreach (StyleRegistration registration2 in this.Registrations)
         {
             if (registration2.IsCompatible(registration1))
             {
                 flag = true;
                 break;
             }
         }
         if (!flag)
         {
             this.Registrations.Add(registration1);
         }
     }
 }
Beispiel #16
0
        private Theme Parse(CSSParser parser)
        {
            Theme theme = new Theme();

            theme.StyleGroups.Add(new StyleGroup());
            foreach (CSSGroup group in parser.groups)
            {
                if (group.name == "theme")
                {
                    theme.Name = group["name"].value;
                    StyleRegistration styleRegistration = new StyleRegistration();
                    theme.StyleGroups[0].Registrations.Add(styleRegistration);
                    if (group.Contains("elementType"))
                    {
                        styleRegistration.RegistrationType = "ElementTypeDefault";
                        styleRegistration.ElementType      = group["elementType"].value;
                    }
                    if (group.Contains("controlType"))
                    {
                        styleRegistration.RegistrationType = "ElementTypeControlType";
                        styleRegistration.ControlType      = group["controlType"].value;
                        styleRegistration.ElementType      = "Telerik.WinControls.RootRadElement";
                    }
                }
                else if (group.name.StartsWith("#"))
                {
                    StyleRepository styleRepository = new StyleRepository();
                    styleRepository.Key = group.name.Remove(0, 1).Trim();
                    foreach (CSSItem cssItem in group.items)
                    {
                        PropertySetting propertySetting = this.CreatePropertySetting(cssItem);
                        styleRepository.Settings.Add(propertySetting);
                    }
                    theme.Repositories.Add(styleRepository);
                }
                else
                {
                    PropertySettingGroup propertySettingGroup = new PropertySettingGroup();
                    if (group.BasedOn.Count > 0)
                    {
                        StringBuilder stringBuilder = new StringBuilder();
                        for (int index = 0; index < group.BasedOn.Count; ++index)
                        {
                            string str = group.BasedOn[index];
                            stringBuilder.Append(str);
                            if (index < group.BasedOn.Count - 1)
                            {
                                stringBuilder.Append(",");
                            }
                        }
                        propertySettingGroup.BasedOn = stringBuilder.ToString();
                    }
                    propertySettingGroup.Selector       = new ElementSelector();
                    propertySettingGroup.Selector.Type  = ElementSelectorTypes.VisualStateSelector;
                    propertySettingGroup.Selector.Value = group.name;
                    if (!string.IsNullOrEmpty(group.childName))
                    {
                        propertySettingGroup.Selector.ChildSelector             = new ElementSelector(group.childName);
                        propertySettingGroup.Selector.ChildSelector.IsRecursive = true;
                    }
                    theme.StyleGroups[0].PropertySettingGroups.Add(propertySettingGroup);
                    foreach (CSSItem cssItem in group.items)
                    {
                        if (cssItem.name == "selectChild")
                        {
                            propertySettingGroup.Selector.ChildSelector             = new ElementSelector(ElementSelectorTypes.VisualStateSelector, cssItem.value);
                            propertySettingGroup.Selector.ChildSelector.IsRecursive = true;
                        }
                        else
                        {
                            if (cssItem.name == "selectChildClass")
                            {
                                propertySettingGroup.Selector.ChildSelector = new ElementSelector(ElementSelectorTypes.ClassSelector, cssItem.value);
                            }
                            PropertySetting propertySetting = this.CreatePropertySetting(cssItem);
                            propertySettingGroup.PropertySettings.Add(propertySetting);
                        }
                    }
                }
            }
            return(theme);
        }