/// <summary> /// Adds the specified number of rows to the bottom of the table. /// </summary> /// <param name="count">The number of rows to add to the bottom of the table.</param> /// <param name="headerTexts">Optional strings to apply to the header labels of the new rows.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="count"/> is less than 0.</exception> public void AddRows(int count, params string[] headerTexts) { if (count < 0) { throw new ArgumentOutOfRangeException("count", "Value cannot be less than 0."); } var list = RowHeaders.ToList(); int currentCount = list.Count; for (int i = 0; i < count; i++) { var label = new Label(); label.Text = headerTexts != null && headerTexts.Length > i ? headerTexts[i] : null; label.HorizontalAlignment = HorizontalAlignment.Left; label.VerticalAlignment = VerticalAlignment.Center; NativeCell.AddChild(label); list.Add(label); } RowHeaders = new ReadOnlyCollection <Label>(list); for (int i = 0; i < columnControls.Length; i++) { var cc = columnControls[i]; Array.Resize(ref cc, RowCount); } }
public string GetDescription(DataSchema dataSchema) { var parts = new List <string>(); if (RowHeaders.Any()) { parts.Add(Resources.PivotSpec_GetDescription_Row_Headers_); parts.AddRange(RowHeaders.Select(header => header.Caption ?? header.SourceColumn.ToString())); } if (ColumnHeaders.Any()) { if (parts.Any()) { parts.Add(string.Empty); } parts.Add(Resources.PivotSpec_GetDescription_Column_Headers_); parts.AddRange(ColumnHeaders.Select(header => header.Caption ?? header.SourceColumn.ToString())); } if (Values.Any()) { if (parts.Any()) { parts.Add(string.Empty); } parts.Add(Resources.PivotSpec_GetDescription_Values_); parts.AddRange(Values.Select(value => (ColumnCaption.ExplicitCaption(value.Caption) ?? value.AggregateOperation.QualifyColumnCaption(value.SourceColumn.ToColumnCaption())) .GetCaption(dataSchema.DataSchemaLocalizer))); } return(string.Join(Environment.NewLine, parts)); }
/// <summary> /// Removes the specified number of rows from the bottom of the table. /// </summary> /// <param name="count">The number of rows to remove from the bottom of the table.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="count"/> is less than 0 -or- /// when <paramref name="count"/> is greater than the number of rows currently in the table.</exception> public void RemoveRows(int count) { if (count < 0) { throw new ArgumentOutOfRangeException("count", "Value cannot be less than 0."); } if (count > RowCount) { throw new ArgumentOutOfRangeException("count", "Value cannot be greater than the number of rows currently in the table."); } var list = RowHeaders.ToList(); for (int i = list.Count - 1; i >= list.Count - count; i--) { NativeCell.RemoveChild(list[i]); list.RemoveAt(i); foreach (var cc in columnControls) { NativeCell.RemoveChild(cc[i]); } } for (int i = 0; i < columnControls.Length; i++) { Array.Resize(ref columnControls[i], RowCount - count); } RowHeaders = new ReadOnlyCollection <Label>(list); }
private void readTGameplayDamageResistanceContainer(NdfObject obj) { var armourFamilies = obj.PropertyValues[1].Value as NdfCollection; var damageFamilies = obj.PropertyValues[0].Value as NdfCollection; var values = obj.PropertyValues[2].Value as NdfCollection; TableData.Clear(); TableData.TableName = "table"; foreach (var armourFamily in armourFamilies) { TableData.Columns.Add(armourFamily.Value.ToString()); } int k = 0; for (var i = 0; i < damageFamilies.Count; i++) { RowHeaders.Add(damageFamilies[i].Value.ToString()); var row = TableData.NewRow(); TableData.Rows.Add(row); var damageFamily = new ObservableCollection <NdfPropertyValue>(); for (var j = 0; j < armourFamilies.Count; j++) { row[j] = values[k++].Value; } } TableData.AcceptChanges(); }
private void UpdateRowHeaders() { RowHeaders.Clear(); foreach (var rowHeaderViewModel in GenRows(SelectedMcu)) { RowHeaders.Add(rowHeaderViewModel); } }
public override int GetHashCode() { unchecked { var hashCode = RowHeaders.GetHashCode(); hashCode = (hashCode * 397) ^ ColumnHeaders.GetHashCode(); hashCode = (hashCode * 397) ^ Values.GetHashCode(); return(hashCode); } }
private void UserControl_LayoutUpdated(object sender, EventArgs e) { List <FrameworkElement> rowHeaders = ItemsIn(RowHeaderContainer); List <FrameworkElement> rows = ItemsIn(RowContainer); for (int i = 0; i < rowHeaders.Count && i < rows.Count; i++) { rowHeaders[i].Height = rows[i].ActualHeight; } ColumnHeaders.ScrollToHorizontalOffset(Scroller.HorizontalOffset); RowHeaders.ScrollToVerticalOffset(Scroller.VerticalOffset); }
public DataTableImpl(IEnumerable <Tuple <TR, TC, TD> > data) { foreach (var tuple in data) { if (RowHeaders.All(r => r.Guid != tuple.Item1.Guid)) { _rowHeaders.Add(tuple.Item1); } if (ColumnHeaders.All(c => c.Guid != tuple.Item2.Guid)) { _columnHeaders.Add(tuple.Item2); } _dataDictionary[tuple.Item1.Guid.Add(tuple.Item2.Guid)] = tuple.Item3; } }
private void Button_Click(object sender, RoutedEventArgs e) { var random = new Random(); var row = random.Next(50, 100); var col = random.Next(50, 100); RowHeaders.Clear(); Enumerable.Range(0, row).ToList() .ForEach(r => RowHeaders.Add($"R{r}")); ColumnHeaders.Clear(); Enumerable.Range(0, col).ToList() .ForEach(c => ColumnHeaders.Add($"C{c}")); Items.Clear(); RowHeaders.ToList() .ForEach(r => Items.Add(new ObservableCollection <string>(ColumnHeaders.Select(c => $"{c}-{r}")))); }
public void Reset() { cells = null; if (RowHeaders == null) { RowHeaders = new List <double>(); } else { RowHeaders.Clear(); } if (ColumnHeaders == null) { ColumnHeaders = new List <double>(); } else { ColumnHeaders.Clear(); } }
protected bool Equals(PivotSpec other) { return(RowHeaders.Equals(other.RowHeaders) && ColumnHeaders.Equals(other.ColumnHeaders) && Values.Equals(other.Values)); }
public ITable <TItem> WithRows <TKey>(string name, Func <TItem, TKey> selector) { RowHeaders.Add(CreateIdenttiyAxis(name, selector)); return(this); }
public ITable <TItem> WithExplicitRow(string name, params Expression <Func <TItem, bool> >[] selectors) { RowHeaders.Add(CreateExplicitAxis(name, selectors)); return(this); }
public double InterpolateXY(double xValue, double yValue) { return(InterpolateXY(xValue, yValue, ColumnHeaders.ToArray(), RowHeaders.ToArray(), cells.ToArray())); }
public IEnumerable <RowItem> GroupAndTotal(IEnumerable <RowItem> rows, IList <DataPropertyDescriptor> propertyDescriptors) { var rowsByRowHeader = rows.ToLookup(row => { CancellationToken.ThrowIfCancellationRequested(); return(ImmutableList.ValueOf(RowHeaders.Select(tuple => tuple.Item1.GetValue(row)))); }); propertyDescriptors.AddRange(RowHeaders.Select((tuple, index) => new IndexedPropertyDescriptor(DataSchema, index, tuple.Item1, tuple.Item2))); var columnHeaders = new Dictionary <ImmutableList <object>, int>(); var resultRows = new List <RowItem>(); List <List <object> > aggregateValues = new List <List <object> >(); foreach (IGrouping <ImmutableList <object>, RowItem> rowGroup in rowsByRowHeader) { foreach (var list in aggregateValues) { list.Clear(); } var rowValues = rowGroup.Key.ToList(); foreach (RowItem row in rowGroup) { // ReSharper disable AccessToForEachVariableInClosure var columnHeader = ImmutableList.ValueOf(ColumnHeaders.Select(pd => pd.GetValue(row))); // ReSharper restore AccessToForEachVariableInClosure int columnHeaderIndex; if (!columnHeaders.TryGetValue(columnHeader, out columnHeaderIndex)) { columnHeaderIndex = columnHeaders.Count; columnHeaders.Add(columnHeader, columnHeaderIndex); foreach (var aggregateColumn in AggregateColumns) { propertyDescriptors.Add(MakePropertyDescriptor(propertyDescriptors.Count, columnHeader, aggregateColumn.Item1, aggregateColumn.Item2, aggregateColumn.Item3)); aggregateValues.Add(new List <object>()); } } for (int iAggColumn = 0; iAggColumn < AggregateColumns.Count; iAggColumn++) { var value = AggregateColumns[iAggColumn].Item1.GetValue(row); if (value != null) { var aggList = aggregateValues[iAggColumn + columnHeaderIndex * AggregateColumns.Count]; aggList.Add(value); } } } for (int iGroup = 0; iGroup < columnHeaders.Count; iGroup++) { for (int iAggColumn = 0; iAggColumn < AggregateColumns.Count; iAggColumn++) { int aggregateValueIndex = iGroup * AggregateColumns.Count + iAggColumn; var individualValues = aggregateValues[aggregateValueIndex]; if (individualValues.Count == 0) { rowValues.Add(null); } else { rowValues.Add(AggregateColumns[iAggColumn].Item3.CalculateValue(DataSchema, individualValues)); } } } resultRows.Add(new RowItem(rowValues)); } return(resultRows); }