public Theme Read(string filePath) { CSSParser parser = new CSSParser(); parser.Read(filePath); return(this.Parse(parser)); }
public Theme Read(Stream stream) { CSSParser parser = new CSSParser(); parser.Read(stream); return(this.Parse(parser)); }
public Theme ReadText(string text) { CSSParser parser = new CSSParser(); parser.ReadText(text); return(this.Parse(parser)); }
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); }