//------------------------------------------------------------------------------
// <copyright file=”*.cs” company=”EhLib Team”>
//     Copyright (c) 2017 Dmitry V. Bolshakov   
// </copyright>
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;

namespace EhLib.Design
{
  public class DataVertGridDesigner : DataAxisGridDesigner
  {
    private DesignerActionListCollection actionLists;

    internal ISelectionService SelService;

    #region constructor
    public DataVertGridDesigner()
    {

    }

    public override void Initialize(IComponent component)
    {
      base.Initialize(component);
      SelService = (ISelectionService)GetService(typeof(ISelectionService));
      if (SelService != null)
      {
        SelService.SelectionChanged += SelService_SelectionChanged;
        SelService.SelectionChanging += SelService_SelectionChanging;
      }

      //Grid.DataGridDesigner = this;
      //Grid.OrderedColumnsListChanged += Grid_OrderedColumnsListChanged;

    }

    protected override void Dispose(bool disposing)
    {
      if (disposing)
      {
        //Grid.DataGridDesigner = null;
        //Grid.OrderedColumnsListChanged -= Grid_OrderedColumnsListChanged;

        if (SelService != null)
        {
          SelService.SelectionChanged -= SelService_SelectionChanged;
          SelService.SelectionChanging -= SelService_SelectionChanging;
        }
      }

      base.Dispose(disposing);
    }
    #endregion

    internal new DataGridEh Grid
    {
      get { return this.Component as DataGridEh; }
    }

    public override string PropAxisBarName
    {
      get { return "Row"; }
    }

    public override string PropAxisBarsName
    {
      get { return "Rows"; }
    }

    public override Type StaticPropBarCollectionType
    {
      get { return typeof(DataVertGridStaticRowsCollection); }
    }

    public override DesignerActionListCollection ActionLists
    {
      get
      {
        if (actionLists == null)
        {
          actionLists = new DesignerActionListCollection();
          actionLists.Add(new DataAxisGridChooseDataSourceActionList(this));
          actionLists.Add(new DataAxisGridActionList(this));
          actionLists.Add(new DataAxisGridPropertiesActionList(this));
          actionLists.AddRange(base.ActionLists);
        }
        return actionLists;
      }
    }

    public override DataAxisGridPropertyBarsEditor CreatePropertyBarsEditor()
    {
      return new DataVertGridRowsEditor(StaticPropBarCollectionType);
    }

    private void SelService_SelectionChanged(object sender, EventArgs e)
    {
      Control.Invalidate();
    }

    private void SelService_SelectionChanging(object sender, EventArgs e)
    {

    }
  }
}
