private async void lbRares_SelectedIndexChanged(object sender, EventArgs e) { int id = getIDfromListBox(); cRare cRare = RareData.Find(p => p.ID.Equals(id)); if (cRare != null) { lbInfo1.Text = string.Format("Attack: {0} | Defense: {1} | Magic: {2} | Resist: {3}", cRare.Attack, cRare.Defense, cRare.Magic, cRare.Resist); lbInfo2.Text = string.Format("Grade: {0} | Type: {1}", (RARE_GRADE)cRare.Grade, (RARE_TYPE)cRare.Type); dgOptions.Rows.Clear(); for (int i = 0; i <= 9; i++) { var optionAddons = await cImport.getOptionAddons(cRare.OPTIONID[i]); foreach (DataRow dataRow in optionAddons.Rows) { string[] optionName; optionName = new string[24]; for (int j = 0; j <= 23; j++) { optionName[j] = (j == 0) ? (string)dataRow["a_name"] : (string)dataRow["a_name_" + Enum.GetName(typeof(Language), j).ToLower()]; } dgOptions.Rows.Add(/*cRare.OPTIONID[i],*/ optionName[(int)cImport.CurrentLanguage], cRare.OPTIONLVL[i], dataRow["a_level"].ToString().Split(' ')[cRare.OPTIONLVL[i]], cRare.OPTIONPROB[i]); } } } }
private async void GetRare() { RareData = new List <cRare>(); var rareData = await cMySQL.QueryToDataTable("SELECT * FROM t_rareoption ORDER BY a_index"); Parallel.ForEach(rareData.AsEnumerable(), new ParallelOptions { MaxDegreeOfParallelism = 1 }, dataRow => { cRare cRare = new cRare { ID = Convert.ToInt32(dataRow["a_index"]), Grade = Convert.ToByte(dataRow["a_grade"]), Type = Convert.ToByte(dataRow["a_type"]), Attack = Convert.ToInt32(dataRow["a_attack"]), Defense = Convert.ToInt32(dataRow["a_defense"]), Magic = Convert.ToInt32(dataRow["a_magic"]), Resist = Convert.ToInt32(dataRow["a_resist"]), OPTIONID = new int[10], OPTIONLVL = new int[10], OPTIONPROB = new int[10], Name = new string[24], Prefix = new string[24], }; for (int i = 0; i <= 9; i++) { cRare.OPTIONID[i] = Convert.ToInt32(dataRow["a_option_index" + i]); cRare.OPTIONPROB[i] = Convert.ToInt32(dataRow["a_option_prob" + i]); cRare.OPTIONLVL[i] = Convert.ToInt32(dataRow["a_option_level" + i]); } for (int i = 0; i <= 23; i++) { cRare.Name[i] = (i == 0 || i == 2 || i == 23) ? dataRow["a_name"].ToString() : dataRow["a_name_" + Enum.GetName(typeof(Language), i).ToLower()].ToString(); cRare.Prefix[i] = (i == 0 || i == 2 || i == 23) ? dataRow["a_prefix"].ToString() : dataRow["a_prefix_" + Enum.GetName(typeof(Language), i).ToLower()].ToString(); } RareData.Add(cRare); }); }