public static void RegisterStyleBuilder(StyleGroup styleBuilderRegistration, string themeName) { foreach (StyleRegistration registration in styleBuilderRegistration.Registrations) { switch (registration.RegistrationType) { case "ElementTypeDefault": ThemeResolutionService.RegisterElementTypeDefaultStyleBuilder(themeName, registration.ElementType, styleBuilderRegistration); continue; case "ElementTypeControlType": ThemeResolutionService.RegisterControlStyleBuilder(registration.ControlType, registration.ElementType, styleBuilderRegistration, themeName); continue; case "ElementTypeControlName": ThemeResolutionService.RegisterStyleBuilderByControlName(registration.ControlName, registration.ElementType, styleBuilderRegistration, themeName); continue; default: continue; } } ThemeResolutionService.EnsureThemeRegistered(themeName); }
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); } }
public ResolveStyleBuilderEventArgs(string themeName, StyleGroup builder) { this.builder = builder; this.themeName = themeName; }
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); } } }