public override LinkedList <RadObject> GetSelectedElements(RadObject element) { IStylableNode stylableNode = element as IStylableNode; if (stylableNode == null) { return(new LinkedList <RadObject>()); } if (this.childrenHierarchyByElement != null && this.CanUseCache) { return(this.FindElements(this.childrenHierarchyByElement) ?? new LinkedList <RadObject>()); } LinkedList <RadObject> linkedList = new LinkedList <RadObject>(); if (this.CanSelectOverride(element)) { linkedList.AddLast(element); } if (this.CanSelectOverride(element)) { linkedList.AddLast(element); } foreach (RadObject targetElement in stylableNode.ChildrenHierarchy) { if (this.CanSelectIgnoringConditions(targetElement)) { linkedList.AddLast(targetElement); } } return(linkedList); }
public void Apply(RadObject radObject, bool initializing) { IStylableElement stylable = radObject as IStylableElement; if (stylable != null) { if (!this.ApplySimpleSettings(stylable)) { this.ApplyVisualStateSettings(stylable, initializing); } } else { IStylableNode stylableNode = radObject as IStylableNode; if (stylableNode != null) { foreach (PropertySettingGroup setting in this.settings) { if (setting.Selector == null || setting.Selector.IsCompatible(radObject)) { stylableNode.ApplySettings(setting); } } } } if (!(radObject is RadItem)) { return; } ((RadItem)radObject).ApplyThemeSettingsOverride(); }
public void ApplyThemeToElement(RadObject element, bool recursive) { if (this.ComponentTreeHandler.Initializing) { return; } this.EnsureTheme(); if (this.theme == null) { return; } StyleGroup styleGroup = this.theme.FindStyleGroup(this.Control); if (styleGroup == null) { for (IStylableNode stylableNode = element as IStylableNode; styleGroup == null && stylableNode != null; stylableNode = stylableNode.Parent) { IStylableElement stylableElement = stylableNode as IStylableElement; if (stylableElement != null) { styleGroup = this.theme.FindStyleGroup((IStylableNode)stylableElement); } } } this.SuspendAnimations(); this.ApplyStyleCore(element, styleGroup, (RadObject)this.RootElement, recursive); this.ResumeAnimations(); if (element != this.RootElement) { return; } this.RootElement.IsThemeApplied = true; }
protected override bool CanSelectOverride(RadObject element) { IStylableNode stylableNode = element as IStylableNode; if (stylableNode != null && element != null) { return(string.Compare(stylableNode.Class, this.elementClass, true) == 0); } return(false); }
public void ApplyValue(IStylableNode element) { element.ApplySettings(new PropertySettingGroup() { PropertySettings = { this.propertySetting } }); }
protected override bool CanSelectOverride(RadObject element) { IStylableNode stylableNode = element as IStylableNode; if (stylableNode != null && element != null) { return((object)this.elementType == (object)stylableNode.GetThemeEffectiveType()); } return(false); }
public bool IsCompatible(IStylableNode item) { foreach (StyleRegistration registration in this.Registrations) { if (registration.IsCompatible(item)) { return(true); } } return(false); }
public StyleGroup FindStyleGroup(IStylableNode item) { foreach (StyleGroup styleGroup in this.styleGroups) { if (styleGroup.IsCompatible(item)) { return(styleGroup); } } return((StyleGroup)null); }
public bool IsChildElementCompatible(IStylableNode childElement) { if (!string.IsNullOrEmpty(this.childElementClass)) { return(childElement.Class == this.childElementClass); } if ((object)this.childElementType != null) { return((object)childElement.GetThemeEffectiveType() == (object)this.childElementType); } return(false); }
public virtual bool IsCompatible(RadObject element) { IStylableNode stylableNode = element as IStylableNode; if (stylableNode == null) { return(false); } if (this.type == ElementSelectorTypes.VisualStateSelector) { IStylableElement stylableElement = element as IStylableElement; string str = stylableElement != null ? stylableElement.ThemeRole : element.GetType().Name; if (this.value.StartsWith(str)) { return(true); } return(str == this.value); } if (this.type == ElementSelectorTypes.ClassSelector) { if (this.childSelector == null || this.childSelector.Type != ElementSelectorTypes.VisualStateSelector) { return(stylableNode.Class == this.value); } if (this.childSelector.IsCompatible(element)) { for (IStylableNode parent = stylableNode.Parent; parent != null; parent = parent.Parent) { if (parent.Class == this.value) { return(true); } } } return(false); } if (this.type != ElementSelectorTypes.TypeSelector) { return(false); } if (this.childSelector == null || this.childSelector.Type != ElementSelectorTypes.VisualStateSelector || !this.childSelector.IsCompatible(element)) { return(stylableNode.GetThemeEffectiveType().FullName == this.value); } for (IStylableNode parent = stylableNode.Parent; parent != null; parent = parent.Parent) { if (parent.GetThemeEffectiveType().FullName == this.value) { return(true); } } return(false); }
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)); }
public override bool IsCompatible(RadObject element) { IStylableNode stylableNode = element as IStylableNode; ClassSelector internalSelector1 = this.internalSelector as ClassSelector; if (internalSelector1 != null) { return(internalSelector1.ElementClass == stylableNode.Class); } TypeSelector internalSelector2 = this.internalSelector as TypeSelector; if (internalSelector2 != null) { return((object)internalSelector2.ElementType == (object)element.GetType()); } return(true); }
private bool FindCompatibleChild(IStylableNode node) { foreach (IStylableNode child in node.Children) { if (node.GetThemeEffectiveType().FullName == this.ElementType) { return(true); } } foreach (IStylableNode child in node.Children) { if (this.FindCompatibleChild(child)) { return(true); } } return(false); }
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); }
public StyleSheet CreateStyleSheet(RadObject element) { StyleSheet styleSheet = new StyleSheet(); RadElement radElement = element as RadElement; IStylableNode stylableNode = element as IStylableNode; lock (this.settingGroups) { foreach (PropertySettingGroup propertySettingGroup in this.PropertySettingGroups) { if (propertySettingGroup.Selector != null) { if (radElement != null && (propertySettingGroup.Selector.Type == ElementSelectorTypes.ClassSelector || propertySettingGroup.Selector.Type == ElementSelectorTypes.TypeSelector)) { bool flag = false; foreach (RadObject element1 in stylableNode.ChildrenHierarchy) { if (!(element1 is RadItem) && propertySettingGroup.Selector.IsCompatible(element1)) { styleSheet.PropertySettingGroups.Add(propertySettingGroup); flag = true; break; } } if (flag) { continue; } } if (propertySettingGroup.Selector.IsCompatible(element)) { styleSheet.PropertySettingGroups.Add(propertySettingGroup); } } } } if (styleSheet.PropertySettingGroups.Count > 0) { return(styleSheet); } return((StyleSheet)null); }
public bool IsCompatible(IStylableNode item) { if (this.registrationType == "ElementTypeDefault") { return(this.elementType == item.GetThemeEffectiveType().FullName); } if (string.IsNullOrEmpty(this.registrationType) || this.registrationType == "ElementTypeControlType") { RadElement radElement = item as RadElement; if (radElement != null && radElement.ElementTree != null) { IComponentTreeHandler control = radElement.ElementTree.Control as IComponentTreeHandler; if (control != null && this.elementType == item.GetThemeEffectiveType().FullName) { return(control.ThemeClassName == this.controlType); } } } return(false); }
public virtual bool IsValid(RadObject testElement, string state) { IStylableNode stylableNode = testElement as IStylableNode; if (this.type == ElementSelectorTypes.VisualStateSelector) { return(string.CompareOrdinal(state, this.Value) == 0); } if (this.childSelector != null && this.childSelector.Type == ElementSelectorTypes.VisualStateSelector) { return(this.childSelector.IsValid(testElement, state)); } if (this.type == ElementSelectorTypes.ClassSelector) { return(string.CompareOrdinal(this.value, stylableNode.Class) == 0); } if (this.type == ElementSelectorTypes.TypeSelector) { return(string.CompareOrdinal(this.value, stylableNode.GetThemeEffectiveType().FullName) == 0); } return(false); }
private void ApplyStyleCore( RadObject element, StyleGroup styleGroup, RadObject stopElement, bool recursive) { IStylableElement stylableElement = element as IStylableElement; IStylableNode stylableNode1 = element as IStylableNode; bool flag1 = stylableElement != null; RadItem radItem = element as RadItem; RadElement radElement = element as RadElement; if (radItem != null) { flag1 = radItem.CanHaveOwnStyle; } else if (radElement != null) { flag1 = !string.IsNullOrEmpty(radElement.Class); } if (flag1) { StyleSheet styleSheet = (StyleSheet)null; RadControl control = this.Control as RadControl; if (control != null) { styleGroup = control.ResolveStyleGroupForElement(styleGroup, element); } if (styleGroup != null) { styleSheet = styleGroup.CreateStyleSheet(element); } if (styleSheet == null) { StyleGroup styleGroup1 = this.theme.FindStyleGroup(stylableNode1); if (styleGroup1 == null) { for (IStylableNode parent = stylableNode1.Parent; parent != null && styleGroup1 == null && parent != stopElement; parent = parent.Parent) { if (parent.Style != null) { bool flag2 = false; foreach (PropertySettingGroup propertySettingGroup in parent.Style.PropertySettingGroups) { if (propertySettingGroup.Selector != null && propertySettingGroup.Selector.Type != ElementSelectorTypes.VisualStateSelector && (propertySettingGroup.Selector.ChildSelector != null && propertySettingGroup.Selector.ChildSelector.Type != ElementSelectorTypes.VisualStateSelector) && (propertySettingGroup.Selector.IsCompatible(parent as RadObject) && propertySettingGroup.Selector.ChildSelector.IsCompatible(element))) { stylableNode1.ApplySettings(propertySettingGroup); flag2 = true; break; } } if (flag2) { break; } } styleGroup1 = this.theme.FindStyleGroup(parent); } } if (styleGroup1 != null) { styleSheet = styleGroup1.CreateStyleSheet(element); styleGroup = styleGroup1; } } if (styleSheet == null && stylableElement != null && stylableElement.FallbackToDefaultTheme) { styleGroup = ThemeRepository.ControlDefault.FindStyleGroup((IStylableNode)stylableElement); if (styleGroup != null) { styleSheet = styleGroup.CreateStyleSheet(element); } } if (radElement != null) { if (radElement.GetValueSource(RadElement.StyleProperty) != ValueSource.Local || radElement.Style == null) { int num = (int)radElement.SetDefaultValueOverride(RadElement.StyleProperty, (object)styleSheet); } } else { stylableNode1.Style = styleSheet; } if (radElement != null) { radElement.styleVersion = this.styleVersion; } } if (!recursive) { return; } IStylableNode stylableNode2 = element as IStylableNode; if (stylableNode2 == null) { return; } if (radElement == null || stylableElement != null && stylableElement.FallbackToDefaultTheme) { stopElement = element; } foreach (RadObject child in stylableNode2.Children) { this.ApplyStyleCore(child, styleGroup, stopElement, recursive); } }