using System.Collections.Generic;
using System;
using System.Drawing;
using System.Diagnostics;
using System.Data;
using System.Collections;
using System.Windows.Forms;
using AR;

namespace vmsnet
{
	public partial class Frm_SelectCH
	{
		
        public Frm_SelectCH(DS1.channelDataTable lst)
        {

            // 디자이너에서 이 호출이 필요합니다.
            InitializeComponent();

            // InitializeComponent() 호출 뒤에 초기화 코드를 추가하세요.
            this.CheckedListBox1.Items.Clear();

            foreach (var item in lst)
            {
                ListViewItem lv = this.CheckedListBox1.Items.Add(System.Convert.ToString(item.cname));
                lv.SubItems.Add(item.cname.ToString());
                //lv.SubItems.Add(item.CH)
                lv.Checked = item.use;
                lv.Tag = item.idx;
                lv.BackColor = item.use ? Color.Lime : Color.White;
            }

            CheckedListBox1.ItemChecked += CheckedListBox1_ItemChecked;
        }


        public Frm_SelectCH(TrendCtrlII.CChinfo[] lst)
		{
			
			// 디자이너에서 이 호출이 필요합니다.
			InitializeComponent();
			
			// InitializeComponent() 호출 뒤에 초기화 코드를 추가하세요.
			this.CheckedListBox1.Items.Clear();
			
			foreach (var item in lst)
			{
				ListViewItem lv = this.CheckedListBox1.Items.Add(System.Convert.ToString(item.TITLE));
				lv.SubItems.Add(item.TITLE.ToString());
				//lv.SubItems.Add(item.CH)
				lv.Checked = item.Show;
				lv.Tag = item.Idx;
				lv.BackColor = item.Show ? Color.Lime : Color.White;
			}

            CheckedListBox1.ItemChecked += CheckedListBox1_ItemChecked;
		}

        private void CheckedListBox1_ItemChecked(object sender, ItemCheckedEventArgs e)
        {
            e.Item.BackColor = e.Item.Checked ? Color.Lime : Color.White;
        }

        public void Frm_SelectCH_Load(object sender, EventArgs e)
		{
			
		}
		
		public void Frm_SelectCH_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Escape)
			{
				this.Close();
			}
		}
		
		public void Button2_Click(object sender, EventArgs e)
		{ // 전체 선택
			foreach (ListViewItem item in CheckedListBox1.Items)
			{
				item.Checked = true;
                item.BackColor = item.Checked ? Color.Lime : Color.White;
            }
		}
		
		public void Button3_Click(object sender, EventArgs e)
		{ // 전체 해제
			foreach (ListViewItem item in CheckedListBox1.Items)
			{
				item.Checked = false;
                item.BackColor = item.Checked ? Color.Lime : Color.White;
            }
		}
		
		public void Button4_Click(object sender, EventArgs e)
		{
			foreach (ListViewItem item in CheckedListBox1.Items)
			{
				item.Checked = !item.Checked;
                item.BackColor = item.Checked ? Color.Lime : Color.White;
            }
		}
		
		public void Button1_Click(object sender, EventArgs e)
		{ // 확인
			if (CheckedListBox1.CheckedItems.Count > 10)
			{
				UTIL.MsgE("최대 10개까지 선택 가능 합니다");
				return ;
			}
			DialogResult = DialogResult.OK;
		}
	}
}
