private void GameStatistic_Load(object sender, EventArgs e) { ArrayList availablePlatforms = GameStatisticModel.GetAvailablePlatforms(onlineId); try { platform = availablePlatforms[0].ToString(); } catch (Exception) { //Platform not found! return; } string defaultPlatform = IniModel.GetPSNPlatform(); /*if (availablePlatforms.IndexOf(defaultPlatform) > -1) * { * availablePlatforms * }*/ foreach (String platform in availablePlatforms) { if (defaultPlatform == platform) { toolStripComboBox1.Items.Insert(0, platform); } else { toolStripComboBox1.Items.Add(platform); } } toolStripComboBox1.SelectedIndex = 0; }
private async Task LoadListAsync(String platform) { imageList.Images.Clear(); imageList.ImageSize = new Size(128, 128); imageList.ColorDepth = ColorDepth.Depth16Bit; listView1.Clear(); ArrayList files = GameStatisticModel.GetFiles(onlineId, platform); foreach (String file in files) { String jsonString = File.ReadAllText(file); Dictionary <string, dynamic> data = JsonConvert.DeserializeObject <Dictionary <string, dynamic> >(jsonString); /* Variables */ String titleName = data["titleName"]; String npTitleId = data["npTitleId"]; String npTitleIconUrl = data["npTitleIconUrl"]; int totalPlayTime = 0; data["date"] = JObject.FromObject(data["date"]).ToObject <Dictionary <string, dynamic> >(); foreach (KeyValuePair <string, dynamic> date in data["date"]) { totalPlayTime += Convert.ToInt16(date.Value.playTime); } /* Variables */ Image bitmap = null; if (npTitleIconUrl == "") { bitmap = new Bitmap(Properties.Resources.NoGameImage); } else { bitmap = await Task.Run(() => GetImageAsync(npTitleIconUrl)); } imageList.Images.Add("itemImageKey", bitmap); ListViewItem listViewItem = new ListViewItem(); listViewItem.Text = titleName + "\n" + Utils.CalculateMinuteToTime(totalPlayTime) + "on records."; listViewItem.ImageIndex = listView1.Items.Count; listView1.LargeImageList = imageList; listView1.Items.Add(listViewItem); } }