Exemple #1
0
        public FastRow(FastGrid owner, object obj, Dictionary <FastColumn, PropertyInfo> columnProperty)
        {
            this.owner  = owner;
            ValueObject = obj;
            if (owner.colorFormatter != null)
            {
                Color?clBack, clFont;
                owner.colorFormatter(ValueObject, out clBack, out clFont);
                BackgroundColor = clBack;
                FontColor       = clFont;
            }

            string[] strings = null;
            if (owner.rowExtraFormatter != null)
            {
                strings = owner.rowExtraFormatter(obj, columnProperty.Select(propertyInfo => propertyInfo.Key).ToList());
            }

            var counter = 0;

            foreach (var colPair in columnProperty)
            {
                var cell = new FastCell();
                if (colPair.Value == null)
                {
                    cells.Add(cell);
                    continue;
                }
                // do format value
                var proVal = colPair.Value.GetValue(obj, null);
                cell.CellValue  = proVal;
                cell.CellString = strings == null ?
                                  (colPair.Key.formatter != null ? colPair.Key.formatter(proVal)
                    : colPair.Key.rowFormatter != null ? colPair.Key.rowFormatter(obj)
                    : proVal == null
                    ? colPair.Key.NullString
                    : ObjectToString(proVal, colPair.Key.FormatString, colPair.Key.FractionDigits)) : strings[counter++];
                if (colPair.Key.cellFormatting != null)
                {
                    var args = new CellFormattingEventArgs
                    {
                        cellValue      = cell.CellValue,
                        resultedString = cell.CellString,
                        column         = colPair.Key,
                        rowValue       = obj,
                    };
                    colPair.Key.cellFormatting(args);
                    cell.CellString = args.resultedString;
                }
                cells.Add(cell);
            }
        }
Exemple #2
0
        public FastRow(FastGrid owner, object obj, Dictionary<FastColumn, PropertyInfo> columnProperty)
        {
            this.owner = owner;
            ValueObject = obj;
            if (owner.colorFormatter != null)
            {
                Color? clBack, clFont;
                owner.colorFormatter(ValueObject, out clBack, out clFont);
                BackgroundColor = clBack;
                FontColor = clFont;
            }

            string[] strings = null;
            if (owner.rowExtraFormatter != null)
                strings = owner.rowExtraFormatter(obj, columnProperty.Select(propertyInfo => propertyInfo.Key).ToList());

            var counter = 0;
            foreach (var colPair in columnProperty)
            {
                var cell = new FastCell();
                if (colPair.Value == null)
                {
                    cells.Add(cell);
                    continue;
                }
                // do format value
                var proVal = colPair.Value.GetValue(obj, null);
                cell.CellValue = proVal;
                cell.CellString = strings == null ?
                    (colPair.Key.formatter != null ? colPair.Key.formatter(proVal)
                    : colPair.Key.rowFormatter != null ? colPair.Key.rowFormatter(obj)
                    : proVal == null
                    ? colPair.Key.NullString
                    : ObjectToString(proVal, colPair.Key.FormatString, colPair.Key.FractionDigits)) : strings[counter++];
                if (colPair.Key.cellFormatting != null)
                {
                    var args = new CellFormattingEventArgs
                        {
                            cellValue = cell.CellValue,
                            resultedString = cell.CellString,
                            column = colPair.Key,
                            rowValue = obj,
                        };
                    colPair.Key.cellFormatting(args);
                    cell.CellString = args.resultedString;
                }
                cells.Add(cell);
            }
        }