using System;

namespace FastReport.AdvMatrix
{
    internal class InteractiveSortInfo
    {
        internal SortInfo Column { get; private set; }
        internal SortInfo Row { get; private set; }

        public InteractiveSortInfo(MatrixData matrixData)
        {
            Column = new SortInfo(matrixData, true);
            Row = new SortInfo(matrixData, false);
        }
        
        internal class SortInfo
        {
            private MatrixData matrixData;
            public bool IsColumn { get; private set; }
            public int Index { get; set; }
            public SortOrder Sort { get; set; }
            public HeaderDescriptor Descriptor
            {
                get
                {
                    HeaderData data = IsColumn ? matrixData.Columns.Data.FindByIndex(Index) : matrixData.Rows.Data.FindByIndex(Index);
                    if (data != null)
                        return data.Descriptor;
                    return null;
                }
            }

            public SortInfo(MatrixData matrixData, bool isColumn)
            {
                this.matrixData = matrixData;
                IsColumn = isColumn;
            }
        }
    }
}