Example #1
0
 protected override void WriteInner(XmlWriter writer)
 {
     if (_textFormat != null && _value != null)
     {
         _value = _textFormat.Format(_value);
     }
     writer.WriteValue(_value ?? string.Empty);
 }
Example #2
0
        protected override NodeBase CreateInternal(string data)
        {
            if (data == null || string.IsNullOrWhiteSpace(data))
            {
                return new SimpleNode("td", string.Empty)
                       {
                           Attributes = new Dictionary <string, string>()
                           {
                               { "column-index", colId.ToString() }
                           }
                       }
            }
            ;
            if (data == "--")//rankname == '--'
            {
                return(new SimpleNode("td", data + "%")
                {
                    Attributes = new Dictionary <string, string>()
                    {
                        { "column-index", colId.ToString() }
                    }
                });
            }
            if (TextFormat != null)
            {
                data = TextFormat.Format(data);
            }

            if (suffix != null || !string.IsNullOrEmpty(suffix))
            {
                data += suffix;
            }
            return(new SimpleNode("td", data)
            {
                Attributes = new Dictionary <string, string>()
                {
                    { "column-index", colId.ToString() }
                }
            });
        }
    }
Example #3
0
        protected override NodeBase CreateInternal(object colValues)
        {
            string data   = null;
            var    values = colValues as List <string>;

            if (values == null || string.IsNullOrEmpty(values[0]))
            {
                return new SimpleNode("td", string.Empty)
                       {
                           Classes = new List <string>()
                           {
                               "col-" + colId.ToString()
                           },
                           Attributes = new Dictionary <string, string>()
                           {
                               { "column-index", colId.ToString() }
                           }
                       }
            }
            ;
            if (TextFormat != null)
            {
                data = TextFormat.Format(values[0]);
            }

            var complexNode = new ComplexNode("td");

            complexNode.Attributes.Add("column-index", colId.ToString());

            complexNode.ChildNodes.Add(new SimpleNode("span", data));
            complexNode.ChildNodes.Add(new SimpleNode("img", "")
            {
                Attributes =
                {
                    { "src", "Content/Images/" + values[1] + ".gif" },
                }
            });
            return(complexNode);
        }
    }
Example #4
0
        protected override NodeBase CreateInternal(string data)
        {
            if (data == null || string.IsNullOrWhiteSpace(data))
            {
                return(new SimpleNode("td", string.Empty));
            }

            if (_textFormat != null)
            {
                data = _textFormat.Format(data);
            }

            if (data == "--")
            {
                data = "%PPG";
            }
            if (data.Contains('#'))
            {
                List <string> splitData = data.Split('#').ToList();
                return(new SimpleNode("td", splitData[0])
                {
                    Attributes = new Dictionary <string, string>()
                    {
                        { "title", splitData[1] },
                    }
                });
            }
            if (IsMakeTextShort && data.Length > NameCollength)
            {
                return(new SimpleNode("td", data.Substring(0, NameCollength - 1) + "...")
                {
                    Attributes = new Dictionary <string, string>()
                    {
                        { "title", data },
                    }
                });
            }

            return(new SimpleNode("td", data));
        }
Example #5
0
        protected override NodeBase CreateInternal(object value)
        {
            _isAsItIS = false;

            double number;

            value = value ?? "0";
            double.TryParse(value.ToString(), out number);

            string result = "";

            if (_showPlusMInus && number >= 0)
            {
                result += "+";
            }
            else if (_showPlusMInus && number < 0)
            {
                result += "-";
            }
            if (Prefix != null)
            {
                result += Prefix;
            }

            if (!string.IsNullOrEmpty(NumberFormatString))
            {
                _numberFormatter = new TextFormat()
                {
                    FormatString = NumberFormatString
                };
                if (Suffix != null && Suffix == "k" && Math.Abs(number) < 1000)
                {
                    _numberFormatter = new TextFormat()
                    {
                        FormatString = "#,##0"
                    };
                    _isAsItIS = true;
                }

                var formattedValue = _numberFormatter.Format(Math.Abs(number).ToString(CultureInfo.InvariantCulture));
                result += formattedValue;
            }
            else
            {
                result += Math.Abs(number).ToString(CultureInfo.InvariantCulture);
            }

            if (Suffix != null)
            {
                if (_isAsItIS)
                {
                    result += "";
                }
                else
                {
                    result += Suffix;
                }
            }
            var tableCell = new SimpleNode(_nodeName, result);

            tableCell.Classes.Add("col-" + _colId);
            tableCell.Attributes.Add("column-index", _colId.ToString());

            return(tableCell);
        }
