示例#1
0
        private void SetExistMagic(string magic)
        {
            MagicInfo existMagicInfo = MagicLib.MagicList1.FirstOrDefault(item => item.Name == magic);

            if (existMagicInfo == null)
            {
                existMagicInfo = MagicLib.MagicList2.FirstOrDefault(item => item.Name == magic);
                if (existMagicInfo == null)
                {
                    existMagicInfo = MagicLib.MagicList3.FirstOrDefault(item => item.Name == magic);
                    if (existMagicInfo == null)
                    {
                        existMagicInfo = MagicLib.MagicList4.FirstOrDefault(item => item.Name == magic);
                        if (existMagicInfo == null)
                        {
                            existMagicInfo = MagicLib.MagicList5.FirstOrDefault(item => item.Name == magic);
                        }
                    }
                }
            }

            if (existMagicInfo != null)
            {
                ListBox currntListBox = null;
                switch (existMagicInfo.Column)
                {
                case "1":
                    currntListBox = listBoxMagic1;
                    break;

                case "2":
                    currntListBox = listBoxMagic2;
                    break;

                case "3":
                    currntListBox = listBoxMagic3;
                    break;

                case "4":
                    currntListBox = listBoxMagic4;
                    break;

                case "5":
                    currntListBox = listBoxMagic5;
                    break;

                default:
                    break;
                }

                foreach (var item  in currntListBox.Items)
                {
                    if (((dynamic)item).Name == magic)
                    {
                        currntListBox.SelectedItem = item;
                        break;
                    }
                }
            }
        }
示例#2
0
        public static void Initialize()
        {
            string[] MagicInfoList = Properties.ResourceSetting.Magic.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

            for (int i = 1; i < MagicInfoList.Length; i++)
            {
                var magicLine = MagicInfoList[i];

                try
                {
                    string[] itemDetail = magicLine.Split(',');
                    if (itemDetail.Length < 4)
                    {
                        continue;
                    }
                    MagicInfo item = new MagicInfo();
                    item.Column = itemDetail[0];
                    item.Code   = itemDetail[1];
                    item.Name   = itemDetail[2];
                    item.Mp     = itemDetail[3];
                    MagicInfo[] MagicList = null;
                    switch (item.Column)
                    {
                    case "1":
                        MagicList = MagicList1;
                        break;

                    case "2":
                        MagicList = MagicList2;
                        break;

                    case "3":
                        MagicList = MagicList3;
                        break;

                    case "4":
                        MagicList = MagicList4;
                        break;

                    case "5":
                        MagicList = MagicList5;
                        break;

                    default:
                        break;
                    }
                    MagicList[int.Parse(item.Code) - 1] = item;
                }
                catch (Exception ex)
                {
                    string exe = ex.ToString();
                }
            }
        }