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 void Pin(string header)
        {

            var column = _Columns.FirstOrDefault(x => x.Title.Equals(header,StringComparison.OrdinalIgnoreCase));
            if (column != null && column.IsPinned == false)
            {
                column.Index -= 100000; // Force reordering
                _NeedCalcHeaders = true;
                RequestRender();
            }
        }
        public void UnPin(string header)
        {
            var column = _Columns.First(x => x.Title.Equals(header, StringComparison.OrdinalIgnoreCase));
            if (column != null && column.IsPinned == true)
            {
                column.Index += 100000;
                _NeedCalcHeaders = true;
                RequestRender();
            }
        }
        public void HideColumn(string header)
        {

            var column = _Columns.FirstOrDefault(x => x.Title.Equals(header, StringComparison.OrdinalIgnoreCase));
            if (column != null && column.IsHiden == false)
            {
                column.isSelected = false;
                column.Index += 1100000; // Force reordering
                _NeedCalcHeaders = true;
                RequestRender();
            }
        }
        public void ShowColumn(string header)
        {

            var column = _Columns.FirstOrDefault(x => x.Title.Equals(header, StringComparison.OrdinalIgnoreCase));
            if (column != null && column.IsHiden == true)
            {
                column.Index -= 1100000; // Force reordering
                _NeedCalcHeaders = true;
                RequestRender();
            }
        }
    }
}
