public string GetContentFormatted(long id) { var content = GetContent(id); var formattedContent = contentFormatter.Format(content); return(formattedContent); }
public Matrix( List <T> cells, Expression <Func <T, string> > colExpr, Expression <Func <T, string> > rowExpr, Func <IEnumerable <T>, string, string, object> cellRenderer, IContentFormatter formatter = null ) { _contentFormatter = formatter ?? new DefaultContentFormatter(); this.AddClass("matrix"); var cols = cells.AsQueryable().GroupBy(colExpr).Select(e => e.Key).Distinct().ToList(); var rows = cells.AsQueryable().GroupBy(rowExpr).Select(e => e.Key).Distinct().ToList(); this.Styles["grid-template-columns"] = $"auto repeat({cols.Count}, 1fr);"; var colFunc = colExpr.Compile(); var rowFunc = rowExpr.Compile(); Div MakeColHeader(object label) { var div = new Div(new Span(label.ToString())); div.SetClass("col-header"); return(div); } Div MakeRowHeader(object label) { var div = new Div(new Span(label.ToString())); div.SetClass("row-header"); return(div); } Div MakeCell(object content) { var div = new Div(_contentFormatter.Format(content)); div.SetClass("cell"); return(div); } this.VisualTree.AddRange(cols.Select(MakeColHeader).ToArray().Prepend(new Div(new Literal("")))); foreach (var row in rows) { this.VisualTree.AddRange( cols.Select(col => cellRenderer( cells.Where(e => colFunc(e).Equals(col) && rowFunc(e).Equals(row)), col, row)).Select(MakeCell).ToArray() .Prepend(MakeRowHeader(row)) ); } }
public EntityGrid <T> Empty(object content) { _empty = _formatter.Format(content); return(this); }
internal virtual IEnumerable <AxisLabelModel> GenerateLabels() { AxisPlotMode plotMode = this.ActualPlotMode; int labelIndex = 0; int startIndex = this.LabelOffset; int labelStep = this.LabelInterval; int skipLabelCount = 1; IContentFormatter labelFormatter = this.ContentFormatter; object owner = this.Presenter; string format = this.GetLabelFormat(); // generate label for each major tick foreach (AxisTickModel tick in this.ticks) { if (labelIndex < startIndex) { labelIndex++; continue; } // skip minor ticks if (tick.Type == TickType.Minor) { continue; } if (skipLabelCount > 1) { skipLabelCount--; continue; } // no need to process last tick if we are plotting between ticks if (plotMode == AxisPlotMode.BetweenTicks && RadMath.IsOne(this.IsInverse ? 1 - tick.normalizedValue : tick.normalizedValue)) { break; } AxisLabelModel label = new AxisLabelModel(); object content = this.GetLabelContent(tick); if (labelFormatter != null) { content = labelFormatter.Format(owner, content); } else if (!string.IsNullOrEmpty(format)) { content = string.Format(CultureInfo.CurrentUICulture, format, content); } label.Content = content; tick.associatedLabel = label; if (plotMode == AxisPlotMode.BetweenTicks) { decimal length = tick.NormalizedForwardLength; if (length == 0) { length = tick.NormalizedBackwardLength; } tick.associatedLabel.normalizedPosition = tick.normalizedValue + (length / 2); } else { tick.associatedLabel.normalizedPosition = tick.normalizedValue; } yield return(label); skipLabelCount = labelStep; } }
public Control Render(object value, GridColumn <T> column, T _) { return(_formatter.Format(value)); }
public void Update(object value) { _dumpContainer.Content = _contentFormatter.Format(value, emptyContent: "-"); }