示例#1
0
 private bool ApplySimpleSelectorToChildren(
     IStylableNode stylable,
     PropertySettingGroup group,
     ElementSelector selector)
 {
     foreach (RadObject child in stylable.Children)
     {
         if (selector.IsCompatible(child))
         {
             (child as IStylableNode).ApplySettings(group);
             return(true);
         }
         if (this.ApplySimpleSelectorToChildren(child as IStylableNode, group, selector))
         {
             return(true);
         }
     }
     return(false);
 }
        private XmlElementSelector CreateSelector(ElementSelector selector)
        {
            XmlSelectorBase xmlSelectorBase = (XmlSelectorBase)null;
            WrapSelector    wrapSelector    = selector as WrapSelector;

            if (wrapSelector != null)
            {
                TypeSelector internalSelector1 = wrapSelector.InternalSelector as TypeSelector;
                if (internalSelector1 != null)
                {
                    return((XmlElementSelector) new XmlTypeSelector(XmlTheme.SerializeType(internalSelector1.ElementType)));
                }
                ClassSelector internalSelector2 = wrapSelector.InternalSelector as ClassSelector;
                if (internalSelector2 != null)
                {
                    return((XmlElementSelector) new XmlClassSelector(internalSelector2.ElementClass));
                }
            }
            if (selector.Type == ElementSelectorTypes.VisualStateSelector)
            {
                xmlSelectorBase = (XmlSelectorBase) new XmlVisualStateSelector(selector.Value);
            }
            else if (selector.Type == ElementSelectorTypes.TypeSelector)
            {
                xmlSelectorBase = (XmlSelectorBase) new XmlTypeSelector(selector.Value);
            }
            else if (selector.Type == ElementSelectorTypes.ClassSelector)
            {
                xmlSelectorBase = (XmlSelectorBase) new XmlClassSelector(selector.Value);
            }
            if (selector.ChildSelector != null)
            {
                xmlSelectorBase.ChildSelector = this.CreateSelector(selector.ChildSelector);
            }
            return((XmlElementSelector)xmlSelectorBase);
        }
示例#3
0
        private bool ApplySimpleSettings(IStylableElement stylable)
        {
            RadObject testElement = stylable as RadObject;
            List <PropertySettingGroup> propertySettingGroupList = (List <PropertySettingGroup>)null;

            foreach (PropertySettingGroup setting in this.settings)
            {
                if (setting.Selector == null)
                {
                    stylable.ApplySettings(setting);
                }
                else if (setting.Selector.Type != ElementSelectorTypes.VisualStateSelector)
                {
                    ElementSelector selector = setting.Selector;
                    if (setting.Selector.IsValid(testElement, string.Empty))
                    {
                        if (setting.Selector.ChildSelector == null)
                        {
                            stylable.ApplySettings(setting);
                            selector = (ElementSelector)null;
                        }
                        else
                        {
                            selector = setting.Selector.ChildSelector;
                        }
                    }
                    else if (setting.Selector.ChildSelector != null && setting.Selector.ChildSelector.Type == ElementSelectorTypes.VisualStateSelector)
                    {
                        if (propertySettingGroupList == null)
                        {
                            propertySettingGroupList = new List <PropertySettingGroup>();
                        }
                        propertySettingGroupList.Add(setting);
                        continue;
                    }
                    if (selector != null)
                    {
                        this.ApplySimpleSelectorToChildren((IStylableNode)stylable, setting, selector);
                    }
                }
            }
            if (propertySettingGroupList != null)
            {
                foreach (string stateFallback in this.GetStateFallbackList(stylable))
                {
                    bool flag = false;
                    foreach (PropertySettingGroup group in propertySettingGroupList)
                    {
                        if (group.Selector.ChildSelector.IsValid(testElement, stateFallback))
                        {
                            stylable.ApplySettings(group);
                            flag = true;
                            break;
                        }
                    }
                    if (flag)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
 public PropertySettingGroup(Type type, params PropertySetting[] propertySettings)
     : this()
 {
     this.selector = (ElementSelector) new WrapSelector((IElementSelector) new TypeSelector(type));
     this.settings.AddRange((IEnumerable <PropertySetting>)propertySettings);
 }
 public PropertySettingGroup(string className, params PropertySetting[] propertySettings)
     : this()
 {
     this.selector = (ElementSelector) new WrapSelector((IElementSelector) new ClassSelector(className));
     this.settings.AddRange((IEnumerable <PropertySetting>)propertySettings);
 }
 public PropertySettingGroup(string basedOn, ElementSelector selector)
     : this(basedOn)
 {
     this.selector = selector;
 }