using System.Windows;
using System.Windows.Media;
using InABox.Core;
using Syncfusion.Data;
using Syncfusion.UI.Xaml.Grid;
using Syncfusion.UI.Xaml.Grid.Cells;
using Syncfusion.UI.Xaml.TreeGrid;

namespace InABox.DynamicGrid;

public class DynamicGridDoubleColumn : DynamicGridNumericColumn< DoubleEditor, GridNumericColumn, TreeGridNumericColumn>
{

    protected override void Configure(GridNumericColumn column, DoubleEditor editor)
    {
        column.NumberDecimalDigits = GetDigits(editor);
        column.NumberGroupSeparator = ",";
        column.NumberGroupSizes = new Int32Collection(new[] { 3, 3, 3, 3, 3, 3 });
    }

    protected override void Configure(TreeGridNumericColumn column, DoubleEditor editor)
    {
        column.NumberDecimalDigits = GetDigits(editor);
        column.NumberGroupSeparator = ",";
        column.NumberGroupSizes = new Int32Collection(new[] { 3, 3, 3, 3, 3, 3 });
    }
    
    public override IDynamicGridSummary? Summary()
    {
        if (Definition.Editor.Summary == Core.Summary.None)
            return null;
        
        return Definition.Editor.Summary == Core.Summary.Sum
            ? new DynamicGridSumSummary<double>($"N{Editor!.Digits}")
            : new DynamicGridCountSummary();
    }

    public DynamicGridDoubleColumn(DynamicGridColumn definition) : base(definition)
    {
    }
}