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

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;

namespace EhLib
{
  [ToolboxItem(false)]
  public class DataVertGridBaseCellMan : BaseGridCellManager
  {
    #region privates
    #endregion privates

    public DataVertGridBaseCellMan()
    {

    }

    #region properties
    [Browsable(false)]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    public new DataVertGridEh Grid
    {
      get { return (DataVertGridEh)base.Grid; }
      set { base.Grid = value; }
    }
    #endregion

    #region methods
    protected internal override void OnPaintBackground(BaseGridCellPaintEventArgs e)
    {
      using (
        SolidBrush fillBrush = new SolidBrush(Grid.BackColor))
      {
        if ((BasePaintCellStates.Selected & e.State) != 0)
        {
          if (Grid.IsActiveControl())
            fillBrush.Color = SystemColors.Highlight;
          else
            fillBrush.Color = SystemColors.ButtonShadow;
        }

        Grid.PaintingFillRectangle(e.Graphics, fillBrush, e.CellClientRect);
      }
    }

    public override string GetDisplayText(int areaColIndex, int areaRowIndex)
    {
      return "GetDisplayText is not implemented";
    }
    #endregion
  }

  public class DataVertGridBaseIndicatorCellMan : DataVertGridBaseCellMan
  {
    protected BaseGridFillFixedCellEventArgs StyledPaintArgs = new BaseGridFillFixedCellEventArgs();

    protected internal override void OnGetCellBorderParams(BaseGridCellBorderEventArgs e)
    {
      if ((e.BorderType == GridCellBorderType.Left) || (e.BorderType == GridCellBorderType.Right))
      {
        e.Visible = Grid.TitleColumn.VertLine.Visible;
        e.IsExtent = true;
      }
      else
      {
        e.Visible = Grid.TitleColumn.HorzLine.Visible;
        e.IsExtent = true;
      }

      if (e.BorderType == GridCellBorderType.Top || e.BorderType == GridCellBorderType.Bottom)
      {
        e.Color = Grid.TitleColumn.HorzLine.Color;
        e.Style = Grid.TitleColumn.HorzLine.Style;
      }
      else
      {
        e.Color = Grid.TitleColumn.VertLine.Color;
        e.Style = Grid.TitleColumn.VertLine.Style;
      }
    }

    protected internal override bool IsSelected(int areaColIndex, int areaRowIndex)
    {
      return false;
    }

    protected internal virtual bool IsPressed(int col, int row,
        Rectangle paintRect,
        BasePaintCellStates state,
        int dataColIndex, int dataRowIndex)
    {
      return false;
    }

    protected internal override void OnPaintBackground(BaseGridCellPaintEventArgs e)
    {

      Color backColor = Grid.FixedBackColor;

      StyledPaintArgs.CellRect = e.CellClientRect;
      StyledPaintArgs.Graphics = e.Graphics;
      StyledPaintArgs.IsHot = false;
      StyledPaintArgs.IsPressed = IsPressed(e.ColIndex, e.RowIndex, e.CellClientRect, e.State, e.AreaColIndex, e.AreaRowIndex);
      StyledPaintArgs.IsSelected = (e.State & BasePaintCellStates.Selected) != 0;
      StyledPaintArgs.BackColor = backColor;
      StyledPaintArgs.FillStyle = Grid.FixedBackFiller.FillStyle;
      StyledPaintArgs.InnerBorder = Grid.FixedBackFiller.InnerBorder;
      StyledPaintArgs.FillColor = Grid.FixedBackFiller.Color;
      StyledPaintArgs.SecondFillColor = Grid.FixedBackFiller.SecondColor;

      Grid.GetDrawStyle().FillTitleCell(Grid, StyledPaintArgs);
    }
  }

}
