DynamicGridDoubleColumn.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System.Windows;
  2. using System.Windows.Media;
  3. using InABox.Core;
  4. using Syncfusion.Data;
  5. using Syncfusion.UI.Xaml.Grid;
  6. using Syncfusion.UI.Xaml.Grid.Cells;
  7. using Syncfusion.UI.Xaml.TreeGrid;
  8. namespace InABox.DynamicGrid;
  9. public class DynamicGridDoubleColumn<TEntity> : DynamicGridNumericColumn<TEntity, DoubleEditor, GridNumericColumn, TreeGridNumericColumn> where TEntity : BaseObject
  10. {
  11. protected override void Configure(GridNumericColumn column, DoubleEditor editor)
  12. {
  13. column.NumberDecimalDigits = GetDigits(editor);
  14. column.NumberGroupSeparator = ",";
  15. column.NumberGroupSizes = new Int32Collection(new[] { 3, 3, 3, 3, 3, 3 });
  16. }
  17. protected override void Configure(TreeGridNumericColumn column, DoubleEditor editor)
  18. {
  19. column.NumberDecimalDigits = GetDigits(editor);
  20. column.NumberGroupSeparator = ",";
  21. column.NumberGroupSizes = new Int32Collection(new[] { 3, 3, 3, 3, 3, 3 });
  22. }
  23. public override GridSummaryColumn? Summary()
  24. {
  25. if (Definition == null || Definition.Editor.Summary == Core.Summary.None)
  26. return null;
  27. var format = Definition.Editor.Summary == Core.Summary.Count
  28. ? "N0"
  29. : $"N{Editor!.Digits}";
  30. var summary = new GridSummaryColumn
  31. {
  32. Name = MappingName,
  33. Format = "{" + (Definition.Editor.Summary == Core.Summary.Sum ? "Sum" : "Count") + ":" + format + "}",
  34. MappingName = MappingName,
  35. SummaryType = Definition.Editor.Summary == Core.Summary.Sum
  36. ? SummaryType.DoubleAggregate
  37. : SummaryType.CountAggregate,
  38. CustomAggregate = new DynamicGridDoubleAggregate()
  39. };
  40. return summary;
  41. }
  42. public DynamicGridDoubleColumn(DynamicGridColumn definition) : base(definition)
  43. {
  44. }
  45. }