public static DataGridColumn Create(RelationalColumn column) { var sheetDef = column.Header.SheetDefinition; Type defType = null; if (sheetDef != null) defType = sheetDef.GetValueType(column.Index); var targetType = defType ?? column.Reader.Type; var header = BuildHeader(column); var binding = CreateCellBinding(column); DataGridColumn target = null; if (column.Header.Variant == 1) { if (typeof(SaintCoinach.Imaging.ImageFile).IsAssignableFrom(targetType)) target = new RawDataGridImageColumn(column) { Binding = binding, }; else if (typeof(System.Drawing.Color).IsAssignableFrom(targetType)) target = new RawDataGridColorColumn(column) { Binding = binding }; } target = target ?? new RawDataGridTextColumn(column) { Binding = binding }; target.Header = header; target.IsReadOnly = true; target.CanUserSort = true; return target; }
private static Binding CreateCellBinding(RelationalColumn column) { return new Binding { Converter = CellConverterInstance, ConverterParameter = column.Index, Mode = BindingMode.OneWay }; }
private static string BuildHeader(RelationalColumn column) { var sb = new StringBuilder(); sb.Append(column.Index); if (!string.IsNullOrWhiteSpace(column.Name)) sb.AppendFormat(": {0}", column.Name); sb.Append(Environment.NewLine); sb.Append(column.Reader.Type.Name); if (column.ValueType != column.Reader.Name) sb.AppendFormat(" > {0}", column.ValueType); return sb.ToString(); }
public IRelationalRow IndexedLookup(string indexName, int key) { if (key == 0) { return(null); } RelationalDataIndex <T> index = _indexes.GetOrAdd(indexName, i => { RelationalColumn column = Header.FindColumn(indexName); if (column == null) { throw new KeyNotFoundException(); } return(new RelationalDataIndex <T>(this, column)); }); return(index[key]); }