123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using System.Collections.Generic;
- using System.Windows.Media;
- using InABox.Core;
- using Syncfusion.Data;
- using Syncfusion.UI.Xaml.Grid;
- using Syncfusion.UI.Xaml.TreeGrid;
- namespace InABox.DynamicGrid;
- public class DynamicGridCurrencyColumn<TEntity> : DynamicGridNumericColumn<TEntity, CurrencyEditor, GridCurrencyColumn, TreeGridCurrencyColumn> where TEntity : BaseObject
- {
- protected override void Configure(GridCurrencyColumn column, CurrencyEditor editor)
- {
- column.CurrencyDecimalDigits = GetDigits(editor);
- column.CurrencySymbol = string.IsNullOrEmpty(editor.CurrencySymbol) ? "$" : $"{editor.CurrencySymbol} ";
- column.CurrencyGroupSeparator = ",";
- column.CurrencyGroupSizes = new Int32Collection(new[] { 3, 3, 3, 3, 3, 3 });
- }
- protected override void Configure(TreeGridCurrencyColumn column, CurrencyEditor editor)
- {
- column.CurrencyDecimalDigits = GetDigits(editor);
- column.CurrencySymbol = string.IsNullOrEmpty(editor.CurrencySymbol) ? "$" : $"{editor.CurrencySymbol} ";
- column.CurrencyGroupSeparator = ",";
- column.CurrencyGroupSizes = new Int32Collection(new[] { 3, 3, 3, 3, 3, 3 });
- }
- public override GridSummaryColumn? Summary()
- {
- if (Definition == null || Definition.Editor.Summary == Core.Summary.None)
- return null;
-
- var format = Definition.Editor.Summary == Core.Summary.Count
- ? "N0"
- : $"C{Editor!.Digits}";
-
- var summary = new GridSummaryColumn
- {
- Name = MappingName,
- Format = "{" + (Definition.Editor.Summary == Core.Summary.Sum ? "Sum" : "Count") + ":" + format + "}",
- MappingName = MappingName,
- SummaryType = Definition.Editor.Summary == Core.Summary.Sum
- ? SummaryType.DoubleAggregate
- : SummaryType.CountAggregate,
- CustomAggregate = new DynamicGridDoubleAggregate()
- };
- return summary;
- }
- public DynamicGridCurrencyColumn(DynamicGridColumn definition) : base(definition)
- {
- }
- }
|