Example #6
0
        public string NumberFormatter(object data)
        {
            var    isMillion  = false;
            var    isBillion  = false;
            var    isThousand = false;
            double number;

            data = data ?? "0";
            double.TryParse(data.ToString(), out number);

            var result = "";

            if (Prefix != null)
            {
                result += Prefix;
            }

            if (!string.IsNullOrEmpty(NumberFormatString))
            {
                _numberFormatter = new TextFormat()
                {
                    FormatString = NumberFormatString
                };
                if (Math.Abs(number) >= 1000000000)//greater than or equal to 1 billion
                {
                    _numberFormatter = new TextFormat()
                    {
                        FormatString = "#,##0,,,.0"
                    };
                    isBillion = true;
                }
                else if (Math.Abs(number) >= 1000000)//greater than or equal to 1 million
                {
                    _numberFormatter = new TextFormat()
                    {
                        FormatString = "#,##0,,.0"
                    };
                    isMillion = true;
                }
                else if (Math.Abs(number) >= 1000)
                {
                    _numberFormatter = new TextFormat()
                    {
                        FormatString = "#,##0,.0"
                    };
                    isThousand = true;
                }

                var formattedValue = _numberFormatter.Format(Math.Abs(number).ToString(CultureInfo.InvariantCulture));
                result += formattedValue;
            }
            else
            {
                result += Math.Abs(number).ToString(CultureInfo.InvariantCulture);
            }

            if (isBillion)
            {
                result += "b";
            }
            else if (isMillion)
            {
                result += "m";
            }
            else if (isThousand)
            {
                result += "k";
            }
            else
            {
                result += Suffix;
            }
            return(result);
        }
Example #7
0
        protected override NodeBase CreateInternal(object colValues)
        {
            _isAsItIS = false;
            var tableCell = new ComplexNode(_nodeName);

            tableCell.Classes.Add("col-" + _colId);
            tableCell.Classes.Add("has-indicator");
            var values = colValues as List <string>;

            double number;

            values[0] = values[0] ?? "0";
            double.TryParse(values[0].ToString(), out number);

            string result = "";

            if (_showPlusMInus && number >= 0)
            {
                result += "+";
            }
            else if (_showPlusMInus && number < 0)
            {
                result += "-";
            }
            if (Prefix != null)
            {
                result += Prefix;
            }

            if (!string.IsNullOrEmpty(NumberFormatString))
            {
                _numberFormatter = new TextFormat()
                {
                    FormatString = NumberFormatString
                };
                if (Suffix != null && Suffix == "k" && Math.Abs(number) < 1000)
                {
                    _numberFormatter = new TextFormat()
                    {
                        FormatString = "#,##0"
                    };
                    _isAsItIS = true;
                }

                var formattedValue = _numberFormatter.Format(Math.Abs(number).ToString(CultureInfo.InvariantCulture));
                result += formattedValue;
            }
            else
            {
                result += Math.Abs(number).ToString(CultureInfo.InvariantCulture);
            }

            if (Suffix != null)
            {
                if (_isAsItIS)
                {
                    result += "";
                }
                else
                {
                    result += Suffix;
                }
            }

            if (string.IsNullOrEmpty(values[0].ToString()))
            {
                return(tableCell);
            }

            tableCell.ChildNodes.Add(new SimpleNode("span", result));
            tableCell.Classes.Add("col-" + _colId);
            tableCell.ChildNodes.Add(new SimpleNode("img", "")
            {
                Attributes =
                {
                    { "src", string.Format("Content/Images/{0}.gif", values[1].ToString()) },
                }
            });
            tableCell.Attributes.Add("column-index", _colId.ToString());
            return(tableCell);
        }
