using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FCOMMON
{
    public partial class fSelectProcess : fBase
    {
        public List<string> values = new List<string>();
        string[] curlist = new string[] { };
        public fSelectProcess(string[] allList,string[] curlist_)
        {
            InitializeComponent();
            values.AddRange(allList);
            curlist = curlist_;
        }

        private void fSelectProcess_Load(object sender, EventArgs e)
        {
            EnsureVisibleAndUsableSize();
            //공정목록
            cmbProcess.Items.Clear();
            //cmbProcess.Items.Add("--전체--");

            foreach(var item in values)
            {
                cmbProcess.Items.Add(item, curlist.Contains(item));
            }
        }
      
        private void button1_Click(object sender, EventArgs e)
        {
            values.Clear();
            for (int i = 0; i <= (cmbProcess.Items.Count - 1); i++)
            {
                if (cmbProcess.GetItemChecked(i))
                {
                    values.Add(cmbProcess.Items[i].ToString());
                }
            } 
            if(values.Count < 1)
            {
                FCOMMON.Util.MsgE("공정선택이 필요 합니다");
                return;
            }
            DialogResult = DialogResult.OK;
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            for (int i = 0; i <= (cmbProcess.Items.Count - 1); i++)
            {
                cmbProcess.SetItemChecked(i, true);
            }
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            for (int i = 0; i <= (cmbProcess.Items.Count - 1); i++)
            {
                cmbProcess.SetItemChecked(i, false);
            }
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            for (int i = 0; i <= (cmbProcess.Items.Count - 1); i++)
            {
                var cur = cmbProcess.GetItemChecked(i);
                cmbProcess.SetItemChecked(i, !cur);
            }
        }
    }
}
