using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using PostCardHitsuji.DataClient.Model;

namespace PostCardHitsuji.Ui.Controls
{
    public partial class NewLayoutMessageItemUserControl : UserControl
    {
        public List<LayoutIllustContentModel> BindingItems
        {
            get
            {
                List<LayoutIllustContentModel> bindItems = new List<LayoutIllustContentModel>();
                foreach (LayoutIllustContentModel item in dataGridView1.Rows)
                    bindItems.Add(item);
                return bindItems;
            }
        }

        public NewLayoutMessageItemUserControl()
        {
            InitializeComponent();
            this.Load += new EventHandler(load);
        }


        private void load(object sender, EventArgs ev)
        {
            //イラストアイテムのモデルを登録
            List<LayoutIllustContentModel> illustItems = new List<LayoutIllustContentModel>();
            for (int index = 0; index < 4; index++)
            {
                illustItems.Add(new LayoutIllustContentModel());
            }
            dataGridView1.DataSource = illustItems;

            dataGridView1.CellContentClick += new DataGridViewCellEventHandler(onClickedColorCell);
            dataGridView1.CellClick += new DataGridViewCellEventHandler(onClickedColorCell);

        }

        private void onClickedColorCell(object sender, DataGridViewCellEventArgs ev)
        {
            if (ev.RowIndex < 0 || ev.ColumnIndex != COLOR.Index)
                return;

            ColorDialog dialog = new ColorDialog();
            if (dialog.ShowDialog(this) == DialogResult.OK)
            {
                Color color = dialog.Color;
                dataGridView1.CurrentCell.Style.BackColor = color;
                dataGridView1.CurrentCell.Style.ForeColor = color;

            }

        }

        private void dataGridView1_DragEnter(object sender, DragEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("");
        }


    }
}
