Ejemplo n.º 1
0
        public void ReadColorInfoXmlNullElementNameTest( )
        {
            var doc = new XmlDocument( );

            doc.LoadXml("<xml></xml>");
            ColorInfoHelper.ReadColorInfoXml(doc.DocumentElement, null);
        }
Ejemplo n.º 2
0
        public void ReadColorInfoXmlEmptyElemementNameTest( )
        {
            var doc = new XmlDocument( );

            doc.LoadXml("<xml></xml>");
            ColorInfoHelper.ReadColorInfoXml(doc.DocumentElement, string.Empty);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Reconstructs an icon formatting rule from the specified XML image.
        /// </summary>
        /// <param name="node">The node containing the icon formatting rule XML.</param>
        /// <returns>The icon formatting rule.</returns>
        private static IconFormattingRule ReadIconFormattingRuleXml(XmlNode node)
        {
            IconFormattingRule formattingRule = new IconFormattingRule();

            XmlNodeList ruleNodes = XmlHelper.SelectNodes(node, "iconFormattingRule/rules/rule");

            foreach (XmlNode ruleNode in ruleNodes)
            {
                IconRule rule = new IconRule();

                rule.Color     = ColorInfoHelper.ReadColorInfoXml(ruleNode, "color");
                rule.Condition = ConditionHelper.ReadConditionXml(ruleNode, "condition");
                rule.Icon      = (IconType)XmlHelper.ReadElementEnum(ruleNode, "icon", typeof(IconType), IconType.None);
                XmlNode iconIdNode = ruleNode.SelectSingleNode("iconId");
                if (iconIdNode != null)
                {
                    long iconId;
                    if (long.TryParse(iconIdNode.InnerText, out iconId))
                    {
                        rule.IconId = iconId;
                    }
                }
                rule.Scale = 1;
                formattingRule.Rules.Add(rule);
            }

            return(formattingRule);
        }
Ejemplo n.º 4
0
        public void ReadColorInfoXmlInvalidXmlTest( )
        {
            var doc = new XmlDocument( );

            doc.LoadXml("<xml><color></color></xml>");
            ColorInfo color = ColorInfoHelper.ReadColorInfoXml(doc.DocumentElement, "color");

            Assert.AreEqual(0, color.A, "The value of Color.A is invalid.");
            Assert.AreEqual(0, color.R, "The value of Color.R is invalid.");
            Assert.AreEqual(0, color.G, "The value of Color.G is invalid.");
            Assert.AreEqual(0, color.B, "The value of Color.B is invalid.");
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Reconstructs a bar formatting rule from the specified XML image.
        /// </summary>
        /// <param name="node">The node containing the bar formatting rule XML.</param>
        /// <returns>The bar formatting rule.</returns>
        private static BarFormattingRule ReadBarFormattingRuleXml(XmlNode node)
        {
            BarFormattingRule formattingRule = new BarFormattingRule();

            if (XmlHelper.EvaluateSingleNode(node, "barFormattingRule"))
            {
                XmlNode barFormattingRuleNode = XmlHelper.SelectSingleNode(node, "barFormattingRule");
                if (barFormattingRuleNode != null)
                {
                    formattingRule.Color   = ColorInfoHelper.ReadColorInfoXml(barFormattingRuleNode, "color");
                    formattingRule.Minimum = TypedValueHelper.ReadTypedValueXml(barFormattingRuleNode, "minimum");
                    formattingRule.Maximum = TypedValueHelper.ReadTypedValueXml(barFormattingRuleNode, "maximum");
                }
            }

            return(formattingRule);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Reconstructs a color formatting rule from the specified XML image.
        /// </summary>
        /// <param name="node">The node containing the color formatting rule XML.</param>
        /// <returns>The color formatting rule.</returns>
        private static ColorFormattingRule ReadColorFormattingRuleXml(XmlNode node)
        {
            ColorFormattingRule formattingRule = new ColorFormattingRule();

            XmlNodeList ruleNodes = XmlHelper.SelectNodes(node, "colorFormattingRule/rules/rule");

            foreach (XmlNode ruleNode in ruleNodes)
            {
                ColorRule rule = new ColorRule();

                rule.BackgroundColor = ColorInfoHelper.ReadColorInfoXml(ruleNode, "backgroundColor");
                rule.ForegroundColor = ColorInfoHelper.ReadColorInfoXml(ruleNode, "foregroundColor");
                rule.Condition       = ConditionHelper.ReadConditionXml(ruleNode, "condition");

                formattingRule.Rules.Add(rule);
            }

            return(formattingRule);
        }
Ejemplo n.º 7
0
 public void ReadColorInfoXmlNullNodeTest( )
 {
     ColorInfoHelper.ReadColorInfoXml(null, "color");
 }