public void updateTeamBox(Player p, FantasyTeam team) { string playerPosition = p.Position; IEnumerable<Label> correspondingLabels = panelTeam.Children.OfType<Label>().Where(label => label.Content.ToString().StartsWith(playerPosition)); Label nextOpenSlot = correspondingLabels.FirstOrDefault(lab => lab.Content.ToString().Split('-')[1].Length == 0); if (nextOpenSlot != null) { nextOpenSlot.Content += p.toTeam(); Label projectedTotalLabel = panelTeam.Children.OfType<Label>().First(label => label.Name.Equals("projTotal")); projectedTotalLabel.Content = "Proj. Total - " + team.ProjectedTotal + " pts"; } else { IEnumerable<Label> benchSlots = panelTeam.Children.OfType<Label>().Where(label => label.Content.ToString().StartsWith("BENCH")); nextOpenSlot = benchSlots.FirstOrDefault(lab => lab.Content.ToString().Length == 8); if (nextOpenSlot != null) { nextOpenSlot.Content += p.toTeam(); } } }
public void AddPlayerToTeamBox(Player playerToBeAdded) { string position = playerToBeAdded.Position; IEnumerable<Label> corresponding = panelTeam.Children.OfType<Label>().Where(label => label.Content.ToString().StartsWith(position)); Label nextSlot = corresponding.FirstOrDefault(lab => lab.Content.ToString().Length < 7); if (nextSlot != null) { nextSlot.Content += playerToBeAdded.toTeam(); Label projected = panelTeam.Children.OfType<Label>().Last(); projected.Content = "Proj. Total - " + mockTeam.ProjectedTotal + " pts"; } else { IEnumerable<Label> benchSlots = panelTeam.Children.OfType<Label>().Where(label => label.Content.ToString().StartsWith("BENCH")); nextSlot = benchSlots.FirstOrDefault(lab => lab.Content.ToString().Length == 8); if (nextSlot != null) { nextSlot.Content += playerToBeAdded.toTeam(); } } }
public void UpdateTeamBox(Player player) { StackPanel panelTeam = current.teamPanel; string playerPosition = player.Position; IEnumerable<Label> correspondingLabels = panelTeam.Children.OfType<Label>().Where(label => label.Content.ToString().StartsWith(playerPosition)); string first = correspondingLabels.First().Content.ToString(); Label nextOpenSlot = correspondingLabels.FirstOrDefault(lab => lab.Content.ToString().Split('-')[1].Length == 1); if (nextOpenSlot != null) { nextOpenSlot.Content += player.toTeam(); Label projectedTotalLabel = panelTeam.Children.OfType<Label>().First(label => label.Name.Equals("projTotal")); projectedTotalLabel.Content = "Proj. Total - " + Brain.MyDraft.MyTeam.ProjectedTotal + " pts"; } else { IEnumerable<Label> benchSlots = panelTeam.Children.OfType<Label>().Where(label => label.Content.ToString().StartsWith("BENCH")); nextOpenSlot = benchSlots.FirstOrDefault(lab => lab.Content.ToString().Split('-')[1].Length == 1); if (nextOpenSlot != null) { nextOpenSlot.Content += player.toTeam(); } } }
private void addToBench(Player p) { IEnumerable<Label> bench = teamPanel.Children.OfType<Label>().Where(t => t.Name.StartsWith("B")); int counter = 0; while(bench.ElementAt(counter).Content.ToString().Replace("BN -",string.Empty).Length == 0) { counter++; } bench.ElementAt(counter).Content += p.toTeam(); }