using System;
using System.Collections.Generic;
using System.ComponentModel;
using InABox.Core;

namespace InABox.DynamicGrid
{
    public abstract class DynamicColumnBase : BaseObject
    {
    }

    public enum DynamicGridOption
    {
        AddRows,
        EditRows,
        DeleteRows,
        FilterRows,
        SelectColumns,
        ExportData,
        ImportData,
        MultiSelect,
        DragSource,
        DragTarget,
        DirectEdit,
        ShowHelp,
        Print,
        RecordCount
    }

    public delegate bool OnFilterRecord(CoreRow row);

    public delegate void OnCreateItem(object sender, object item);

    public delegate T OnCreateItem<T>();

    public delegate void OnDefineLookup(ILookupEditorControl sender);

    public delegate void OnLookupsDefined(ILookupEditorControl sender);

    public delegate void OnGridCustomiseEditor(DynamicEditorGrid sender, DynamicGridColumn column, BaseEditor editor);

    public delegate void OnFormCustomiseEditor(IDynamicEditorForm sender, object[] items, DynamicGridColumn column, BaseEditor editor);

    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="sender"></param>
    /// <param name="items">The array of items being edited; <see langword="null"/> is synonymous with an empty array.</param>
    /// <param name="column"></param>
    /// <param name="editor"></param>
    public delegate void OnCustomiseEditor<T>(IDynamicEditorForm sender, T[]? items, DynamicGridColumn column, BaseEditor editor);

    public delegate void OnReconfigureEditors(DynamicEditorGrid sender);
    
    public delegate Dictionary<String,object?>? OnAfterEditorValueChanged(DynamicEditorGrid sender, String columnname);

    public delegate void OnGridChanged(IDynamicGrid sender);

    public delegate void OnLoadPage(IDynamicEditorPage page);

    public delegate void OnSelectPage(DynamicEditorGrid sender, BaseObject[]? items);

    public delegate void OnUnloadPage(IDynamicEditorPage page, bool saved);

    public delegate void OnCustomiseColumns(object sender, DynamicGridColumns columns);

    public delegate BaseEditor? OnGetEditor(DynamicGridColumn column);

    public delegate decimal OnGetEditorSequence(DynamicGridColumn column);

    public delegate object? OnDefineFilter(object sender, Type type);

    public delegate IList<string>? OnValidateData(object sender, BaseObject[] items);

    public delegate void OnPrintData(object sender);

    public class DynamicGridSelectionEventArgs : EventArgs
    {
        public DynamicGridSelectionEventArgs(CoreRow[]? rows)
        {
            Rows = rows;
        }

        public CoreRow[]? Rows { get; }
    }

    public delegate void SelectItemHandler(object sender, DynamicGridSelectionEventArgs e);

    public delegate void OnDoubleClick(object sender, HandledEventArgs args);

    public class DynamicGridCellClickEventArgs : HandledEventArgs
    {
        public CoreRow Row { get; set; }

        public DynamicGridColumn Column { get; set; }

        public DynamicGridCellClickEventArgs(CoreRow row, DynamicGridColumn column)
        {
            Row = row;
            Column = column;
        }
    }

    public delegate void OnCellDoubleClick(object sender, DynamicGridCellClickEventArgs args);

    public delegate void OnAfterReloadEventHandler(object sender);
}