public NativeCell(NSString cellId, FastCell fastCell) : base(UITableViewCellStyle.Default, cellId) { _fastCell = fastCell; _fastCell.PrepareCell(); _originalBindingContext = fastCell.BindingContext; var renderer = RendererFactory.GetRenderer(fastCell.View); _view = renderer.NativeView; ContentView.AddSubview(_view); }
public NativeCell(Android.Content.Context context, FastCell fastCell) : base(context) { FastCell = fastCell; fastCell.PrepareCell(); var renderer = RendererFactory.GetRenderer(fastCell.View); this.AddView(renderer.ViewGroup); // _view = renderer.NativeView; // ContentView.AddSubview (_view); }
public object GetBindingContextForReusedCell(FastCell cell) { if (OriginalBindingContextsForReusedItems.ContainsKey(cell)) { return(OriginalBindingContextsForReusedItems[cell]); } else { return(null); } }
public void RecycleCell(FastCell newCell) { if (newCell == _fastCell) { _fastCell.BindingContext = _originalBindingContext; } else { _fastCell.BindingContext = newCell.BindingContext; } }
public NativeCell(Android.Content.Context context, FastCell fastCell) : base(context) { FastCell = fastCell; fastCell.PrepareCell(); //var renderer = RendererFactory.GetRenderer(fastCell.View); //this.AddView(renderer.ViewGroup); var renderer = Xamarin.Forms.Platform.Android.Platform.CreateRendererWithContext(fastCell.View, context); this.AddView(renderer.View); }
public FastRow(FastGrid owner, object obj, Dictionary<FastColumn, PropertyInfo> columnProperty) { this.owner = owner; ValueObject = obj; if (owner.colorFormatter != null) { Color? clBack, clFont; owner.colorFormatter(ValueObject, out clBack, out clFont); BackgroundColor = clBack; FontColor = clFont; } string[] strings = null; if (owner.rowExtraFormatter != null) strings = owner.rowExtraFormatter(obj, columnProperty.Select(propertyInfo => propertyInfo.Key).ToList()); var counter = 0; foreach (var colPair in columnProperty) { var cell = new FastCell(); if (colPair.Value == null) { cells.Add(cell); continue; } // do format value var proVal = colPair.Value.GetValue(obj, null); cell.CellValue = proVal; cell.CellString = strings == null ? (colPair.Key.formatter != null ? colPair.Key.formatter(proVal) : colPair.Key.rowFormatter != null ? colPair.Key.rowFormatter(obj) : proVal == null ? colPair.Key.NullString : ObjectToString(proVal, colPair.Key.FormatString, colPair.Key.FractionDigits)) : strings[counter++]; if (colPair.Key.cellFormatting != null) { var args = new CellFormattingEventArgs { cellValue = cell.CellValue, resultedString = cell.CellString, column = colPair.Key, rowValue = obj, }; colPair.Key.cellFormatting(args); cell.CellString = args.resultedString; } cells.Add(cell); } }
public void RecycleCell(Android.Views.View view, FastCell newCell) { if (CellItemsByCoreCells.ContainsKey(view)) { var reusedItem = CellItemsByCoreCells[view]; if (OriginalBindingContextsForReusedItems.ContainsKey(newCell)) { reusedItem.BindingContext = OriginalBindingContextsForReusedItems[newCell]; } else { reusedItem.BindingContext = newCell.BindingContext; } } }
void CacheBindingContextForReusedCell(FastCell cell) { OriginalBindingContextsForReusedItems[cell] = cell.BindingContext; }
public void CacheCell(FastCell cell, Android.Views.View view) { CellItemsByCoreCells[view] = cell; OriginalBindingContextsForReusedItems[cell] = cell.BindingContext; }
public static void GridSummaryStatUserDrawCellText(int columnIndex, FastColumn column, FastCell cell, FastGrid.BrushesStorage brushes, Graphics g, Point leftTop, int cellWidth, int cellHeight, Font font, Brush brushFont, Color? fontColor, int rowIndex, int cellPadding) { var cellString = cell.CellString; var cellFont = column.ColumnFont ?? font; var brush = brushFont; if (fontColor.HasValue) brush = brushes.GetBrush(fontColor.Value); var leftString = cellString; var rightString = ""; if (cellString.IndexOf('\t') != -1) { leftString = cellString.Substring(0, cellString.IndexOf('\t')); rightString = cellString.Substring(cellString.IndexOf('\t') + 1); } g.DrawString(leftString, cellFont, brush, leftTop.X + cellPadding, leftTop.Y + cellHeight / 2, new StringFormat {Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center}); g.DrawString(rightString, cellFont, brush, leftTop.X + cellWidth - cellPadding, leftTop.Y + cellHeight / 2, new StringFormat {Alignment = StringAlignment.Far, LineAlignment = StringAlignment.Center}); }
private void OnUserDrawCellText(int columnIndex, FastColumn column, FastCell cell, BrushesStorage brushes, Graphics g, Point leftTop, int cellWidth, int cellHeightI, Font font, Brush brushFont, Color? fontColor, int rowIndex, int cellPaddingI) { if (userDrawCellText != null) userDrawCellText(columnIndex, column, cell, brushes, g, leftTop, cellWidth, cellHeightI, font, brushFont, fontColor, rowIndex, cellPaddingI); }
private void DrawCellText(int columnIndex, FastColumn column, FastCell cell, BrushesStorage brushes, Graphics g, Point leftTop, int cellWidth, int cellHeight, Font font, Brush brushFont, Color? fontColor, int rowIndex, int cellPadding) { if (userDrawCellText != null) { userDrawCellText(columnIndex, column, cell, brushes, g, leftTop, cellWidth, cellHeight, font, brushFont, fontColor, rowIndex, cellPadding); return; } var cellFont = column.ColumnFont ?? font; var brush = brushFont; if (fontColor.HasValue) brush = brushes.GetBrush(fontColor.Value); // apply hyperlink colors? if (column.IsHyperlinkStyleColumn) { var linkColor = column.ColorHyperlinkTextInactive; if (column.HyperlinkFontInactive != null) cellFont = column.HyperlinkFontInactive; if (owner.LastHoveredCell.HasValue) { var hoveredCell = owner.LastHoveredCell.Value; // is there cursor above? if (columnIndex == hoveredCell.X && rowIndex == hoveredCell.Y) { linkColor = column.ColorHyperlinkTextActive; if (column.HyperlinkFontActive != null) cellFont = column.HyperlinkFontActive; } } if (linkColor.HasValue) brush = brushes.GetBrush(linkColor.Value); } var cellString = cell.CellString; // Color render if (cell.CellValue is Color) { var c = (Color) cell.CellValue; g.FillRectangle(new SolidBrush(c), leftTop.X + cellPadding, leftTop.Y + 2, 25, cellHeight - 3); cellString = string.Format("{0}; {1}; {2}", c.B, c.G, c.R); leftTop.X += 25; } if (column.CellHAlignment == StringAlignment.Center) g.DrawString(cellString, cellFont, brush, leftTop.X + cellWidth / 2, leftTop.Y + cellHeight / 2, cellTextFormatHCenter); if (column.CellHAlignment == StringAlignment.Near) g.DrawString(cellString, cellFont, brush, leftTop.X + cellPadding, leftTop.Y + cellHeight / 2, cellTextFormatHNear); if (column.CellHAlignment == StringAlignment.Far) g.DrawString(cellString, cellFont, brush, leftTop.X + cellWidth - cellPadding, leftTop.Y + cellHeight / 2, cellTextFormatHFar); }