Example #8
0
        protected override SimpleNode CreateInternal(object data)
        {
            _isAsItIS = false;
            var tableCell = new SimpleNode(_nodeName, "");

            tableCell.Classes.Add("col-" + _colId);

            double number;

            data = data ?? "0";
            double.TryParse(data.ToString(), out number);

            string result = "";

            if (Prefix != null)
            {
                result += Prefix;
            }

            if (!string.IsNullOrEmpty(NumberFormatString))
            {
                _numberFormatter = new TextFormat()
                {
                    FormatString = NumberFormatString
                };
                if (Suffix != null && Suffix == "k" && Math.Abs(number) < 1000)
                {
                    _numberFormatter = new TextFormat()
                    {
                        FormatString = "#,##0"
                    };
                    _isAsItIS = true;
                }

                var formattedValue = _numberFormatter.Format(Math.Abs(number).ToString(CultureInfo.InvariantCulture));
                result += formattedValue;
            }
            else
            {
                result += Math.Abs(number).ToString(CultureInfo.InvariantCulture);
            }

            if (Suffix != null)
            {
                if (_isAsItIS)
                {
                    result += "";
                }
                else
                {
                    result += Suffix;
                }
            }

            if (string.IsNullOrEmpty(data.ToString()))
            {
                return(tableCell);
            }

            tableCell = new SimpleNode(_nodeName, result);
            tableCell.Classes.Add("col-" + _colId);

            return(tableCell);
        }
Example #9
0
        protected override NodeBase CreateInternal(Object value)
        {
            var data = (ExpandCollapseCellData)value;

            if (data.CellData == null)
            {
                data.CellData = string.Empty;
            }

            if (string.IsNullOrWhiteSpace(data.CellData))
            {
                return(new SimpleNode("td", string.Empty));
            }

            if (_textFormat != null)
            {
                data.CellData = _textFormat.Format(data.CellData);
            }

            SimpleNode node;


            if (data.CellData.Contains('#'))
            {
                List <string> splitData2 = data.CellData.Split('#').ToList();
                return(new SimpleNode("td", splitData2[0])
                {
                    Attributes = new Dictionary <string, string>()
                    {
                        { "title", splitData2[1] },
                    }
                });
            }


            var splitData = data.CellData.Split('#');

            if (IsMakeTextShort && IsSubbrandAtAGlance && splitData.Length > 1)//Subbrand
            {
                node = new SimpleNode("td", splitData[splitData.Length - 1])
                {
                    Attributes = new Dictionary <string, string>()
                    {
                        { "title", splitData[splitData.Length - 3] + "-" + splitData[splitData.Length - 2] },
                    }
                };
            }
            else if (IsMakeTextShort && IsBrandAtAGlance && splitData.Length > 1)//Brand
            {
                node = new SimpleNode("td", splitData[splitData.Length - 1])
                {
                    Attributes = new Dictionary <string, string>()
                    {
                        { "title", splitData[splitData.Length - 2] },
                    }
                };
            }
            //else if (IsMakeTextShort && !data.CellData.ToUpper().Contains("RECKITT") && data.CellData.Length > NameCollength)
            //{
            //    node = new SimpleNode("td", data.CellData.Substring(0, NameCollength - 1) + "...")
            //    {
            //        Attributes = new Dictionary<string, string>()
            //        {
            //            {"title",data.CellData},
            //        }
            //    };
            //}
            else
            {
                node = new SimpleNode("td", data.CellData);
            }

            if (data.Level == 1 && data.GeoLevel == 1)
            {
                node.Styles.Add("padding-left", "0px");
            }
            if (data.Level == 2 && data.GeoLevel == 1)
            {
                node.Styles.Add("padding-left", "7px");
            }
            if (data.Level == 3 && data.GeoLevel == 1)
            {
                node.Styles.Add("padding-left", "14px");
            }

            if (data.Level == 1 && data.GeoLevel == 2)
            {
                node.Styles.Add("padding-left", "7px");
            }
            if (data.Level == 2 && data.GeoLevel == 2)
            {
                node.Styles.Add("padding-left", "14px");
            }
            if (data.Level == 3 && data.GeoLevel == 2)
            {
                node.Styles.Add("padding-left", "21px");
            }

            if (data.Level == 1 && data.GeoLevel == 3)
            {
                node.Styles.Add("padding-left", "14px");
            }
            if (data.Level == 2 && data.GeoLevel == 3)
            {
                node.Styles.Add("padding-left", "21px");
            }
            if (data.Level == 3 && data.GeoLevel == 3)
            {
                node.Styles.Add("padding-left", "28px");
            }


            return(node);
        }