protected virtual void SerializeProperties(XmlElementSelector xmlselctor) { XmlSelectorBase instance = (XmlSelectorBase)xmlselctor; if (this.Condition != null) { instance.Condition = this.Condition.Serialize(); } if (this.UnapplyCondition != null) { instance.UnapplyCondition = this.UnapplyCondition.Serialize(); } if (this.ChildSelector != null) { instance.ChildSelector = this.ChildSelector.Serialize(); } instance.AutoUnapply = this.AutoUnapply; }
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); }
/// <summary> /// This method supports TPF infrastructure and is intended for internal use only. /// </summary> /// <param name="applyUnconditional"></param> /// <param name="groups"></param> /// <returns></returns> public StyleSheet GetStyleSheet(XmlSelectorBase applyUnconditional, XmlPropertySettingGroup[] groups) { StyleSheet res = new StyleSheet(); SelectorBase applySelector = null; if (this.PropertySettingGroups == null) { return(res); } for (int i = 0; i < this.PropertySettingGroups.Count; i++) { XmlPropertySettingGroup xmlGroup = this.PropertySettingGroups[i]; if (xmlGroup.Selectors != null) { for (int selectorIndex = 0; selectorIndex < xmlGroup.Selectors.Count; selectorIndex++) { XmlElementSelector xmlSelector = xmlGroup.Selectors[selectorIndex]; if (xmlSelector == applyUnconditional) { applySelector = (SelectorBase)xmlSelector.Deserialize(); break; } } } } for (int i = 0; i < this.PropertySettingGroups.Count; i++) { XmlPropertySettingGroup xmlGroup = this.PropertySettingGroups[i]; PropertySettingGroup group = new PropertySettingGroup(); if (xmlGroup.PropertySettings == null || xmlGroup.Selectors == null) { continue; } bool disable = false; if (applyUnconditional != null) { for (int groupIndex = 0; groupIndex < groups.Length; groupIndex++) { XmlPropertySettingGroup g = groups[groupIndex]; if (g == xmlGroup) { disable = true; break; } } } for (int settingIndex = 0; settingIndex < xmlGroup.PropertySettings.Count; settingIndex++) { XmlPropertySetting xmlPropertySetting = xmlGroup.PropertySettings[settingIndex]; IPropertySetting setting = xmlPropertySetting.Deserialize(); group.PropertySettings.Add(setting); } //IElementSelector activeSelector = null; for (int selectorIndex = 0; selectorIndex < xmlGroup.Selectors.Count; selectorIndex++) { XmlElementSelector xmlSelector = xmlGroup.Selectors[selectorIndex]; IElementSelector selector = null; selector = xmlSelector.Deserialize(); if (xmlSelector == applyUnconditional) { applySelector.IsActiveSelectorInStyleBuilder = true; selector = applySelector; //continue; } else if (disable) { ((SelectorBase)selector).DisableStyle = true; //((SelectorBase)selector).ExcludeSelector = applySelector; } group.Selectors.Add(selector); } //if (activeSelector != null) // group.Selectors.Insert(0, activeSelector); res.PropertySettingGroups.Add(group); } return(res); }