using System;
using FastReport.Table;

namespace FastReport.AdvMatrix
{
    internal static partial class CellExt
    {
        // cell extension methods
        public static CellDescriptor GetDescriptor(this TableCell cell)
        {
            return (CellDescriptor)cell.CellData.Value;
        }

        public static void SetDescriptor(this TableCell cell, CellDescriptor descriptor)
        {
            cell.CellData.Value = descriptor;
        }

        public static MatrixCollapseButton GetCollapseButton(this TableCell cell)
        {
            if (cell.Objects == null)
                return null;
            foreach (Base c in cell.Objects)
            {
                if (c is MatrixCollapseButton)
                    return c as MatrixCollapseButton;
            }
            return null;
        }

        public static MatrixSortButton GetSortButton(this TableCell cell)
        {
            if (cell.Objects == null)
                return null;
            foreach (Base c in cell.Objects)
            {
                if (c is MatrixSortButton)
                    return c as MatrixSortButton;
            }
            return null;
        }
    }
}