DynamicGridCurrencyColumn.cs 2.1 KB

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