using Microsoft.UI.Xaml.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sonex.UserControls.DataGridView
{
    public sealed partial class DataGridView
    {
        public class SelectRange()
        {
            public CellVector? From { get; set; }
            public CellVector? To { get; set; }
            public bool Remove { get; set; }
            public RemoveOption RemoveOption { get; set; }

            internal void Clear()
            {
                From = null;
                To = null;
            }
            public bool IsInclude(Column columnHeader, int rowIndex)
            {
                if (From == null || To == null) return false;

                int left = Math.Min(From.Header.Index, To.Header.Index);
                int right = Math.Max(From.Header.Index, To.Header.Index);
                int top = Math.Min(From.RowIndex, To.RowIndex);
                int botton = Math.Max(From.RowIndex, To.RowIndex);
                bool v = columnHeader.Index >= left && columnHeader.Index <= right;
                bool h = rowIndex >= top && rowIndex <= botton;

                return h && v;
            }
            public bool IsInclude(int rowIndex)
            {
                if (From == null || To == null) return false;

                int top = Math.Min(From.RowIndex, To.RowIndex);
                int botton = Math.Max(From.RowIndex, To.RowIndex);
                bool h = rowIndex >= top && rowIndex <= botton;

                return h;
            }

            public bool IsInclude(Column columnHeader)
            {
                if (From == null || To == null) return false;

                int left = Math.Min(From.Header.Index, To.Header.Index);
                int right = Math.Max(From.Header.Index, To.Header.Index);
                bool v = columnHeader.Index >= left && columnHeader.Index <= right;

                return v;
            }
        }
        public enum RemoveOption
        {
            Row, Column
        }
    }
}
