Ejemplo n.º 1
0
        public PropertySettingGroup Deserialize()
        {
            PropertySettingGroup group = new PropertySettingGroup();

            group.BasedOn = this.basedOn;

            if (this.propertySettings != null)
            {
                for (int settingIndex = 0; settingIndex < this.PropertySettings.Count; settingIndex++)
                {
                    XmlPropertySetting xmlPropertySetting = this.PropertySettings[settingIndex];
                    IPropertySetting   setting            = xmlPropertySetting.Deserialize();
                    group.PropertySettings.Add(setting);
                }
            }

            if (this.selectors != null)
            {
                for (int selectorIndex = 0; selectorIndex < this.Selectors.Count; selectorIndex++)
                {
                    XmlElementSelector xmlSelector = this.Selectors[selectorIndex];
                    IElementSelector   selector    = xmlSelector.Deserialize();
                    group.Selectors.Add(selector);
                }
            }

            return(group);
        }
Ejemplo n.º 2
0
        /// <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);
        }