示例#1
0
        private void CreateRowMap()
        {
            RowMap.Clear();
            int row = 0;

            _contentWidth = 0;
            foreach (TreeNodeAdv node in VisibleNodes)
            {
                node.Row = row;
                RowMap.Add(node);
                if (!UseColumns)
                {
                    _contentWidth = Math.Max(_contentWidth, GetNodeWidth(node));
                }
                row++;
            }
            if (UseColumns)
            {
                _contentWidth = 0;
                foreach (TreeColumn col in _columns)
                {
                    if (col.IsVisible)
                    {
                        _contentWidth += col.Width;
                    }
                }
            }
        }
        public object[] AddData(object[] values)
        {
            if (Parent != null)
            {
                if (Parent.CurrentRow == null)
                {
                    throw new InvalidOperationException("Row cannot be added when parent table has no current row");
                }

                foreach (var pk in _parentReferenceIndices)
                {
                    values[pk.Value] = Parent.CurrentRow[pk.Key];
                }
            }

            if (HashKey.HasValue)
            {
                values[HashKey.Value] = KeyFactory.CalculateKey(HashIndices.Select(ix => values[ix]));
            }


            //Facts with scope unique values (e.g. count only one visit for pages visited multiple times in a visit)
            foreach (var f in Schema.Facts)
            {
                var defered = values[f.Index] as IDeferedValue;
                if (defered != null)
                {
                    values[f.Index] = defered.GetValue(this, f, values);
                }
            }

            object[] row;
            if (RowMap.TryGetValue(values, out row))
            {
                MergeFacts(row, values);
            }
            else
            {
                RowMap.Add(values, row = values);
                ++RowsCreated;
            }

            return(row);
        }