/// <summary> /// Creates a <see cref="T:System.Windows.FrameworkElement" /> responsible for editing the value in a grid /// cell at the given coordinates. /// </summary> /// <param name="grid"> /// <see cref="T:C1.WPF.FlexGrid.C1FlexGrid" /> that owns the cell. /// </param> /// <param name="cellType"> /// <see cref="T:C1.WPF.FlexGrid.CellType" /> that specifies the type of cell to be created. /// </param> /// <param name="rng"> /// <see cref="T:C1.WPF.FlexGrid.CellRange" /> that specifies the row and column represented by the cell. /// </param> /// <returns>A new <see cref="T:System.Windows.FrameworkElement" /> responsible for representing the grid cell.</returns> public virtual FrameworkElement CreateCellEditor(C1FlexGrid grid, CellType cellType, CellRange rng) { Border bdr = CreateCellBorder(grid, cellType, rng); if (grid.EditorBackground != null) { bdr.Background = grid.EditorBackground; } if (!grid.IsRangeValid(rng)) { return bdr; } CreateCellContentEditor(grid, bdr, rng); CustomizeCellStyle(grid, cellType, rng, bdr, true); GroupRow groupRow = grid.Rows[rng.Row] as GroupRow; if (groupRow != null && rng.Column <= grid.Columns.FirstVisibleIndex) { Brush foreground = GetForegroundBrush(grid, groupRow, grid.GroupRowForeground); FrameworkElement glyphTree = GetGlyphTree(groupRow, groupRow.IsCollapsed, foreground); SetBorderContent(bdr, glyphTree, bdr.Child, 0); } return bdr; }
internal static decimal GetValue(C1FlexGrid grid, Aggregate agg, CellRange rng) { if (agg == Aggregate.Custom) { CustomAggregateEventArgs customAggregateEventArg = new CustomAggregateEventArgs(grid.Cells, rng); grid.OnCustomAggregate(customAggregateEventArg); return customAggregateEventArg.Result; } decimal num = new decimal(0); decimal num1 = num; decimal num2 = num; decimal num3 = num; decimal num4 = num; decimal num5 = num; bool flag = false; switch (agg) { case Aggregate.Std: case Aggregate.Var: case Aggregate.StdPop: case Aggregate.VarPop: { flag = true; break; } } foreach (CellRange cell in rng.Cells) { if (!grid.IsRangeValid(cell)) { continue; } Row item = grid.Rows[cell.Row]; Column column = grid.Columns[cell.Column]; if (!grid.IncludeInAggregate(item, column)) { continue; } object dataRaw = item.GetDataRaw(column); if (Equals(dataRaw, string.Empty)) { dataRaw = null; } if (dataRaw is bool) { dataRaw = ((bool) dataRaw ? 1 : 0); } if (dataRaw is DateTime) { dataRaw = null; } if (dataRaw != null && grid.TryChangeType(ref dataRaw, typeof (decimal))) { decimal num6 = (decimal) dataRaw; if (num5 == new decimal(0)) { decimal num7 = num6; num1 = num7; num2 = num7; } if (num6 < num1) { num1 = num6; } if (num6 > num2) { num2 = num6; } num4 = num4 + num6; if (flag) { num3 = num3 + (num6*num6); } } num5 = num5++; } decimal num8 = (num5 == new decimal(0) ? new decimal(0) : num4/num5); switch (agg) { case Aggregate.Sum: { return num4; } case Aggregate.Count: { return num5; } case Aggregate.Average: { return num8; } case Aggregate.Maximum: { return num2; } case Aggregate.Minimum: { return num1; } case Aggregate.Range: { return num2 - num1; } case Aggregate.Std: { if (num5 <= new decimal(1)) { return new decimal(0); } return (decimal) Math.Sqrt((double) ((((num3/num5) - (num8*num8))*num5)/num5--)); } case Aggregate.Var: { if (num5 <= new decimal(1)) { return new decimal(0); } return (((num3/num5) - (num8*num8))*num5)/num5--; } case Aggregate.StdPop: { if (num5 <= new decimal(1)) { return new decimal(0); } return (decimal) Math.Sqrt((double) ((num3/num5) - (num8*num8))); } case Aggregate.VarPop: { if (num5 <= new decimal(1)) { return new decimal(0); } return (num3/num5) - (num8*num8); } } return new decimal(0); }