using DevExpress.XtraEditors;
using LolDataRequestLib;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static lol_coder.Data.DataControl;
using static LolDataRequestLib.DataManager;

namespace lol_coder.Forms.Frame
{
    public partial class BanPickFrame : UserControl
    {
        Timer timer = new Timer();

        MainForm mainForm;
        public BanPickFrame(MainForm _mainForm)
        {
            InitializeComponent();

            mainForm = _mainForm;

            timer.Interval = 1000;
            timer.Tick += new EventHandler(timer_Tick);

            fearB1_5.Image = picBlue1.Image;
            fearB1_4.Image = picBlue2.Image;
            fearB1_3.Image = picBlue3.Image;
            fearB1_2.Image = picBlue4.Image;
            fearB1_1.Image = picBlue5.Image;

            fearR1_5.Image = picRed1.Image;
            fearR1_4.Image = picRed2.Image;
            fearR1_3.Image = picRed3.Image;
            fearR1_2.Image = picRed4.Image;
            fearR1_1.Image = picRed5.Image;
            fearB2_5.Image = picBlue1.Image;
            fearB2_4.Image = picBlue2.Image;
            fearB2_3.Image = picBlue3.Image;
            fearB2_2.Image = picBlue4.Image;
            fearB2_1.Image = picBlue5.Image;

            fearR2_5.Image = picRed1.Image;
            fearR2_4.Image = picRed2.Image;
            fearR2_3.Image = picRed3.Image;
            fearR2_2.Image = picRed4.Image;
            fearR2_1.Image = picRed5.Image;
            fearB3_5.Image = picBlue1.Image;
            fearB3_4.Image = picBlue2.Image;
            fearB3_3.Image = picBlue3.Image;
            fearB3_2.Image = picBlue4.Image;
            fearB3_1.Image = picBlue5.Image;

            fearR3_5.Image = picRed1.Image;
            fearR3_4.Image = picRed2.Image;
            fearR3_3.Image = picRed3.Image;
            fearR3_2.Image = picRed4.Image;
            fearR3_1.Image = picRed5.Image;

        }

        #region 데이터수신

        public void AllClear()
        {
            indexBan = 0;
            banList = new int[11];

            for (int i = 0; i < 5; i++)
            {
                ((PictureEdit)groupControl14.Controls["picBlue" + (i + 1)]).Image = mainForm.imageReSize(40, 40, getChampsPath(""));
                ((PictureEdit)groupControl14.Controls["picRed" + (i + 1)]).Image = mainForm.imageReSize(40, 40, getChampsPath(""));
                ((PictureEdit)gc6.Controls["BB" + (i + 1)]).Image = mainForm.imageReSize(40, 40, getChampsPath(""));
                ((PictureEdit)gc7.Controls["RB" + (i + 1)]).Image = mainForm.imageReSize(40, 40, getChampsPath(""));

                //((Label)groupControl14.Controls["lblPlayerBlue" + (i + 1)]).Text = "Player";
                //((Label)groupControl14.Controls["lblPlayerRed" + (i + 1)]).Text = "Player";

                ((Label)groupControl14.Controls["lblPriorityRed" + (i + 1)]).Text = "Data 우선";
                ((Label)groupControl14.Controls["lblPriorityBlue" + (i + 1)]).Text = "Data 우선";

                ((Label)groupControl14.Controls["lblStateRed" + (i + 1)]).Text = "상태";
                ((Label)groupControl14.Controls["lblStateBlue" + (i + 1)]).Text = "상태";

            }
        }

        public void TimerSwitch(bool start)
        {
            if (!start) if (timer.Enabled) timer.Stop();
            /*
            if (start)
            {
                if (!timer.Enabled) timer.Start();
            }
            else
            {
                if (timer.Enabled) timer.Stop();
            }
            */
        }


        private string RES_FOLDER_PATH = Environment.CurrentDirectory + @"\Resource\";
        private string getChampsPath(string fileName) => RES_FOLDER_PATH + @"Champs(140x140)\" + fileName + "_140140.png";
        private string getChampsPathBanPick(string fileName, bool isBlue)
        {
            return RES_FOLDER_PATH + @"Champs(158x245)\" + fileName + "_158245.png";
        }
        private string getChampsPathBanPick_old(string fileName, bool isBlue)
        {
            if (isBlue) return RES_FOLDER_PATH + @"Champs(520x370)\" + fileName + "_L.png";
            else return RES_FOLDER_PATH + @"Champs(520x370)\" + fileName + "_R.png";
        }


        int indexOfBanPick = -1;
        int countOfBanPick = 0;

        int indexBan = 0; //임시 - 임시는 아님.. 초기화 꼭 할 것
        int[] banList = new int[11];

        public string getGameNum => cmbGame.Text;

