示例#1
0
        public FRealCurve?FindCurve(FName rowName, bool bWarnIfNotFound = true)
        {
            if (rowName.IsNone)
            {
                if (bWarnIfNotFound)
                {
                    Log.Warning("UCurveTable::FindCurve : NAME_None is invalid row name for CurveTable '{0}'.", GetPathName());
                }
                return(null);
            }

            if (!RowMap.TryGetValue(rowName, out var foundCurve))
            {
                if (bWarnIfNotFound)
                {
                    Log.Warning("UCurveTable::FindCurve : Row '{0}' not found in CurveTable '{1}'.", rowName.ToString(), GetPathName());
                }
                return(null);
            }

            return(CurveTableMode switch
            {
                ECurveTableMode.SimpleCurves => new FSimpleCurve(foundCurve),
                ECurveTableMode.RichCurves => new FRichCurve(foundCurve),
                _ => null
            });
示例#2
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;
                    }
                }
            }
        }
示例#3
0
            public ColumnMap GetMap()
            {
                MemberExpression temp        = _memberAccess;
                string           propertyMap = "";

                while (temp != null)
                {
                    propertyMap = "." + temp.Member.Name + propertyMap;
                    temp        = temp.Expression as MemberExpression;
                }
                propertyMap   = propertyMap.TrimStart('.');
                _propertyName = propertyMap;
                if (_mapType == MapType.UseMap && propertyMap.Contains("."))
                {
                    throw new Exception("Nested Property And UseMap Is Not Compatible");
                }
                ColumnMap columnMap = null;

                if (_mapType == MapType.ColumnName)
                {
                    string columnName = _columnName;
                    if (propertyMap.Contains("."))
                    {
                        string[] strings = propertyMap.Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries);


                        RowMap tempRm = RowMapper.GetTempRowMap(strings, columnName);
                        columnMap = new ColumnMap()
                        {
                            PropertyName   = strings[0],
                            InnerType      = InnerMapType.Internal,
                            InternalRowMap = tempRm
                        };
                    }
                    else
                    {
                        columnMap = new ColumnMap()
                        {
                            ColumnName = columnName, PropertyName = propertyMap
                        }
                    };
                }
                else if (_mapType == MapType.UseMap)
                {
                    columnMap = new ColumnMap()
                    {
                        PropertyName = propertyMap,
                        InnerType    = InnerMapType.Internal,
                    };
                }
                return(columnMap);
            }
示例#4
0
 public RowMap GetMap()
 {
     if (_rowMap == null)
     {
         _rowMap = new RowMap();
         foreach (MapClass mapClass in maps)
         {
             ColumnMap mapFunc = mapClass.GetMap();
             if (_rowMap.ColumnMapsByPropertyName == null)
             {
                 _rowMap.ColumnMapsByPropertyName = new Dictionary <string, ColumnMap>();
             }
             _rowMap.ColumnMapsByPropertyName.Add(mapClass.GetPropName(), mapFunc);
         }
     }
     return(_rowMap);
 }
        private Row WriteRow(WorksheetPart worksheetPart, RowMap map, IEnumerable <FilterValue> filterValues, int rowIndex, uint styleIndex)
        {
            var row = new Row()
            {
                RowIndex     = (uint)rowIndex,
                CustomFormat = true,
                Height       = 30,
                Hidden       = false,
                CustomHeight = true,
                OutlineLevel = 0,
                Collapsed    = false
            };

            var dataRow = new DataRow();

            foreach (var rowMap in map.CellMaps)
            {
                var filterValue = filterValues.First(x => x.PropertyInfo == rowMap.FilterValue.PropertyInfo);

                var cell = new Cell
                {
                    CellReference = $"{GetExcelColumnName(rowMap.ColumnIndex)}{rowIndex}",
                    DataType      = CellValues.String,
                    CellValue     = new CellValue(filterValue.Label)
                };

                if (styleIndex != 0)
                {
                    cell.StyleIndex = styleIndex;
                }

                dataRow.DataCells.Add(new DataCell
                {
                    Value        = filterValue.Label,
                    PropertyInfo = filterValue.PropertyInfo
                });

                row.AppendChild(cell);
            }

            InsertRow((uint)rowIndex, worksheetPart, row);


            return(row);
        }
        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);
        }
示例#7
0
        protected RowMap GetHeaderMap(SharedStringTable sst, IEnumerable <Row> rows, IEnumerable <FilterValue> filterValues)
        {
            var rowMap = new RowMap();

            foreach (Row row in rows)
            {
                var cellsMap = GetHeaderCellsMap(sst, row, filterValues);

                if (cellsMap == null || !cellsMap.Any())
                {
                    continue;
                }

                rowMap.RowIndex = Int32.Parse(row.RowIndex);
                rowMap.CellMaps = cellsMap;

                break;
            }

            return(rowMap);
        }
示例#8
0
        private List <DataRow> ExtractBodyRows(SharedStringTable sst, RowMap rowMap, IEnumerable <Row> rows)
        {
            var firstBodyRowIndex = rowMap.RowIndex + 1;
            var rowList           = rows.Where(r => r.RowIndex >= firstBodyRowIndex).ToList();

            var dataRows = new List <DataRow>();

            var index = firstBodyRowIndex;


            foreach (var row in rowList)
            {
                // если расстояние между непустыми строками больше 1, значит таблица закончилась
                if (row.RowIndex - index > 1)
                {
                    break;
                }

                var cells = ExtractCells(sst, row, rowMap.CellMaps);

                // если не получил заполненных ячеек, то таблица закончилась
                if (!cells.Any())
                {
                    break;
                }

                dataRows.Add(new DataRow
                {
                    DataCells = cells
                });

                index++;
            }

            return(dataRows);
        }
 public void Reset()
 {
     RowMap.Clear();
 }
 public void Clear()
 {
     CurrentRow = null;
     RowMap.Clear();
 }
示例#11
0
        private async Task <IEnumerable <DataRow> > ExtractBodyRowsAsync(SharedStringTable sst, RowMap rowMap, IEnumerable <Row> rows)
        {
            var firstBodyRowIndex = rowMap.RowIndex + 1;
            var rowList           = rows.Where(r => r.RowIndex >= firstBodyRowIndex).ToList();

            var extractRowsTasks = rowList.Select(row =>
                                                  Task.Run(() =>
            {
                var cells = ExtractCells(sst, row, rowMap.CellMaps);

                return(new DataRow
                {
                    RowIndex = row.RowIndex,
                    DataCells = cells
                });
            }));


            var dataRows = await Task.WhenAll(extractRowsTasks);

            dataRows =
                dataRows
                .Where(r => r.DataCells.Any())
                .OrderBy(r => r.RowIndex)
                .ToArray();

            return(dataRows);
        }
示例#12
0
 /// <summary>
 /// Overloaded constructor
 /// </summary>
 /// <param name="rowMap">Initial data row</param>
 public Row(RowMap rowMap)
 {
     _row = rowMap;
 }