private void UpdateData() { foreach (KeyValuePair <String, InviteInfo> info in Client.InviteData) { InviteInfo data = info.Value; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { ChatListView.Items.Clear(); InvitesNotification notification = new InvitesNotification(); notification.Accept.Click += (s, e) => { Client.PVPNet.Accept(data.stats.InvitationId); Client.InviteData.Remove(data.stats.InvitationId); Client.SwitchPage(new TeamQueuePage(data.stats.InvitationId)); }; notification.Decline.Click += (s, e) => { Client.PVPNet.Decline(data.stats.InvitationId); Client.InviteData.Remove(data.stats.InvitationId); }; notification.TitleLabel.Content = "Game Invite"; notification.BodyTextbox.Text = data.stats.Inviter + " has invited you to a game"; invitationRequest m = JsonConvert.DeserializeObject <invitationRequest>(data.stats.GameMetaData); string MapName; CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; TextInfo textInfo = cultureInfo.TextInfo; var gameModeLower = textInfo.ToTitleCase(string.Format(m.gameMode.ToLower())); var gameTypeLower = textInfo.ToTitleCase(string.Format(m.gameType.ToLower())); //Why do I have to do this Riot? var gameTypeRemove = gameTypeLower.Replace("_game", ""); var removeAllUnder = gameTypeRemove.Replace("_", " "); notification.BodyTextbox.Text += "Mode: " + gameModeLower; if (m.mapId == 1) { MapName = "Summoners Rift"; } else if (m.mapId == 10) { MapName = "The Twisted Treeline"; } else if (m.mapId == 12) { MapName = "Howling Abyss"; } else if (m.mapId == 8) { MapName = "The Crystal Scar"; } else { MapName = "Unknown Map"; } notification.BodyTextbox.Text += "Map: " + MapName; notification.BodyTextbox.Text += "Type: " + removeAllUnder; ChatListView.Items.Add(notification); })); } }
private void UpdateData() { foreach (InviteInfo data in Client.InviteData.Select(info => info.Value)) { InviteInfo data2 = data; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { ChatListView.Items.Clear(); var notification = new InvitesNotification(); InviteInfo data1 = data2; notification.Accept.Click += (s, e) => { Client.SwitchPage(new TeamQueuePage(data1.stats.InvitationId)); Client.PVPNet.Accept(data1.stats.InvitationId); Client.InviteData.Remove(data1.stats.InvitationId); }; notification.Decline.Click += (s, e) => { Client.PVPNet.Decline(data2.stats.InvitationId); Client.InviteData.Remove(data2.stats.InvitationId); }; notification.TitleLabel.Content = "Game Invite"; string _name; if (data2.stats.Inviter != null) { _name = data2.stats.Inviter.SummonerName; } else { _name = data2.stats.Owner.SummonerName; } notification.BodyTextbox.Text = _name + " has invited you to a game" + Environment.NewLine; var m = JsonConvert.DeserializeObject <invitationRequest>(data2.stats.GameMetaData); string mapName; CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; TextInfo textInfo = cultureInfo.TextInfo; string gameModeLower = textInfo.ToTitleCase(string.Format(m.gameMode.ToLower())); string gameTypeLower = textInfo.ToTitleCase(string.Format(m.gameType.ToLower())); string gameTypeRemove = gameTypeLower.Replace("_game", ""); string removeAllUnder = gameTypeRemove.Replace("_", " "); notification.BodyTextbox.Text += "Mode: " + gameModeLower + Environment.NewLine; switch (m.mapId) { case 1: mapName = "Summoners Rift"; break; case 10: mapName = "The Twisted Treeline"; break; case 12: mapName = "Howling Abyss"; break; case 8: mapName = "The Crystal Scar"; break; default: mapName = "Unknown Map"; break; } notification.BodyTextbox.Text += "Map: " + mapName + Environment.NewLine; notification.BodyTextbox.Text += "Type: " + removeAllUnder; ChatListView.Items.Add(notification); })); } }