        private void timer_Tick(object sender, EventArgs e)
        {
            try
            {                
                DataTable ban = DataManager.getInstance().라이브데이터요청(DBDefine.요청데이터분류.밴데이터).Tables[0];
                DataTable pick = DataManager.getInstance().라이브데이터요청(DBDefine.요청데이터분류.픽데이터).Tables[0];

                int banIndex = 0;
                int blueBanIndex = 0;
                int redBanIndex = 0;
                //벤정보
                foreach (DataRow dr in ban.Rows)
                {
                    banIndex++;
                    int index = banIndex; //Convert.ToInt32(dr[0]);
                    
                    //if (index == indexBan + 1)
                    {
                        indexBan = index;

                        int key = Convert.ToInt32(dr[1]);

                        //if  (banList[index] != key)
                        {
                            ChampionInfoVO champion = new ChampionInfoVO();
                            champion.ID = -1;
                            champion.champNameKOR = "선택없음";
                            champion.champNameENG = "NONE";

                            if (key != -1) champion = DataManager.getInstance().mChampionTable[key];

                            PictureEdit banImg = new PictureEdit();


                            if (dr[3].ToString() == "100")
                            {
                                blueBanIndex++;

                                if (blueBanIndex == 1) banImg = BB1;
                                else if (blueBanIndex == 2) banImg = BB2;
                                else if (blueBanIndex == 3) banImg = BB3;
                                else if (blueBanIndex == 4) banImg = BB4;
                                else if (blueBanIndex == 5) banImg = BB5;
                            }
                            else
                            {
                                redBanIndex++;

                                if (redBanIndex == 1) banImg = RB1;
                                else if (redBanIndex == 2) banImg = RB2;
                                else if (redBanIndex == 3) banImg = RB3;
                                else if (redBanIndex == 4) banImg = RB4;
                                else if (redBanIndex == 5) banImg = RB5;
                            }

                            /*
                            if (index == 1) banImg = BB1;
                            else if (index == 3) banImg = BB2;
                            else if (index == 5) banImg = BB3;
                            else if (index == 8) banImg = BB4;
                            else if (index == 10) banImg = BB5;

                            if (index == 2) banImg = RB1;
                            else if (index == 4) banImg = RB2;
                            else if (index == 6) banImg = RB3;
                            else if (index == 7) banImg = RB4;
                            else if (index == 9) banImg = RB5;
                            */
                            

                            banImg.Image = mainForm.imageReSize(40, 40, getChampsPath(champion.champNameENG));

                            //밴정보 저장
                            int indexOfPhase = Convert.ToInt32(banImg.Name.Substring(2));

                            if (banImg.Name.Contains("BB"))
                            {
                                Liner liner = mainForm.DC.BlueLiner.GetLiner(indexOfPhase - 1);
                                liner.ban = champion.champNameENG;
                                mainForm.DC.BlueLiner.SetLiner(indexOfPhase - 1, liner);
                            }
                            else
                            {
                                Liner liner = mainForm.DC.RedLiner.GetLiner(indexOfPhase - 1);
                                liner.ban = champion.champNameENG;
                                mainForm.DC.RedLiner.SetLiner(indexOfPhase - 1, liner);
                            }

                            //if (mainForm.TM.isDisplayBanPick) mainForm.TM.DisplayBanPickStart(index, new string[] { getChampsPath(champion.champNameENG) }, true);
                             
                            banList[index] = key;
                        }
                    }
                }


                int blueIndex = 0;
                int redIndex = 0;
                //픽정보
                for (int i = 0; i < pick.Rows.Count; i++)
                {
                   
                    bool isBlue = pick.Rows[i][0].ToString() == "블루";

                        string state = pick.Rows[i][4].ToString();
                        int champID = Convert.ToInt32(pick.Rows[i][2]);
                        Liner liner;

                        if (isBlue) liner = mainForm.DC.BlueLiner.GetLiner(i);
                        else liner = mainForm.DC.RedLiner.GetLiner(i - 5);

                    if (isBlue) blueIndex++;
                    else redIndex++;

                        if (liner.state == null) liner.state = "";

                    if (!liner.state.Equals(state) || !liner.champID.Equals(champID))
                    {
                        if (champID != 0)
                        {
                            liner.state = state;
                            liner.champID = champID;

                            ChampionInfoVO champion;
                            if (champID != 0) champion = DataManager.getInstance().mChampionTable[champID];
                            else
                            {
                                champion = new ChampionInfoVO();
                                champion.ID = 0;
                                champion.champNameENG = "";
                                champion.champNameKOR = "";
                            }

                            liner.champ = champion.champNameENG;

                            if (isBlue)
                            {
                                //((PictureEdit)groupControl14.Controls["picBlue" + (i + 1)]).Image = mainForm.imageReSize(40, 40, getChampsPath(champion.champNameENG));
                                //groupControl14.Controls["lblStateBlue" + (i + 1)].Text = pick.Rows[i][4].ToString();
                                //mainForm.DC.BlueLiner.SetLiner(i, liner);
                                ((PictureEdit)groupControl14.Controls["picBlue" + blueIndex]).Image = mainForm.imageReSize(40, 40, getChampsPath(champion.champNameENG));
                                groupControl14.Controls["lblStateBlue" + blueIndex].Text = pick.Rows[i][4].ToString();
                                mainForm.DC.BlueLiner.SetLiner(blueIndex-1, liner);
                            }
                            else
                            {
                                //((PictureEdit)groupControl14.Controls["picRed" + (i - 4)]).Image = mainForm.imageReSize(40, 40, getChampsPath(champion.champNameENG));
                                //groupControl14.Controls["lblStateRed" + (i - 4)].Text = pick.Rows[i][4].ToString();
                                //mainForm.DC.RedLiner.SetLiner(i - 5, liner);
                                ((PictureEdit)groupControl14.Controls["picRed" + redIndex]).Image = mainForm.imageReSize(40, 40, getChampsPath(champion.champNameENG));
                                groupControl14.Controls["lblStateRed" + redIndex].Text = pick.Rows[i][4].ToString();
                                mainForm.DC.RedLiner.SetLiner(redIndex-1, liner);
                            }
 
                        } 
                    }
                }


                //수동픽이 있으면 해당 값들로 변경한다
                for (int i = 1; i < 11; i++)
                {
                    string priority = i < 6 ? groupControl14.Controls["lblPriorityBlue" + i].Text : groupControl14.Controls["lblPriorityRed" + (i - 5)].Text;
                    Liner liner = i < 6 ? mainForm.DC.BlueLiner.GetLiner(i - 1) : mainForm.DC.RedLiner.GetLiner(i - 6);

                    if (!priority.Equals("Data 우선"))
                    {
                        foreach (var v in DataManager.getInstance().mChampionTable)
                        {
                            if (v.Value.champNameKOR.Equals(priority))
                            {
                                liner.champ = v.Value.champNameENG;
                                liner.champID = v.Value.ID;
                                liner.state = "선택확정";
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            try
            {
                bool isRedStart = mainForm.getIsRedStart;
                
                if (isRedStart)
                {
                    //자동이든 수동이든 밴픽을 정상화 하기 위함.. 시발!
                    if (indexOfBanPick > -1 && mainForm.TM.isDisplayBanPick)
                    {
                        Liners blue = mainForm.DC.BlueLiner;
                        Liners red = mainForm.DC.RedLiner;

                        countOfBanPick--;
                        if (countOfBanPick > 0) return;

                        Liner liner = blue.Top;
                        bool isBlue = true;
                        //각 순번에 따른 확인할 선수 정하기
                        //벤 6개
                        //if (mainForm.getIsRedStart)
                        //{
                        //    isBlue = false;

                        //    if (indexOfBanPick == 0) liner = blue.Top;
                        //    else if (indexOfBanPick == 1) liner = red.Top;
                        //    else if (indexOfBanPick == 2) liner = blue.Jungle;
                        //    else if (indexOfBanPick == 3) liner = red.Jungle;
                        //    else if (indexOfBanPick == 4) liner = blue.Mid;
                        //    else if (indexOfBanPick == 5) liner = red.Mid;
                        //    //픽 6개
                        //    else if (indexOfBanPick == 6) { liner = blue.Top; isBlue = true; }                            
                        //    else if (indexOfBanPick == 7) liner = red.Top;
                        //    else if (indexOfBanPick == 8) liner = red.Jungle;
                        //    else if (indexOfBanPick == 9) { liner = blue.Jungle; isBlue = true; }                            
                        //    else if (indexOfBanPick == 10) { liner = blue.Mid; isBlue = true; }                            
                        //    else if (indexOfBanPick == 11) liner = red.Mid;
                        //    //벤 2차
                        //    else if (indexOfBanPick == 12) liner = red.ADCarry; 
                        //    else if (indexOfBanPick == 13) liner = blue.ADCarry;
                        //    else if (indexOfBanPick == 14) liner = red.Supporter;
                        //    else if (indexOfBanPick == 15) liner = blue.Supporter; 
                        //    //픽 2차
                        //    else if (indexOfBanPick == 16) liner = red.ADCarry;                            
                        //    else if (indexOfBanPick == 17) { liner = blue.ADCarry; isBlue = true; }
                        //    else if (indexOfBanPick == 18) { liner = blue.Supporter; isBlue = true; }
                        //    else if (indexOfBanPick == 19) liner = red.Supporter;                            
                        //    else
                        //    {
                        //        if (timer.Enabled) timer.Stop();
                        //        return;
                        //    }
                        //}
                        //else
                        {
                            if (indexOfBanPick == 0) liner = red.Top;
                            else if (indexOfBanPick == 1) liner = blue.Top; 
                            else if (indexOfBanPick == 2) liner = red.Jungle; 
                            else if (indexOfBanPick == 3) liner = blue.Jungle;
                            else if (indexOfBanPick == 4) liner = red.Mid; 
                            else if (indexOfBanPick == 5) liner = blue.Mid;
                            //픽 6개
                            else if (indexOfBanPick == 6) { liner = red.Top; isBlue = false; }                            
                            else if (indexOfBanPick == 7) liner = blue.Top;
                            else if (indexOfBanPick == 8) liner = blue.Jungle;
                            else if (indexOfBanPick == 9) { liner = red.Jungle; isBlue = false; }                            
                            else if (indexOfBanPick == 10) { liner = red.Mid; isBlue = false; }                            
                            else if (indexOfBanPick == 11) liner = blue.Mid;
                            //벤 2차
                            else if (indexOfBanPick == 12) liner = blue.ADCarry; 
                            else if (indexOfBanPick == 13) liner = red.ADCarry;
                            else if (indexOfBanPick == 14) liner = blue.Supporter; 
                            else if (indexOfBanPick == 15) liner = red.Supporter;
                            //픽 2차
                            else if (indexOfBanPick == 16) liner = blue.ADCarry;                            
                            else if (indexOfBanPick == 17) { liner = red.ADCarry; isBlue = false; }
                            else if (indexOfBanPick == 18) { liner = red.Supporter; isBlue = false; }                            
                            else if (indexOfBanPick == 19) liner = blue.Supporter;
                            else
                            {
                                if (timer.Enabled) timer.Stop();
                                return;
                            }
                        }



                        {
                            //밴 시작
                            if (indexOfBanPick < 6 && liner.ban != "")
                            {
                                mainForm.TM.DisplayBanPickStart(indexOfBanPick + 1, new string[] { getChampsPath(liner.ban) }, true, true);
                                countOfBanPick = 1;
                                if (indexOfBanPick == 5) countOfBanPick = 3; //라인페이즈로 변경하므로 시간을 더 준다

                                //밴 순서 꼬일때를 대비한 맞추기
                                indexBan = indexOfBanPick + 1;

                                indexOfBanPick++;
                            }
                            //픽 시작
                            else if (indexOfBanPick >= 6 && indexOfBanPick < 12 && liner.champ != "")
                            {
                                mainForm.TM.DisplayBanPickStart(indexOfBanPick - 6, new string[] { getChampsPathBanPick(liner.champ, isBlue), liner.champ, liner.state }, false, true);

                                if (liner.state == "선택확정")
                                {
                                    countOfBanPick = 1;
                                    indexOfBanPick++;
                                }
                            }
                            //밴 시작 2차
                            else if (indexOfBanPick >= 12 && indexOfBanPick < 16 && liner.ban != "")
                            {
                                mainForm.TM.DisplayBanPickStart(indexOfBanPick - 5, new string[] { getChampsPath(liner.ban) }, true, true);
                                countOfBanPick = 1;

                                //밴 순서 꼬일때를 대비한 맞추기
                                indexBan = indexOfBanPick - 5;

                                indexOfBanPick++;
                            }
                            else if (indexOfBanPick >= 16 && indexOfBanPick < 20 && liner.champ != "") //픽 시작 2차
                            {
                                mainForm.TM.DisplayBanPickStart(indexOfBanPick - 10, new string[] { getChampsPathBanPick(liner.champ, isBlue), liner.champ, liner.state }, false, true);


                                if (liner.state == "선택확정")
                                {
                                    countOfBanPick = 1;
                                    indexOfBanPick++;

                                    if (indexOfBanPick == 20) if (timer.Enabled) timer.Stop();
                                }
                            }
                            else if (indexOfBanPick == 20)
                            {
                                btnSwap_Click(null, null);
                                indexOfBanPick++;
                            }
                        }
                    }
                }
                else
                {
                    //자동이든 수동이든 밴픽을 정상화 하기 위함.. 시발!
                    if (indexOfBanPick > -1 && mainForm.TM.isDisplayBanPick)
                    {
                        Liners blue = mainForm.DC.BlueLiner;
                        Liners red = mainForm.DC.RedLiner;

                        countOfBanPick--;
                        if (countOfBanPick > 0) return;

                        Liner liner = blue.Top;
                        bool isBlue = true;
                        //각 순번에 따른 확인할 선수 정하기
                        //벤 6개
                        if (mainForm.getIsRedStart)
                        {
                            isBlue = false;

                            if (indexOfBanPick == 0) liner = red.Top;
                            else if (indexOfBanPick == 1) liner = blue.Top;
                            else if (indexOfBanPick == 2) liner = red.Jungle;
                            else if (indexOfBanPick == 3) liner = blue.Jungle;
                            else if (indexOfBanPick == 4) liner = red.Mid;
                            else if (indexOfBanPick == 5) liner = blue.Mid;
                            //픽 6개
                            else if (indexOfBanPick == 6) liner = red.Top;
                            else if (indexOfBanPick == 7) { liner = blue.Top; isBlue = true; }
                            else if (indexOfBanPick == 8) { liner = blue.Jungle; isBlue = true; }
                            else if (indexOfBanPick == 9) liner = red.Jungle;
                            else if (indexOfBanPick == 10) liner = red.Mid;
                            else if (indexOfBanPick == 11) { liner = blue.Mid; isBlue = true; }
                            //벤 2차
                            else if (indexOfBanPick == 12) liner = blue.ADCarry;
                            else if (indexOfBanPick == 13) liner = red.ADCarry;
                            else if (indexOfBanPick == 14) liner = blue.Supporter;
                            else if (indexOfBanPick == 15) liner = red.Supporter;
                            //픽 2차
                            else if (indexOfBanPick == 16) { liner = blue.ADCarry; isBlue = true; }
                            else if (indexOfBanPick == 17) liner = red.ADCarry;
                            else if (indexOfBanPick == 18) liner = red.Supporter;
                            else if (indexOfBanPick == 19) { liner = blue.Supporter; isBlue = true; }
                            else
                            {
                                if (timer.Enabled) timer.Stop();
                                return;
                            }
                        }
                        else
                        {
                            if (indexOfBanPick == 0) liner = blue.Top;
                            else if (indexOfBanPick == 1) liner = red.Top;
                            else if (indexOfBanPick == 2) liner = blue.Jungle;
                            else if (indexOfBanPick == 3) liner = red.Jungle;
                            else if (indexOfBanPick == 4) liner = blue.Mid;
                            else if (indexOfBanPick == 5) liner = red.Mid;
                            //픽 6개
                            else if (indexOfBanPick == 6) liner = blue.Top;
                            else if (indexOfBanPick == 7) { liner = red.Top; isBlue = false; }
                            else if (indexOfBanPick == 8) { liner = red.Jungle; isBlue = false; }
                            else if (indexOfBanPick == 9) liner = blue.Jungle;
                            else if (indexOfBanPick == 10) liner = blue.Mid;
                            else if (indexOfBanPick == 11) { liner = red.Mid; isBlue = false; }
                            //벤 2차
                            else if (indexOfBanPick == 12) liner = red.ADCarry;
                            else if (indexOfBanPick == 13) liner = blue.ADCarry;
                            else if (indexOfBanPick == 14) liner = red.Supporter;
                            else if (indexOfBanPick == 15) liner = blue.Supporter;
                            //픽 2차
                            else if (indexOfBanPick == 16) { liner = red.ADCarry; isBlue = false; }
                            else if (indexOfBanPick == 17) liner = blue.ADCarry;
                            else if (indexOfBanPick == 18) liner = blue.Supporter;
                            else if (indexOfBanPick == 19) { liner = red.Supporter; isBlue = false; }
                            else
                            {
                                if (timer.Enabled) timer.Stop();
                                return;
                            }
                        }



                        {
                            //밴 시작
                            if (indexOfBanPick < 6 && liner.ban != "")
                            {
                                mainForm.TM.DisplayBanPickStart(indexOfBanPick + 1, new string[] { getChampsPath(liner.ban) }, true);
                                countOfBanPick = 1;
                                if (indexOfBanPick == 5) countOfBanPick = 3; //라인페이즈로 변경하므로 시간을 더 준다

                                //밴 순서 꼬일때를 대비한 맞추기
                                indexBan = indexOfBanPick + 1;

                                indexOfBanPick++;
                            }
                            //픽 시작
                            else if (indexOfBanPick >= 6 && indexOfBanPick < 12 && liner.champ != "")
                            {
                                mainForm.TM.DisplayBanPickStart(indexOfBanPick - 6, new string[] { getChampsPathBanPick(liner.champ, isBlue), liner.champ, liner.state }, false);

                                if (liner.state == "선택확정")
                                {
                                    countOfBanPick = 1;
                                    indexOfBanPick++;
                                }
                            }
                            //밴 시작 2차
                            else if (indexOfBanPick >= 12 && indexOfBanPick < 16 && liner.ban != "")
                            {
                                mainForm.TM.DisplayBanPickStart(indexOfBanPick - 5, new string[] { getChampsPath(liner.ban) }, true);
                                countOfBanPick = 1;

                                //밴 순서 꼬일때를 대비한 맞추기
                                indexBan = indexOfBanPick - 5;

                                indexOfBanPick++;
                            }
                            else if (indexOfBanPick >= 16 && indexOfBanPick < 20 && liner.champ != "") //픽 시작 2차
                            {
                                mainForm.TM.DisplayBanPickStart(indexOfBanPick - 10, new string[] { getChampsPathBanPick(liner.champ, isBlue), liner.champ, liner.state }, false);


                                if (liner.state == "선택확정")
                                {
                                    countOfBanPick = 1;
                                    indexOfBanPick++;

                                    if (indexOfBanPick == 20) if (timer.Enabled) timer.Stop();
                                }
                            }
                            else if (indexOfBanPick == 20)
                            {
                                btnSwap_Click(null, null);
                                indexOfBanPick++;
                            }
                        }


                    }
                }
              
            }
            catch(Exception ex)
            {
                Console.WriteLine("밴픽 정상화 과정 : " + ex.Message);
            } 
        }

        #endregion


        #region 밴픽
         
        private void btnBanPick_Click(object sender, EventArgs e)
        {
            if (!mainForm.TM.isConnected())
            {
                MessageBox.Show("Tornado와 송출 연결이 되지 않았습니다.");
                return;
            }

            if (mainForm.MainLayerButton((SimpleButton)sender))
            {
                Tornado.TornadoManager.getInstance().TimerTime = 27;
                indexOfBanPick = 0;
                countOfBanPick = 2;

                banList = new int[11];
                string[] teams = new string[] { mainForm.DC.BlueLiner.TeamName, mainForm.DC.RedLiner.TeamName };
                string[] scores = new string[] { mainForm.bscore.Text, mainForm.rscore.Text, mainForm.bscoreAll.Text, mainForm.rscoreAll.Text };
                bool[] isFearlessShow = new bool[] {toggleGame1.IsOn, toggleGame2.IsOn, toggleGame3.IsOn, toggleGame4.IsOn };

                string[] images1 = new string[] { "", "", "", "", "", "", "", "", "", "" };

                if (fearB1_1.Image.Tag != null) images1 = new string[] {
                    fearB1_1.Image.Tag.ToString(), fearB1_2.Image.Tag.ToString(), fearB1_3.Image.Tag.ToString(), fearB1_4.Image.Tag.ToString(), fearB1_5.Image.Tag.ToString(),
                    fearR1_1.Image.Tag.ToString(), fearR1_2.Image.Tag.ToString(), fearR1_3.Image.Tag.ToString(), fearR1_4.Image.Tag.ToString(), fearR1_5.Image.Tag.ToString()
                };
                string[] images2 = new string[] { "", "", "", "", "", "", "", "", "", "" };

                if (fearB2_1.Image.Tag != null) images2 = new string[] {
                    fearB2_1.Image.Tag.ToString(), fearB2_2.Image.Tag.ToString(), fearB2_3.Image.Tag.ToString(), fearB2_4.Image.Tag.ToString(), fearB2_5.Image.Tag.ToString(),
                    fearR2_1.Image.Tag.ToString(), fearR2_2.Image.Tag.ToString(), fearR2_3.Image.Tag.ToString(), fearR2_4.Image.Tag.ToString(), fearR2_5.Image.Tag.ToString()
                };
                string[] images3 = new string[] { "", "", "", "", "", "", "", "", "", "" };

                if (fearB3_1.Image.Tag != null) images3 = new string[] {
                    fearB3_1.Image.Tag.ToString(), fearB3_2.Image.Tag.ToString(), fearB3_3.Image.Tag.ToString(), fearB3_4.Image.Tag.ToString(), fearB3_5.Image.Tag.ToString(),
                    fearR3_1.Image.Tag.ToString(), fearR3_2.Image.Tag.ToString(), fearR3_3.Image.Tag.ToString(), fearR3_4.Image.Tag.ToString(), fearR3_5.Image.Tag.ToString()
                };
                string[] images4 = new string[] { "", "", "", "", "", "", "", "", "", "" };

                if (fearB4_1.Image.Tag != null) images4 = new string[] {
                    fearB4_1.Image.Tag.ToString(), fearB4_2.Image.Tag.ToString(), fearB4_3.Image.Tag.ToString(), fearB4_4.Image.Tag.ToString(), fearB4_5.Image.Tag.ToString(),
                    fearR4_1.Image.Tag.ToString(), fearR4_2.Image.Tag.ToString(), fearR4_3.Image.Tag.ToString(), fearR4_4.Image.Tag.ToString(), fearR4_5.Image.Tag.ToString()
                };

                
                mainForm.TM.DisplayBanPick(mainForm.GetTitle(), teams, mainForm.DC, scores, isFearlessShow, images1, images2, images3, images4, mainForm.getIsRedStart);
                mainForm.TM.DisplayBanPickStart(0, null, true);

                if (!timer.Enabled) timer.Start();
            }

        }

        private void btnBanPickStart_Click(object sender, EventArgs e)
        {
            if (!mainForm.TM.isConnected())
            {
                MessageBox.Show("Tornado와 송출 연결이 되지 않았습니다.");
                return;
            }

            if (mainForm.TM.isDisplayBanPick)
            {
                mainForm.TM.DisplayBanPickStart(0, null, true); 
            }
        }


        private void btnSwap_Click(object sender, EventArgs e)
        {
            if (!mainForm.TM.isConnected())
            {
                MessageBox.Show("Tornado와 송출 연결이 되지 않았습니다.");
                return;
            }

            Console.WriteLine(mainForm.DC);

            string[] teams = new string[] { mainForm.DC.BlueLiner.TeamName, mainForm.DC.RedLiner.TeamName };
            mainForm.TM.DisplaySwapPhase(mainForm.GetTitle(), teams, mainForm.DC);
        }   
        #endregion


        #region 라인업

        

        private void LC_Click(object sender, EventArgs e)
        {
            if (!mainForm.TM.isConnected())
            {
                MessageBox.Show("Tornado와 송출 연결이 되지 않았습니다.");
                return;
            }

            if (mainForm.MainLayerButton((SimpleButton)sender))
            {
                mainForm.TM.Out(2);
                mainForm.TM.DisplayLineUp(mainForm.GetTitle(), mainForm.DC.BlueLiner, mainForm.DC.RedLiner);
            }
        }






        #endregion

        public ChampionInfoVO selectedChamp = null;

        private void pic_Click(object sender, EventArgs e)
        {
            //if (!checkEdit2.Checked) return;

            string controlName = ((PictureEdit)sender).Name;


            selectedChamp = null;
            int index = Convert.ToInt32(controlName.Substring(controlName.Length - 1));
            
            Liners liners = controlName.Contains("picBlue") || controlName.Contains("BB") ? mainForm.DC.BlueLiner : mainForm.DC.RedLiner;
            Liner liner = liners.GetLiner(index - 1);
            //이미 케릭터가 선택되어 있는지 정보를 넘겨야 한다.
            string selectedChampName = controlName.Contains("pic") ? liner.champ : liner.ban;



            ChampSearchForm champSearchForm = new ChampSearchForm(this, selectedChampName);
            champSearchForm.ShowDialog(); 


            if (selectedChamp != null)
            {  
                PictureEdit target = (PictureEdit)sender;

                target.Image = mainForm.imageReSize(40, 40, getChampsPath(selectedChamp.champNameENG));

                if (controlName.Contains("pic"))
                {
                    liner.champ = selectedChamp.champNameENG;
                    if (liner.champ.Equals("")) liner.state = "";
                    else
                    {
                        if (selectedChamp.champNameKOR.Equals("초기화") || selectedChamp.champNameKOR.Equals("없음선택"))
                        {
                            groupControl14.Controls[controlName.Replace("pic", "lblPriority")].Text = "Data 우선";
                        }
                        else
                        {
                            liner.state = "선택확정";
                            groupControl14.Controls[controlName.Replace("pic", "lblPriority")].Text = selectedChamp.champNameKOR;
                        }
                    }
                }
                else liner.ban = selectedChamp.champNameENG;
                liners.SetLiner(index - 1, liner);
            }


        }

        private void fearless_Click(object sender, EventArgs e)
        {

        }
        private void btnSaveFearless_Click(object sender, EventArgs e)
        {
            if (cmbGame.SelectedIndex == 0)
            {
                fearB1_5.Image = picBlue1.Image;
                fearB1_4.Image = picBlue2.Image;
                fearB1_3.Image = picBlue3.Image;
                fearB1_2.Image = picBlue4.Image;
                fearB1_1.Image = picBlue5.Image;

                fearR1_5.Image = picRed1.Image;
                fearR1_4.Image = picRed2.Image;
                fearR1_3.Image = picRed3.Image;
                fearR1_2.Image = picRed4.Image;
                fearR1_1.Image = picRed5.Image;
            }
            else if (cmbGame.SelectedIndex == 1)
            {
                fearB2_5.Image = picBlue1.Image;
                fearB2_4.Image = picBlue2.Image;
                fearB2_3.Image = picBlue3.Image;
                fearB2_2.Image = picBlue4.Image;
                fearB2_1.Image = picBlue5.Image;

                fearR2_5.Image = picRed1.Image;
                fearR2_4.Image = picRed2.Image;
                fearR2_3.Image = picRed3.Image;
                fearR2_2.Image = picRed4.Image;
                fearR2_1.Image = picRed5.Image;
            }
            else if (cmbGame.SelectedIndex == 2)
            {
                fearB3_5.Image = picBlue1.Image;
                fearB3_4.Image = picBlue2.Image;
                fearB3_3.Image = picBlue3.Image;
                fearB3_2.Image = picBlue4.Image;
                fearB3_1.Image = picBlue5.Image;

                fearR3_5.Image = picRed1.Image;
                fearR3_4.Image = picRed2.Image;
                fearR3_3.Image = picRed3.Image;
                fearR3_2.Image = picRed4.Image;
                fearR3_1.Image = picRed5.Image;
            }
            else if (cmbGame.SelectedIndex == 3)
            {
                fearB4_5.Image = picBlue1.Image;
                fearB4_4.Image = picBlue2.Image;
                fearB4_3.Image = picBlue3.Image;
                fearB4_2.Image = picBlue4.Image;
                fearB4_1.Image = picBlue5.Image;

                fearR4_5.Image = picRed1.Image;
                fearR4_4.Image = picRed2.Image;
                fearR4_3.Image = picRed3.Image;
                fearR4_2.Image = picRed4.Image;
                fearR4_1.Image = picRed5.Image;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (sender == button1)
            {
                Image image1 = fearR1_1.Image;
                Image image2 = fearR1_2.Image;
                Image image3 = fearR1_3.Image;
                Image image4 = fearR1_4.Image;
                Image image5 = fearR1_5.Image;

                fearR1_1.Image = fearB1_1.Image;
                fearR1_2.Image = fearB1_2.Image;
                fearR1_3.Image = fearB1_3.Image;
                fearR1_4.Image = fearB1_4.Image;
                fearR1_5.Image = fearB1_5.Image;

                fearB1_1.Image = image1;
                fearB1_2.Image = image2;
                fearB1_3.Image = image3;
                fearB1_4.Image = image4;
                fearB1_5.Image = image5;
            }
            else if (sender == button2)
            {
                Image image1 = fearR2_1.Image;
                Image image2 = fearR2_2.Image;
                Image image3 = fearR2_3.Image;
                Image image4 = fearR2_4.Image;
                Image image5 = fearR2_5.Image;

                fearR2_1.Image = fearB2_1.Image;
                fearR2_2.Image = fearB2_2.Image;
                fearR2_3.Image = fearB2_3.Image;
                fearR2_4.Image = fearB2_4.Image;
                fearR2_5.Image = fearB2_5.Image;

                fearB2_1.Image = image1;
                fearB2_2.Image = image2;
                fearB2_3.Image = image3;
                fearB2_4.Image = image4;
                fearB2_5.Image = image5;
            }
            else if (sender == button3)
            {
                Image image1 = fearR3_1.Image;
                Image image2 = fearR3_2.Image;
                Image image3 = fearR3_3.Image;
                Image image4 = fearR3_4.Image;
                Image image5 = fearR3_5.Image;

                fearR3_1.Image = fearB3_1.Image;
                fearR3_2.Image = fearB3_2.Image;
                fearR3_3.Image = fearB3_3.Image;
                fearR3_4.Image = fearB3_4.Image;
                fearR3_5.Image = fearB3_5.Image;

                fearB3_1.Image = image1;
                fearB3_2.Image = image2;
                fearB3_3.Image = image3;
                fearB3_4.Image = image4;
                fearB3_5.Image = image5;
            }
            else if (sender == button7)
            {
                Image image1 = fearR4_1.Image;
                Image image2 = fearR4_2.Image;
                Image image3 = fearR4_3.Image;
                Image image4 = fearR4_4.Image;
                Image image5 = fearR4_5.Image;

                fearR4_1.Image = fearB4_1.Image;
                fearR4_2.Image = fearB4_2.Image;
                fearR4_3.Image = fearB4_3.Image;
                fearR4_4.Image = fearB4_4.Image;
                fearR4_5.Image = fearB4_5.Image;

                fearB4_1.Image = image1;
                fearB4_2.Image = image2;
                fearB4_3.Image = image3;
                fearB4_4.Image = image4;
                fearB4_5.Image = image5;
            }
        }


        string posChangeName = "";
        private void picPosition_Click(object sender, EventArgs e)
        {
            ContextMenu custommenu = new ContextMenu();

            posChangeName = ((PictureEdit)sender).Name;

            for (int i = 1; i <= 5; i++)
            {
                custommenu.MenuItems.Add(i.ToString(), new EventHandler(ContextMenu_SWAP));
            }

            ((PictureEdit)sender).ContextMenu = custommenu;
        }

        private void ContextMenu_SWAP(object sender, System.EventArgs e)
        {
            int before = Convert.ToInt32(posChangeName.Substring(posChangeName.Length - 1)) - 1;
            int after = Convert.ToInt32(((MenuItem)sender).Text) - 1;


            if (before.Equals(after))
            {
                MessageBox.Show("동일한 라인입니다..");
                return;
            }

            Liners liners = posChangeName.Contains("Blue") ? mainForm.DC.BlueLiner : mainForm.DC.RedLiner;
            Liner liner1 = liners.GetLiner(before);
            Liner liner2 = liners.GetLiner(after);

            string champ = liner1.champ;
            liner1.champ = liner2.champ;
            liner2.champ = champ;

            liners.SetLiner(before, liner1);
            liners.SetLiner(after, liner2);

            Console.WriteLine((posChangeName.Contains("Blue") ? "Blue" : "Red") + before + " <=> " + after);

            refreshLines();

            if (mainForm.TM.isDisplayBanPick) btnSwap_Click(null, null);
        }

        public void refreshLines()
        {
            for (int i = 0; i < 5; i++)
            {
                Liner blueLiner = mainForm.DC.BlueLiner.GetLiner(i);
                Liner redLiner = mainForm.DC.RedLiner.GetLiner(i); 

                if (blueLiner.champ != null)
                    ((PictureEdit)groupControl14.Controls["picBlue" + (i + 1)]).Image = mainForm.imageReSize(40, 40, getChampsPath(blueLiner.champ));

                if (redLiner.champ != null)
                    ((PictureEdit)groupControl14.Controls["picRed" + (i + 1)]).Image = mainForm.imageReSize(40, 40, getChampsPath(redLiner.champ));

                if (blueLiner.Name != null)
                    ((Label)groupControl14.Controls["lblPlayerBlue" + (i + 1)]).Text = blueLiner.Name;
                if (redLiner.Name != null)
                    ((Label)groupControl14.Controls["lblPlayerRed" + (i + 1)]).Text = redLiner.Name;
            } 
        }

        private void btnBanPickData_Click(object sender, EventArgs e)
        {
            try
            {
                AllClear();
                mainForm.selectTeamText();

                DataTable ban = DataManager.getInstance().라이브데이터요청(DBDefine.요청데이터분류.밴데이터).Tables[0];
                DataTable pick = DataManager.getInstance().라이브데이터요청(DBDefine.요청데이터분류.픽데이터).Tables[0];

                //벤정보
                foreach (DataRow dr in ban.Rows)
                {
                    int index = Convert.ToInt32(dr[0]);
                    int key = Convert.ToInt32(dr[1]);

                    ChampionInfoVO champion = DataManager.getInstance().mChampionTable[key];

                    PictureEdit banImg = new PictureEdit();

                    if (index == 1) banImg = BB1;
                    else if (index == 3) banImg = BB2;
                    else if (index == 5) banImg = BB3;
                    else if (index == 8) banImg = BB4;
                    else if (index == 10) banImg = BB5;

                    if (index == 2) banImg = RB1;
                    else if (index == 4) banImg = RB2;
                    else if (index == 6) banImg = RB3;
                    else if (index == 7) banImg = RB4;
                    else if (index == 9) banImg = RB5;

                    banImg.Image = mainForm.imageReSize(40, 40, getChampsPath(champion.champNameENG));

                    //밴정보 저장
                    int indexOfPhase = Convert.ToInt32(banImg.Name.Substring(2));
                    if (banImg.Name.Contains("BB"))
                    {
                        Liner liner = mainForm.DC.BlueLiner.GetLiner(indexOfPhase - 1);
                        liner.ban = champion.champNameENG;
                        mainForm.DC.BlueLiner.SetLiner(indexOfPhase - 1, liner);
                    }
                    else
                    {
                        Liner liner = mainForm.DC.RedLiner.GetLiner(indexOfPhase - 1);
                        liner.ban = champion.champNameENG;
                        mainForm.DC.RedLiner.SetLiner(indexOfPhase - 1, liner);
                    }
                }


                //픽정보
                for (int i = 0; i < pick.Rows.Count; i++)
                {
                    string state = pick.Rows[i][4].ToString();
                    int champID = Convert.ToInt32(pick.Rows[i][2]);
                    Liner liner;

                    if (i < 5) liner = mainForm.DC.BlueLiner.GetLiner(i);
                    else liner = mainForm.DC.RedLiner.GetLiner(i - 5);
                    if (liner.state == null) liner.state = "";
                    if (champID != 0)
                    {
                        liner.state = state;
                        liner.champID = champID;

                        ChampionInfoVO champion;
                        if (champID != 0) champion = DataManager.getInstance().mChampionTable[champID];
                        else
                        {
                            champion = new ChampionInfoVO();
                            champion.ID = 0;
                            champion.champNameENG = "";
                            champion.champNameKOR = "";
                        }

                        liner.champ = champion.champNameENG;

                        if (i < 5)
                        {
                            ((PictureEdit)groupControl14.Controls["picBlue" + (i + 1)]).Image = mainForm.imageReSize(40, 40, getChampsPath(champion.champNameENG));
                            groupControl14.Controls["lblStateBlue" + (i + 1)].Text = pick.Rows[i][4].ToString();
                            mainForm.DC.BlueLiner.SetLiner(i, liner);
                        }
                        else
                        {
                            ((PictureEdit)groupControl14.Controls["picRed" + (i - 4)]).Image = mainForm.imageReSize(40, 40, getChampsPath(champion.champNameENG));
                            groupControl14.Controls["lblStateRed" + (i - 4)].Text = pick.Rows[i][4].ToString();
                            mainForm.DC.RedLiner.SetLiner(i - 5, liner);
                        }

                        if (mainForm.TM.isDisplayBanPick && champion.ID != 0)
                        {
                            //픽순서
                            int selectIndex = i;

                            if (i.Equals(1)) selectIndex = 3;
                            else if (i.Equals(2)) selectIndex = 4;
                            else if (i.Equals(3)) selectIndex = 7;
                            else if (i.Equals(4)) selectIndex = 8;
                            else if (i.Equals(5)) selectIndex = 1;
                            else if (i.Equals(6)) selectIndex = 2;
                            else if (i.Equals(7)) selectIndex = 5;
                            else if (i.Equals(8)) selectIndex = 6;
                            else if (i.Equals(9)) selectIndex = 9;

                            string path = getChampsPathBanPick(champion.champNameENG, i < 5 ? true : false);
                            mainForm.TM.DisplayBanPickStart(selectIndex, new string[] { path, champion.champNameENG.ToUpper(), state }, false);
                        }
                    }

                }
            }
            catch(Exception ex)
            { 
            }
           
        }


        
        private void button4_Click(object sender, EventArgs e)
        {
            DataTable ban = DataManager.getInstance().라이브데이터요청(DBDefine.요청데이터분류.밴데이터).Tables[0];
            DataTable pick = DataManager.getInstance().라이브데이터요청(DBDefine.요청데이터분류.픽데이터).Tables[0];

            dataGridView1.DataSource = ban;
            dataGridView2.DataSource = pick;

            //int index = Convert.ToInt32(textEdit1.Text);
            //string c = textEdit2.Text;
            //string path = "E:\\김의연\\롤코더\\lol_coder\\lol_coder\\lol_coder\\bin\\Debug\\Resource\\Champs(158x245)\\Amumu_158245.png";
            //string cname = "Amumu";
            //path = path.Replace("Amumu", c);
            //cname = cname.Replace("Amumu", c);
            //string state = "고르는중";

            //mainForm.TM.DisplayBanPickStart(index, new string[] { path,cname.ToUpper(), state }, false);
        }

        private void button5_Click(object sender, EventArgs e)
        {
            try
            {
                string path = Environment.CurrentDirectory + @"\Data\fearless.txt";


                File.WriteAllText(path, "");
                using (StreamWriter w = File.AppendText(path))
                {
                    w.WriteLine(fearB1_1.Image.Tag != null ? fearB1_1.Image.Tag.ToString() : "");
                    w.WriteLine(fearB1_2.Image.Tag != null ? fearB1_2.Image.Tag.ToString() : "");
                    w.WriteLine(fearB1_3.Image.Tag != null ? fearB1_3.Image.Tag.ToString() : "");
                    w.WriteLine(fearB1_4.Image.Tag != null ? fearB1_4.Image.Tag.ToString() : "");
                    w.WriteLine(fearB1_5.Image.Tag != null ? fearB1_5.Image.Tag.ToString() : "");

                    w.WriteLine(fearB2_1.Image.Tag != null ? fearB2_1.Image.Tag.ToString() : "");
                    w.WriteLine(fearB2_2.Image.Tag != null ? fearB2_2.Image.Tag.ToString() : "");
                    w.WriteLine(fearB2_3.Image.Tag != null ? fearB2_3.Image.Tag.ToString() : "");
                    w.WriteLine(fearB2_4.Image.Tag != null ? fearB2_4.Image.Tag.ToString() : "");
                    w.WriteLine(fearB2_5.Image.Tag != null ? fearB2_5.Image.Tag.ToString() : "");

                    w.WriteLine(fearB3_1.Image.Tag != null ? fearB3_1.Image.Tag.ToString() : "");
                    w.WriteLine(fearB3_2.Image.Tag != null ? fearB3_2.Image.Tag.ToString() : "");
                    w.WriteLine(fearB3_3.Image.Tag != null ? fearB3_3.Image.Tag.ToString() : "");
                    w.WriteLine(fearB3_4.Image.Tag != null ? fearB3_4.Image.Tag.ToString() : "");
                    w.WriteLine(fearB3_5.Image.Tag != null ? fearB3_5.Image.Tag.ToString() : "");

                    w.WriteLine(fearB4_1.Image.Tag != null ? fearB4_1.Image.Tag.ToString() : "");
                    w.WriteLine(fearB4_2.Image.Tag != null ? fearB4_2.Image.Tag.ToString() : "");
                    w.WriteLine(fearB4_3.Image.Tag != null ? fearB4_3.Image.Tag.ToString() : "");
                    w.WriteLine(fearB4_4.Image.Tag != null ? fearB4_4.Image.Tag.ToString() : "");
                    w.WriteLine(fearB4_5.Image.Tag != null ? fearB4_5.Image.Tag.ToString() : "");

                    w.WriteLine(fearR1_1.Image.Tag != null ? fearR1_1.Image.Tag.ToString() : "");
                    w.WriteLine(fearR1_2.Image.Tag != null ? fearR1_2.Image.Tag.ToString() : "");
                    w.WriteLine(fearR1_3.Image.Tag != null ? fearR1_3.Image.Tag.ToString() : "");
                    w.WriteLine(fearR1_4.Image.Tag != null ? fearR1_4.Image.Tag.ToString() : "");
                    w.WriteLine(fearR1_5.Image.Tag != null ? fearR1_5.Image.Tag.ToString() : "");

                    w.WriteLine(fearR2_1.Image.Tag != null ? fearR2_1.Image.Tag.ToString() : "");
                    w.WriteLine(fearR2_2.Image.Tag != null ? fearR2_2.Image.Tag.ToString() : "");
                    w.WriteLine(fearR2_3.Image.Tag != null ? fearR2_3.Image.Tag.ToString() : "");
                    w.WriteLine(fearR2_4.Image.Tag != null ? fearR2_4.Image.Tag.ToString() : "");
                    w.WriteLine(fearR2_5.Image.Tag != null ? fearR2_5.Image.Tag.ToString() : "");

                    w.WriteLine(fearR3_1.Image.Tag != null ? fearR3_1.Image.Tag.ToString() : "");
                    w.WriteLine(fearR3_2.Image.Tag != null ? fearR3_2.Image.Tag.ToString() : "");
                    w.WriteLine(fearR3_3.Image.Tag != null ? fearR3_3.Image.Tag.ToString() : "");
                    w.WriteLine(fearR3_4.Image.Tag != null ? fearR3_4.Image.Tag.ToString() : "");
                    w.WriteLine(fearR3_5.Image.Tag != null ? fearR3_5.Image.Tag.ToString() : "");

                    w.WriteLine(fearR4_1.Image.Tag != null ? fearR4_1.Image.Tag.ToString() : "");
                    w.WriteLine(fearR4_2.Image.Tag != null ? fearR4_2.Image.Tag.ToString() : "");
                    w.WriteLine(fearR4_3.Image.Tag != null ? fearR4_3.Image.Tag.ToString() : "");
                    w.WriteLine(fearR4_4.Image.Tag != null ? fearR4_4.Image.Tag.ToString() : "");
                    w.WriteLine(fearR4_5.Image.Tag != null ? fearR4_5.Image.Tag.ToString() : "");

                }

                MessageBox.Show("저장완료");
            }
            catch (Exception ex) { }

        }

        private void button6_Click(object sender, EventArgs e)
        {
            try
            {
                string path = Environment.CurrentDirectory + @"\Data\fearless.txt";

                string[] values = File.ReadAllLines(path);
                int i = 0;

                Image getimage(string str) {
                    return mainForm.imageReSize(40, 40, getChampsPath(Path.GetFileName(str).Replace("_140140.png", "")));
                }
                void setimage(PictureEdit p)
                {
                    string str = values[i];
                    i++;
                    if (str.Contains("Champs(140x140)")) p.Image = getimage(str);
                    else p.Image = getimage("Clear");
                }

                setimage(fearB1_1);
                setimage(fearB1_2);
                setimage(fearB1_3);
                setimage(fearB1_4);
                setimage(fearB1_5);

                setimage(fearB2_1);
                setimage(fearB2_2);
                setimage(fearB2_3);
                setimage(fearB2_4);
                setimage(fearB2_5);

                setimage(fearB3_1);
                setimage(fearB3_2);
                setimage(fearB3_3);
                setimage(fearB3_4);
                setimage(fearB3_5);

                setimage(fearB4_1);
                setimage(fearB4_2);
                setimage(fearB4_3);
                setimage(fearB4_4);
                setimage(fearB4_5);

                setimage(fearR1_1);
                setimage(fearR1_2);
                setimage(fearR1_3);
                setimage(fearR1_4);
                setimage(fearR1_5);

                setimage(fearR2_1);
                setimage(fearR2_2);
                setimage(fearR2_3);
                setimage(fearR2_4);
                setimage(fearR2_5);

                setimage(fearR3_1);
                setimage(fearR3_2);
                setimage(fearR3_3);
                setimage(fearR3_4);
                setimage(fearR3_5);

                setimage(fearR4_1);
                setimage(fearR4_2);
                setimage(fearR4_3);
                setimage(fearR4_4);
                setimage(fearR4_5);


                MessageBox.Show("로드완료");
            }
            catch (Exception ex)
            {
                MessageBox.Show("로드에러..");
            }
        }

        private void button8_Click(object sender, EventArgs e)
        {
            //데이터 초기화를 위한 작업
            for (int i = 0; i < 5; i++)
            {
                ((Label)groupControl14.Controls["lblPriorityRed" + (i + 1)]).Text = "Data 우선";
                ((Label)groupControl14.Controls["lblPriorityBlue" + (i + 1)]).Text = "Data 우선";
                ((Label)groupControl14.Controls["lblStateRed" + (i + 1)]).Text = "상태";
                ((Label)groupControl14.Controls["lblStateBlue" + (i + 1)]).Text = "상태";
            }
        }
    }
}
