protected override void DisplayContent() { contentWrapPanel.Children.Clear(); upgradesToDisplay = upgradesToDisplay.OrderBy(upgrade => upgrade.upgradeType.ToString()).ThenByDescending(upgrade => upgrade.cost).ThenBy(upgrade => upgrade.name).ToList(); foreach (Upgrade upgrade in upgradesToDisplay) { if (upgrade.shipSize == ShipSize.Huge || upgrade.upgradeType == UpgradeType.Team || upgrade.upgradeType == UpgradeType.Hardpoint || upgrade.upgradeType == UpgradeType.Cargo) { continue; } if (upgradeCache.ContainsKey(upgrade.id) == false) { CardCanvas upgradeCanvas = upgrade.GetCanvas(upgradeCardWidth, upgradeCardHeight, new Thickness(2, 2, 2, 2), this); upgradeCanvas.AddCardClickedEvent(this); upgradeCache[upgrade.id] = upgradeCanvas; } upgradeCache[upgrade.id].UpdateNumberOwned(); contentWrapPanel.Children.Add(upgradeCache[upgrade.id]); } pilotsToDisplay = pilotsToDisplay.ToList().OrderBy(pilot => pilot.faction).ThenBy(pilot => pilot.ship.name).ThenByDescending(pilot => pilot.pilotSkill).ThenByDescending(pilot => pilot.cost).ThenBy(pilot => pilot.name).ToList(); foreach (Pilot pilot in pilotsToDisplay) { if (pilot.ship.shipSize == ShipSize.Huge) { continue; } if (pilotCache.ContainsKey(pilot.id) == false) { CardCanvas pilotCanvas = pilot.GetCanvas(pilotCardWidth, pilotCardHeight, new Thickness(2, 2, 2, 2), this); pilotCanvas.AddCardClickedEvent(this); pilotCache[pilot.id] = pilotCanvas; } pilotCache[pilot.id].UpdateNumberOwned(); contentWrapPanel.Children.Add(pilotCache[pilot.id]); } if (contentWrapPanel.Children.Count == 0) { TextBlock instructions = new TextBlock(); instructions.Text = "Enter any word in the search box above to find Upgraes/Pilots with that name\r\n"; instructions.Text += "'all' will show all the Upgrades or Pilots depending on which is selected\r\n"; instructions.Text += "'PS8' or 'PS4-7', using any numbers, will show pilots of, or between, that Pilot Skill\r\n"; instructions.Text += "'8' or '4-7', using any numbers, will show cards of, or between, that cost\r\n"; instructions.Text += "'torpedo' or 'tech', using any upgrade, will show cards of that are, or can use, that upgrade\r\n"; instructions.Text += "'rebel', 'scum' or 'imperial' will show cards of that faction\r\n"; instructions.Text += "'Y-Wing' or 'TIE/fo', using any ship name, will show pilots who use that ship\r\n"; instructions.Text += "'small' or 'large' will show pilots whose ships are of that size"; instructions.FontSize = Opt.ApResMod(14); instructions.LineHeight = 30; instructions.Background = new SolidColorBrush(Color.FromRgb(250, 250, 250)); instructions.Padding = ScaledThicknessFactory.GetThickness(20); contentWrapPanel.Children.Add(instructions); } contentWrapPanel.Margin = new Thickness(0, 0, 0, 40); }
public void AddPilotToCache(Pilot pilot) { if (pilotCache.ContainsKey(pilot.id) == false) { CardCanvas pilotCanvas = pilot.GetCanvas(pilotCardWidth, pilotCardHeight, new Thickness(2, 2, 2, 2), this); pilotCanvas.AddCardClickedEvent(this); pilotCache[pilot.id] = pilotCanvas; } }
public void AddUpgradeToCache(Upgrade upgrade) { if (upgradeCache.ContainsKey(upgrade.id) == false) { CardCanvas upgradeCanvas = upgrade.GetCanvas(upgradeCardWidth, upgradeCardHeight, new Thickness(2, 2, 2, 2), this); upgradeCanvas.AddCardClickedEvent(this); upgradeCache[upgrade.id] = upgradeCanvas; } }