public void SetGear(Gear gear) { // Remove previous Downloader's handlers, let lambda decide //DownloadHelper.RemoveDownloaders(Downloader.SourceType.Gear); Gear = gear; // Fade out labels and images ((Storyboard)FindResource("fade_out")).Begin(bdGear); ((Storyboard)FindResource("fade_out")).Begin(bdMain); ((Storyboard)FindResource("fade_out")).Begin(bdSub1); ((Storyboard)FindResource("fade_out")).Begin(bdSub2); ((Storyboard)FindResource("fade_out")).Begin(bdSub3); if (Gear != null) { // Gear string image = FileFolderUrl.ApplicationData + Gear.Image; try { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image))); brush.Stretch = Stretch.Uniform; bdGear.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(bdGear); } catch { // Download the image Downloader downloader = new Downloader(FileFolderUrl.SplatNet + Gear.Image, image, Downloader.SourceType.Gear, Depot.Proxy); DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() => { if (System.IO.Path.GetFileName(image) == System.IO.Path.GetFileName(Gear.Image)) { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image))); brush.Stretch = Stretch.Uniform; bdGear.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(bdGear); } })); } // Primary ability string image2 = FileFolderUrl.ApplicationData + Gear.PrimaryAbility.Image; try { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image2))); brush.Stretch = Stretch.Uniform; bdMain.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(bdMain); } catch { // Download the image Downloader downloader = new Downloader(FileFolderUrl.SplatNet + Gear.PrimaryAbility.Image, image2, Downloader.SourceType.Gear, Depot.Proxy); DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() => { if (System.IO.Path.GetFileName(image2) == System.IO.Path.GetFileName(Gear.PrimaryAbility.Image)) { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image2))); brush.Stretch = Stretch.Uniform; bdMain.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(bdMain); } })); } // Secondary ability string image3 = FileFolderUrl.ApplicationData + Gear.SecondaryAbilities[0].Image; try { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image3))); brush.Stretch = Stretch.Uniform; bdSub1.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(bdSub1); } catch { // Download the image Downloader downloader = new Downloader(FileFolderUrl.SplatNet + Gear.SecondaryAbilities[0].Image, image3, Downloader.SourceType.Gear, Depot.Proxy); DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() => { if (System.IO.Path.GetFileName(image3) == System.IO.Path.GetFileName(Gear.SecondaryAbilities[0].Image)) { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image3))); brush.Stretch = Stretch.Uniform; bdSub1.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(bdSub1); } })); } if (Gear.SecondaryAbilities.Count > 1) { // Secondary ability 2 string image4 = FileFolderUrl.ApplicationData + Gear.SecondaryAbilities[1].Image; try { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image4))); brush.Stretch = Stretch.Uniform; bdSub2.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(bdSub2); ((Storyboard)FindResource("fade_in")).Begin(bdSub2Background); } catch { // Download the image Downloader downloader = new Downloader(FileFolderUrl.SplatNet + Gear.SecondaryAbilities[1].Image, image4, Downloader.SourceType.Gear, Depot.Proxy); DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() => { if (Gear.SecondaryAbilities.Count > 1) { if (System.IO.Path.GetFileName(image4) == System.IO.Path.GetFileName(Gear.SecondaryAbilities[1].Image)) { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image4))); brush.Stretch = Stretch.Uniform; bdSub2.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(bdSub2); ((Storyboard)FindResource("fade_in")).Begin(bdSub2Background); } } })); } if (Gear.SecondaryAbilities.Count > 2) { // Secondary ability 3 string image5 = FileFolderUrl.ApplicationData + Gear.SecondaryAbilities[2].Image; try { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image5))); brush.Stretch = Stretch.Uniform; bdSub3.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(bdSub3); ((Storyboard)FindResource("fade_in")).Begin(bdSub3Background); } catch { // Download the image Downloader downloader = new Downloader(FileFolderUrl.SplatNet + Gear.SecondaryAbilities[2].Image, image5, Downloader.SourceType.Gear, Depot.Proxy); DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() => { if (Gear.SecondaryAbilities.Count > 2) { if (System.IO.Path.GetFileName(image5) == System.IO.Path.GetFileName(Gear.SecondaryAbilities[2].Image)) { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image5))); brush.Stretch = Stretch.Uniform; bdSub3.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(bdSub3); ((Storyboard)FindResource("fade_in")).Begin(bdSub3Background); } } })); } } else { ((Storyboard)FindResource("fade_out")).Begin(bdSub3Background); } } else { ((Storyboard)FindResource("fade_out")).Begin(bdSub2Background); ((Storyboard)FindResource("fade_out")).Begin(bdSub3Background); } } }
public void SetPlayer(Player player, bool isMy) { Player = player; IsMy = isMy; ((Storyboard)FindResource("fade_out")).Begin(gridMain); ((Storyboard)FindResource("fade_out")).Begin(bdIcon); ((Storyboard)FindResource("fade_out")).Begin(bdWeapon); ((Storyboard)FindResource("fade_out")).Begin(bdSpecial); Storyboard sb = (Storyboard)FindResource("resize_width"); (sb.Children[0] as DoubleAnimation).To = 0; sb.Begin(bdKillDeathRatio); ((Storyboard)FindResource("fade_out")).Begin(bdKillDeathRatio); ((Storyboard)FindResource("bg_to_black")).Begin(bdMain); if (Player != null) { // Background change bdOffline.Background = new SolidColorBrush(Colors.Transparent); if (Player.IsSelf) { ((Storyboard)FindResource("bg_to_white")).Begin(bdMain); } else if (Player.IsOffline) { bdOffline.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#7F000000")); } // Level or Rank if (Player.Level >= 100) { tbLevel.Text = (Player.Level - 100 * Player.Star).ToString(); tbStar.SetResourceReference(Run.TextProperty, "player_control-★"); tbRank.Text = ""; } else { tbLevel.Text = Player.Level.ToString(); tbStar.Text = ""; tbRank.Text = ""; } ((Storyboard)FindResource("fade_in")).Begin(lbLevel); ((Storyboard)FindResource("fade_out")).Begin(lbRank); if (Player is RankedPlayer) { tbRank.SetResourceReference(TextBlock.TextProperty, (Player as RankedPlayer).Rank.ToString()); ((Storyboard)FindResource("fade_in")).Begin(lbRank); ((Storyboard)FindResource("fade_out")).Begin(lbLevel); } // Icon string image = FileFolderUrl.ApplicationData + FileFolderUrl.IconFolder + @"\" + System.IO.Path.GetFileName(Player.Image) + ".jpg"; try { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image))); brush.Stretch = Stretch.UniformToFill; bdIcon.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(bdIcon); } catch { // Download the image Downloader downloader = new Downloader(Player.Image, image, Downloader.SourceType.Battle, Depot.Proxy); DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() => { if (Player != null) { if (System.IO.Path.GetFileName(image) == System.IO.Path.GetFileName(Player.Image) + ".jpg") { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image))); brush.Stretch = Stretch.UniformToFill; bdIcon.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(bdIcon); } } })); } // Weapon image string image2 = FileFolderUrl.ApplicationData + Player.Weapon.Image; try { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image2))); brush.Stretch = Stretch.UniformToFill; bdWeapon.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(bdWeapon); } catch { // Download the image Downloader downloader = new Downloader(FileFolderUrl.SplatNet + Player.Weapon.Image, image2, Downloader.SourceType.Battle, Depot.Proxy); DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() => { if (Player != null) { if (System.IO.Path.GetFileName(image2) == System.IO.Path.GetFileName(Player.Weapon.Image)) { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image2))); brush.Stretch = Stretch.UniformToFill; bdWeapon.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(bdWeapon); } } })); } // Nickname and paint tbNickname.Text = Player.Nickname; lbPaint.Content = string.Format(Translate("{0}p", true), Player.Paint.ToString()); // Kill, death and special switch (player.Species) { case Player.SpeciesType.inklings: ((Storyboard)FindResource("fade_in")).Begin(imgInklingsKill); ((Storyboard)FindResource("fade_in")).Begin(imgInklingsDeath); ((Storyboard)FindResource("fade_out")).Begin(imgOctolingsKill); ((Storyboard)FindResource("fade_out")).Begin(imgOctolingsDeath); break; case Player.SpeciesType.octolings: ((Storyboard)FindResource("fade_in")).Begin(imgOctolingsKill); ((Storyboard)FindResource("fade_in")).Begin(imgOctolingsDeath); ((Storyboard)FindResource("fade_out")).Begin(imgInklingsKill); ((Storyboard)FindResource("fade_out")).Begin(imgInklingsDeath); break; default: throw new ArgumentOutOfRangeException(); } tbKillAndAssist.Text = Player.KillAndAssist.ToString(); tbDeath.Text = Player.Death.ToString(); tbKD.Text = string.Format("{0:f2}", Player.KillDeathRatio); if (Player.Assist > 0) { tbAssist.Text = string.Format(Translate("({0})", true), Player.Assist); } else { tbAssist.Text = ""; } tbSpecial.Text = Player.Special.ToString(); // Special image string image3; if (IsMy) { image3 = FileFolderUrl.ApplicationData + Player.Weapon.SpecialWeapon.Image1; } else { image3 = FileFolderUrl.ApplicationData + Player.Weapon.SpecialWeapon.Image2; } try { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image3))); brush.Stretch = Stretch.Uniform; bdSpecial.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(bdSpecial); } catch { // Download the image Downloader downloader; if (IsMy) { downloader = new Downloader(FileFolderUrl.SplatNet + Player.Weapon.SpecialWeapon.Image1, image3, Downloader.SourceType.Battle, Depot.Proxy); } else { downloader = new Downloader(FileFolderUrl.SplatNet + Player.Weapon.SpecialWeapon.Image2, image3, Downloader.SourceType.Battle, Depot.Proxy); } DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() => { if (Player != null) { if (IsMy) { if (System.IO.Path.GetFileName(image3) == System.IO.Path.GetFileName(Player.Weapon.SpecialWeapon.Image1)) { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image3))); brush.Stretch = Stretch.Uniform; bdSpecial.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(bdSpecial); } } else { if (System.IO.Path.GetFileName(image3) == System.IO.Path.GetFileName(Player.Weapon.SpecialWeapon.Image2)) { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image3))); brush.Stretch = Stretch.Uniform; bdSpecial.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(bdSpecial); } } } })); } // Kill death ratio if (IsMy) { bdKillDeathRatio.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#2F" + Design.NeonRed)); } else { bdKillDeathRatio.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#2F" + Design.NeonGreen)); } double to; if (player.IsOffline) { to = 0; } else { if (player.KillDeathRatio <= 2) { to = bdMain.ActualWidth * (0.05 + 0.35 * player.KillDeathRatio); } else if (player.KillDeathRatio <= 8) { to = bdMain.ActualWidth * (0.75 + 0.25 * (Math.Log(player.KillDeathRatio) / Math.Log(2)) / 3); } else { to = bdMain.ActualWidth; } } (sb.Children[0] as DoubleAnimation).To = to; sb.Begin(bdKillDeathRatio); ((Storyboard)FindResource("fade_in")).Begin(bdKillDeathRatio); // Show all ((Storyboard)FindResource("fade_in")).Begin(gridMain); } }
public void SetWave(Wave wave, int number = 0) { Wave = wave; Number = number; ((Storyboard)FindResource("fade_out")).Begin(bdTide); ((Storyboard)FindResource("fade_out")).Begin(lbWave); ((Storyboard)FindResource("fade_out")).Begin(lbResult); ((Storyboard)FindResource("fade_out")).Begin(lbGoldenEgg); ((Storyboard)FindResource("fade_out")).Begin(lbTide); ((Storyboard)FindResource("fade_out")).Begin(spGoldenEggPop); ((Storyboard)FindResource("fade_out")).Begin(lbEvent); ((Storyboard)FindResource("fade_out")).Begin(spSpecial); ((Storyboard)FindResource("fade_out")).Begin(gridSpecial1); ((Storyboard)FindResource("fade_out")).Begin(gridSpecial2); ((Storyboard)FindResource("fade_out")).Begin(gridSpecial3); ((Storyboard)FindResource("fade_out")).Begin(gridSpecial4); ((Storyboard)FindResource("fade_out")).Begin(gridSpecial5); ((Storyboard)FindResource("fade_out")).Begin(gridSpecial6); ((Storyboard)FindResource("fade_out")).Begin(gridSpecial7); ((Storyboard)FindResource("fade_out")).Begin(gridSpecial8); Storyboard sb = (Storyboard)FindResource("resize_height"); (sb.Children[0] as DoubleAnimation).To = 0; sb.Begin(bdTide); ((Storyboard)FindResource("fade_out")).Begin(bdTide); if (Wave != null && Number > 0) { lbWave.Content = string.Format(Translate("wave_{0}", true), Number); lbResult.SetResourceReference(ContentProperty, Wave.Result.ToString()); lbGoldenEgg.Content = string.Format(Translate("{0}/{1}", true), Wave.GoldenEgg, Wave.Quota); lbGolderEggPop.Content = string.Format(Translate("x{0}", true), Wave.GoldenEggPop); lbTide.SetResourceReference(ContentProperty, Wave.WaterLevel.ToString()); lbEvent.SetResourceReference(ContentProperty, Wave.EventType.ToString()); if (wave.IsClear) { lbResult.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonGreen)); } else { lbResult.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonOrange)); } ((Storyboard)FindResource("fade_in")).Begin(lbWave); ((Storyboard)FindResource("fade_in")).Begin(lbGoldenEgg); ((Storyboard)FindResource("fade_in")).Begin(lbTide); ((Storyboard)FindResource("fade_in")).Begin(lbEvent); double to; switch (wave.WaterLevel) { case WaterLevel.Key.low: to = 10; break; case WaterLevel.Key.normal: to = 45; break; case WaterLevel.Key.high: to = 80; break; default: throw new ArgumentOutOfRangeException(); } if (Wave.Specials.Count > 0) { string image = FileFolderUrl.ApplicationData + Wave.Specials[0].Image1; try { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image))); brush.Stretch = Stretch.UniformToFill; bdSpecial1.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(gridSpecial1); } catch { // Download the image Downloader downloader = new Downloader(FileFolderUrl.SplatNet + Wave.Specials[0].Image1, image, Downloader.SourceType.Job, Depot.Proxy); DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() => { if (Wave != null && Wave.Specials.Count > 0) { if (System.IO.Path.GetFileName(image) == System.IO.Path.GetFileName(Wave.Specials[0].Image1)) { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image))); brush.Stretch = Stretch.UniformToFill; bdSpecial1.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(gridSpecial1); } } })); } if (Wave.Specials.Count > 1) { bdSpecial2.Width = 30; string image2 = FileFolderUrl.ApplicationData + Wave.Specials[1].Image1; try { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image2))); brush.Stretch = Stretch.UniformToFill; bdSpecial2.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(gridSpecial2); } catch { // Download the image Downloader downloader = new Downloader(FileFolderUrl.SplatNet + Wave.Specials[1].Image1, image2, Downloader.SourceType.Job, Depot.Proxy); DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() => { if (Wave != null && Wave.Specials.Count > 1) { if (System.IO.Path.GetFileName(image2) == System.IO.Path.GetFileName(Wave.Specials[1].Image1)) { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image2))); brush.Stretch = Stretch.UniformToFill; bdSpecial2.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(gridSpecial2); } } })); } if (Wave.Specials.Count > 2) { bdSpecial3.Width = 30; string image3 = FileFolderUrl.ApplicationData + Wave.Specials[2].Image1; try { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image3))); brush.Stretch = Stretch.UniformToFill; bdSpecial3.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(gridSpecial3); } catch { // Download the image Downloader downloader = new Downloader(FileFolderUrl.SplatNet + Wave.Specials[2].Image1, image3, Downloader.SourceType.Job, Depot.Proxy); DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() => { if (Wave != null && Wave.Specials.Count > 2) { if (System.IO.Path.GetFileName(image3) == System.IO.Path.GetFileName(Wave.Specials[2].Image1)) { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image3))); brush.Stretch = Stretch.UniformToFill; bdSpecial3.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(gridSpecial3); } } })); } if (Wave.Specials.Count > 3) { bdSpecial4.Width = 30; string image4 = FileFolderUrl.ApplicationData + Wave.Specials[3].Image1; try { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image4))); brush.Stretch = Stretch.UniformToFill; bdSpecial4.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(gridSpecial4); } catch { // Download the image Downloader downloader = new Downloader(FileFolderUrl.SplatNet + Wave.Specials[3].Image1, image4, Downloader.SourceType.Job, Depot.Proxy); DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() => { if (Wave != null && Wave.Specials.Count > 3) { if (System.IO.Path.GetFileName(image4) == System.IO.Path.GetFileName(Wave.Specials[3].Image1)) { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image4))); brush.Stretch = Stretch.UniformToFill; bdSpecial4.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(gridSpecial4); } } })); } if (Wave.Specials.Count > 4) { bdSpecial5.Width = 30; string image5 = FileFolderUrl.ApplicationData + Wave.Specials[4].Image1; try { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image5))); brush.Stretch = Stretch.UniformToFill; bdSpecial5.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(gridSpecial5); } catch { // Download the image Downloader downloader = new Downloader(FileFolderUrl.SplatNet + Wave.Specials[4].Image1, image5, Downloader.SourceType.Job, Depot.Proxy); DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() => { if (Wave != null && Wave.Specials.Count > 4) { if (System.IO.Path.GetFileName(image5) == System.IO.Path.GetFileName(Wave.Specials[4].Image1)) { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image5))); brush.Stretch = Stretch.UniformToFill; bdSpecial5.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(gridSpecial5); } } })); } if (Wave.Specials.Count > 5) { bdSpecial6.Width = 30; string image6 = FileFolderUrl.ApplicationData + Wave.Specials[5].Image1; try { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image6))); brush.Stretch = Stretch.UniformToFill; bdSpecial6.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(gridSpecial6); } catch { // Download the image Downloader downloader = new Downloader(FileFolderUrl.SplatNet + Wave.Specials[5].Image1, image6, Downloader.SourceType.Job, Depot.Proxy); DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() => { if (Wave != null && Wave.Specials.Count > 5) { if (System.IO.Path.GetFileName(image6) == System.IO.Path.GetFileName(Wave.Specials[5].Image1)) { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image6))); brush.Stretch = Stretch.UniformToFill; bdSpecial6.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(gridSpecial6); } } })); } if (Wave.Specials.Count > 6) { bdSpecial7.Width = 30; string image7 = FileFolderUrl.ApplicationData + Wave.Specials[6].Image1; try { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image7))); brush.Stretch = Stretch.UniformToFill; bdSpecial7.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(gridSpecial7); } catch { // Download the image Downloader downloader = new Downloader(FileFolderUrl.SplatNet + Wave.Specials[6].Image1, image7, Downloader.SourceType.Job, Depot.Proxy); DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() => { if (Wave != null && Wave.Specials.Count > 6) { if (System.IO.Path.GetFileName(image7) == System.IO.Path.GetFileName(Wave.Specials[6].Image1)) { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image7))); brush.Stretch = Stretch.UniformToFill; bdSpecial7.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(gridSpecial7); } } })); } if (Wave.Specials.Count > 7) { bdSpecial8.Width = 30; string image8 = FileFolderUrl.ApplicationData + Wave.Specials[7].Image1; try { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image8))); brush.Stretch = Stretch.UniformToFill; bdSpecial8.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(gridSpecial8); } catch { // Download the image Downloader downloader = new Downloader(FileFolderUrl.SplatNet + Wave.Specials[7].Image1, image8, Downloader.SourceType.Job, Depot.Proxy); DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() => { if (Wave != null && Wave.Specials.Count > 7) { if (System.IO.Path.GetFileName(image8) == System.IO.Path.GetFileName(Wave.Specials[7].Image1)) { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image8))); brush.Stretch = Stretch.UniformToFill; bdSpecial8.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(gridSpecial8); } } })); } gridSpecial2.Width = 30; gridSpecial3.Width = 30; gridSpecial4.Width = 30; gridSpecial5.Width = 30; gridSpecial6.Width = 30; gridSpecial7.Width = 30; gridSpecial8.Width = 30; gridSpecial2.Margin = new Thickness(-15.9, 0, 0, 0); gridSpecial3.Margin = new Thickness(-15.9, 0, 0, 0); gridSpecial4.Margin = new Thickness(-15.9, 0, 0, 0); gridSpecial5.Margin = new Thickness(-15.9, 0, 0, 0); gridSpecial6.Margin = new Thickness(-15.9, 0, 0, 0); gridSpecial7.Margin = new Thickness(-15.9, 0, 0, 0); gridSpecial8.Margin = new Thickness(-15.9, 0, 0, 0); } else { gridSpecial2.Width = 30; gridSpecial3.Width = 30; gridSpecial4.Width = 30; gridSpecial5.Width = 30; gridSpecial6.Width = 30; gridSpecial7.Width = 30; gridSpecial8.Width = 0; gridSpecial2.Margin = new Thickness(-13.5, 0, 0, 0); gridSpecial3.Margin = new Thickness(-13.5, 0, 0, 0); gridSpecial4.Margin = new Thickness(-13.5, 0, 0, 0); gridSpecial5.Margin = new Thickness(-13.5, 0, 0, 0); gridSpecial6.Margin = new Thickness(-13.5, 0, 0, 0); gridSpecial7.Margin = new Thickness(-13.5, 0, 0, 0); gridSpecial8.Margin = new Thickness(0); } } else { gridSpecial2.Width = 30; gridSpecial3.Width = 30; gridSpecial4.Width = 30; gridSpecial5.Width = 30; gridSpecial6.Width = 30; gridSpecial7.Width = 0; gridSpecial8.Width = 0; gridSpecial2.Margin = new Thickness(-10.2, 0, 0, 0); gridSpecial3.Margin = new Thickness(-10.2, 0, 0, 0); gridSpecial4.Margin = new Thickness(-10.2, 0, 0, 0); gridSpecial5.Margin = new Thickness(-10.2, 0, 0, 0); gridSpecial6.Margin = new Thickness(-10.2, 0, 0, 0); gridSpecial7.Margin = new Thickness(0); gridSpecial8.Margin = new Thickness(0); } } else { gridSpecial2.Width = 30; gridSpecial3.Width = 30; gridSpecial4.Width = 30; gridSpecial5.Width = 30; gridSpecial6.Width = 0; gridSpecial7.Width = 0; gridSpecial8.Width = 0; gridSpecial2.Margin = new Thickness(-5.25, 0, 0, 0); gridSpecial3.Margin = new Thickness(-5.25, 0, 0, 0); gridSpecial4.Margin = new Thickness(-5.25, 0, 0, 0); gridSpecial5.Margin = new Thickness(-5.25, 0, 0, 0); gridSpecial6.Margin = new Thickness(0); gridSpecial7.Margin = new Thickness(0); gridSpecial8.Margin = new Thickness(0); } } else { gridSpecial2.Width = 30; gridSpecial3.Width = 30; gridSpecial4.Width = 30; gridSpecial5.Width = 0; gridSpecial6.Width = 0; gridSpecial7.Width = 0; gridSpecial8.Width = 0; gridSpecial2.Margin = new Thickness(3, 0, 0, 0); gridSpecial3.Margin = new Thickness(3, 0, 0, 0); gridSpecial4.Margin = new Thickness(3, 0, 0, 0); gridSpecial5.Margin = new Thickness(0); gridSpecial6.Margin = new Thickness(0); gridSpecial7.Margin = new Thickness(0); gridSpecial8.Margin = new Thickness(0); } } else { gridSpecial2.Width = 30; gridSpecial3.Width = 30; gridSpecial4.Width = 0; gridSpecial5.Width = 0; gridSpecial6.Width = 0; gridSpecial7.Width = 0; gridSpecial8.Width = 0; gridSpecial2.Margin = new Thickness(5, 0, 0, 0); gridSpecial3.Margin = new Thickness(5, 0, 0, 0); gridSpecial4.Margin = new Thickness(0); gridSpecial5.Margin = new Thickness(0); gridSpecial6.Margin = new Thickness(0); gridSpecial7.Margin = new Thickness(0); gridSpecial8.Margin = new Thickness(0); } } else { gridSpecial2.Width = 30; gridSpecial3.Width = 0; gridSpecial4.Width = 0; gridSpecial5.Width = 0; gridSpecial6.Width = 0; gridSpecial7.Width = 0; gridSpecial8.Width = 0; gridSpecial2.Margin = new Thickness(5, 0, 0, 0); gridSpecial3.Margin = new Thickness(0); gridSpecial4.Margin = new Thickness(0); gridSpecial5.Margin = new Thickness(0); gridSpecial6.Margin = new Thickness(0); gridSpecial7.Margin = new Thickness(0); gridSpecial8.Margin = new Thickness(0); } } else { gridSpecial2.Width = 0; gridSpecial3.Width = 0; gridSpecial4.Width = 0; gridSpecial5.Width = 0; gridSpecial6.Width = 0; gridSpecial7.Width = 0; gridSpecial8.Width = 0; gridSpecial2.Margin = new Thickness(0); gridSpecial3.Margin = new Thickness(0); gridSpecial4.Margin = new Thickness(0); gridSpecial5.Margin = new Thickness(0); gridSpecial6.Margin = new Thickness(0); gridSpecial7.Margin = new Thickness(0); gridSpecial8.Margin = new Thickness(0); } } (sb.Children[0] as DoubleAnimation).To = to; sb.Begin(bdTide); ((Storyboard)FindResource("fade_in")).Begin(bdTide); } }
public void SetBattle(Battle battle) { Battle = battle; // Fade out labels and images ((Storyboard)FindResource("fade_out")).Begin(imgMode); ((Storyboard)FindResource("fade_out")).Begin(lbRule); ((Storyboard)FindResource("fade_out")).Begin(tagResult); ((Storyboard)FindResource("fade_out")).Begin(stg); ((Storyboard)FindResource("fade_out")).Begin(lbPowerName); ((Storyboard)FindResource("fade_out")).Begin(lbPower); ((Storyboard)FindResource("fade_out")).Begin(tagWin); ((Storyboard)FindResource("fade_out")).Begin(lbWinEstimatedPower); ((Storyboard)FindResource("fade_out")).Begin(tagLose); ((Storyboard)FindResource("fade_out")).Begin(lbLoseEstimatedPower); plWin1.SetPlayer(null, true); plWin2.SetPlayer(null, true); plWin3.SetPlayer(null, true); plWin4.SetPlayer(null, true); plLose1.SetPlayer(null, false); plLose2.SetPlayer(null, false); plLose3.SetPlayer(null, false); plLose4.SetPlayer(null, false); if (Battle != null) { if (Battle.Stage != null) { // Update current Battle switch (Battle.Mode) { case Mode.Key.regular_battle: imgMode.Source = (BitmapImage)FindResource("image_battle_regular"); lbPowerName.SetResourceReference(ContentProperty, (Battle as RegularBattle).Freshness.ToString()); lbPower.FontFamily = FindResource("splatfont_2") as FontFamily; switch ((Battle as RegularBattle).Freshness) { case RegularBattle.FreshnessKey.raw: lbPower.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFDBDBDB")); break; case RegularBattle.FreshnessKey.dry: lbPower.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.MeterGreen)); break; case RegularBattle.FreshnessKey.fresh: lbPower.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.MeterBronze)); break; case RegularBattle.FreshnessKey.superfresh: case RegularBattle.FreshnessKey.superfresh2: lbPower.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.MeterSilver)); break; case RegularBattle.FreshnessKey.superfresh3: lbPower.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.MeterGold)); break; default: throw new ArgumentOutOfRangeException(); } lbPower.Margin = new Thickness(0, -20, 0, 0); tbPower.Foreground = new SolidColorBrush(); tbPower.FontSize = 36; tbPower.Text = (Battle as RegularBattle).WinMeter.ToString("0.0"); tbPowerSub.Text = ""; lbWinEstimatedPower.Content = ""; lbLoseEstimatedPower.Content = ""; break; case Mode.Key.ranked_battle: imgMode.Source = (BitmapImage)FindResource("image_battle_ranked"); lbPower.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFDBDBDB")); if (Battle is RankedXBattle) { lbPowerName.SetResourceReference(ContentProperty, "battle_window-x_power"); lbPower.FontFamily = FindResource("splatfont_2") as FontFamily; lbPower.Margin = new Thickness(0, -10, 0, 0); tbPower.FontSize = 28; if ((Battle as RankedXBattle).XPowerAfter >= 0) { tbPower.Text = (Battle as RankedXBattle).XPowerAfter.ToString(); } else { tbPower.SetResourceReference(Run.TextProperty, "battle_window-calculating"); } tbPowerSub.Text = ""; } else { lbPowerName.SetResourceReference(ContentProperty, "battle_window-rank"); lbPower.Margin = new Thickness(0, -20, 0, 0); tbPower.FontSize = 36; lbPower.FontFamily = FindResource("splatfont") as FontFamily; var a = (Battle as RankedBattle).RankAfter.ToString(); tbPower.SetResourceReference(Run.TextProperty, (Battle as RankedBattle).RankAfter.ToString()); if ((Battle as RankedBattle).RankAfter > Rank.Key.s && (Battle as RankedBattle).RankAfter < Rank.Key.x) { tbPowerSub.Text = ((Battle as RankedBattle).RankAfter - Rank.Key.s_plus_0).ToString(); } else { tbPowerSub.Text = ""; } } lbWinEstimatedPower.Content = string.Format(Translate("estimated_{0}", true), (Battle as RankedBattle).EstimatedRankPower); lbLoseEstimatedPower.Content = ""; break; case Mode.Key.league_battle: imgMode.Source = (BitmapImage)FindResource("image_battle_league"); lbPowerName.SetResourceReference(ContentProperty, "battle_window-league_power"); lbPower.FontFamily = FindResource("splatfont_2") as FontFamily; lbPower.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFDBDBDB")); lbPower.Margin = new Thickness(0, -10, 0, 0); tbPower.FontSize = 28; if ((Battle as LeagueBattle).IsCalculating) { tbPower.SetResourceReference(Run.TextProperty, "battle_window-calculating"); tbPowerSub.Text = ""; } else { tbPower.Text = string.Format(Translate("{0:0.0}/{1:0.0}", true), (Battle as LeagueBattle).LeaguePoint, (Battle as LeagueBattle).MaxLeaguePoint); tbPowerSub.Text = ""; } if (Battle.IsWin) { lbWinEstimatedPower.Content = string.Format(Translate("estimated_{0}", true), (Battle as LeagueBattle).MyEstimatedLeaguePower); lbLoseEstimatedPower.Content = string.Format(Translate("estimated_{0}", true), (Battle as LeagueBattle).OtherEstimatedLeaguePower); } else { lbWinEstimatedPower.Content = string.Format(Translate("estimated_{0}", true), (Battle as LeagueBattle).OtherEstimatedLeaguePower); lbLoseEstimatedPower.Content = string.Format(Translate("estimated_{0}", true), (Battle as LeagueBattle).MyEstimatedLeaguePower); } break; case Mode.Key.private_battle: imgMode.Source = (BitmapImage)FindResource("image_battle_private"); lbPowerName.Content = ""; lbPower.FontFamily = FindResource("splatfont_2") as FontFamily; lbPower.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFDBDBDB")); lbPower.Margin = new Thickness(0, -10, 0, 0); tbPower.FontSize = 28; tbPower.Text = ""; tbPowerSub.Text = ""; lbWinEstimatedPower.Content = ""; lbLoseEstimatedPower.Content = ""; break; case Mode.Key.splatfest: imgMode.Source = (BitmapImage)FindResource("image_battle_splatfest"); lbPower.FontFamily = FindResource("splatfont_2") as FontFamily; lbPower.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFDBDBDB")); lbPower.Margin = new Thickness(0, -10, 0, 0); tbPower.FontSize = 28; switch ((Battle as SplatfestBattle).SplatfestMode) { case SplatfestBattle.Key.regular: lbPowerName.Content = ""; tbPower.Text = ""; tbPowerSub.Text = ""; break; case SplatfestBattle.Key.challenge: lbPowerName.SetResourceReference(ContentProperty, "battle_window-splatfest_power"); if ((Battle as SplatfestBattle).IsCalculating) { tbPower.SetResourceReference(Run.TextProperty, "battle_window-calculating"); tbPowerSub.Text = ""; } else { tbPower.Text = string.Format(Translate("{0:0.0}/{1:0.0}", true), (Battle as SplatfestBattle).SplatfestPower, (Battle as SplatfestBattle).MaxSplatfestPower); tbPowerSub.Text = ""; } break; default: throw new ArgumentOutOfRangeException(); } if (Battle.IsWin) { lbWinEstimatedPower.Content = string.Format(Translate("estimated_{0}", true), (Battle as SplatfestBattle).MyEstimatedSplatfestPower); lbLoseEstimatedPower.Content = string.Format(Translate("estimated_{0}", true), (Battle as SplatfestBattle).OtherEstimatedSplatfestPower); } else { lbWinEstimatedPower.Content = string.Format(Translate("estimated_{0}", true), (Battle as SplatfestBattle).OtherEstimatedSplatfestPower); lbLoseEstimatedPower.Content = string.Format(Translate("estimated_{0}", true), (Battle as SplatfestBattle).MyEstimatedSplatfestPower); } break; default: throw new ArgumentOutOfRangeException(); } lbRule.SetResourceReference(ContentProperty, Battle.Rule.ToString()); if (Battle.IsWin) { tagResult.SetResourceReference(TagControl.ContentProperty, "battle_window-win"); tagResult.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonRed)); switch (Battle.Type) { case Mode.Key.regular_battle: case Mode.Key.splatfest: tagWin.Content = Battle.MyScore.ToString("0.0"); tagWin.SetResourceReference(TagControl.Content2Property, "battle_window-%"); tagWin.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonRed)); tagLose.Content = Battle.OtherScore.ToString("0.0"); tagLose.SetResourceReference(TagControl.Content2Property, "battle_window-%"); tagLose.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonGreen)); break; case Mode.Key.ranked_battle: if ((Battle as RankedBattle).IsKo) { tagWin.SetResourceReference(TagControl.ContentProperty, "battle_window-knock_out"); tagWin.Content2 = ""; tagWin.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonRed)); tagLose.Content = string.Format(Translate("{0}_count", true), Battle.OtherScore.ToString()); tagLose.Content2 = ""; tagLose.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonGreen)); } else { tagWin.Content = string.Format(Translate("{0}_count", true), Battle.MyScore.ToString()); tagWin.Content2 = ""; tagWin.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonRed)); tagLose.Content = string.Format(Translate("{0}_count", true), Battle.OtherScore.ToString()); tagLose.Content2 = ""; tagLose.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonGreen)); } break; case Mode.Key.league_battle: if ((Battle as LeagueBattle).IsKo) { tagWin.SetResourceReference(TagControl.ContentProperty, "battle_window-knock_out"); tagWin.Content2 = ""; tagWin.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonRed)); tagLose.Content = string.Format(Translate("{0}_count", true), Battle.OtherScore.ToString()); tagLose.Content2 = ""; tagLose.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonGreen)); } else { tagWin.Content = string.Format(Translate("{0}_count", true), Battle.MyScore.ToString()); tagWin.Content2 = ""; tagWin.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonRed)); tagLose.Content = string.Format(Translate("{0}_count", true), Battle.OtherScore.ToString()); tagLose.Content2 = ""; tagLose.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonGreen)); } break; default: throw new ArgumentOutOfRangeException(); } } else { tagResult.SetResourceReference(TagControl.ContentProperty, "battle_window-lose"); tagResult.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonGreen)); switch (Battle.Type) { case Mode.Key.regular_battle: case Mode.Key.splatfest: tagWin.Content = Battle.OtherScore.ToString("0.0"); tagWin.SetResourceReference(TagControl.Content2Property, "battle_window-%"); tagWin.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonGreen)); tagLose.Content = Battle.MyScore.ToString("0.0"); tagLose.SetResourceReference(TagControl.Content2Property, "battle_window-%"); tagLose.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonRed)); break; case Mode.Key.ranked_battle: if ((Battle as RankedBattle).IsBeKoed) { tagWin.SetResourceReference(TagControl.ContentProperty, "battle_window-knock_out"); tagWin.Content2 = ""; tagWin.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonGreen)); tagLose.Content = string.Format(Translate("{0}_count", true), Battle.MyScore.ToString()); tagLose.Content2 = ""; tagLose.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonRed)); } else { tagWin.Content = string.Format(Translate("{0}_count", true), Battle.OtherScore.ToString()); tagWin.Content2 = ""; tagWin.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonRed)); tagLose.Content = string.Format(Translate("{0}_count", true), Battle.MyScore.ToString()); tagLose.Content2 = ""; tagLose.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonGreen)); } break; case Mode.Key.league_battle: if ((Battle as LeagueBattle).IsBeKoed) { tagWin.SetResourceReference(TagControl.ContentProperty, "battle_window-knock_out"); tagWin.Content2 = ""; tagWin.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonGreen)); tagLose.Content = string.Format(Translate("{0}_count", true), Battle.MyScore.ToString()); tagLose.Content2 = ""; tagLose.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonRed)); } else { tagWin.Content = string.Format(Translate("{0}_count", true), Battle.OtherScore.ToString()); tagWin.Content2 = ""; tagWin.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonRed)); tagLose.Content = string.Format(Translate("{0}_count", true), Battle.MyScore.ToString()); tagLose.Content2 = ""; tagLose.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonGreen)); } break; default: throw new ArgumentOutOfRangeException(); } } ((Storyboard)FindResource("fade_in")).Begin(imgMode); ((Storyboard)FindResource("fade_in")).Begin(lbRule); ((Storyboard)FindResource("fade_in")).Begin(tagResult); ((Storyboard)FindResource("fade_in")).Begin(lbPowerName); ((Storyboard)FindResource("fade_in")).Begin(lbPower); ((Storyboard)FindResource("fade_in")).Begin(tagWin); ((Storyboard)FindResource("fade_in")).Begin(lbWinEstimatedPower); ((Storyboard)FindResource("fade_in")).Begin(tagLose); ((Storyboard)FindResource("fade_in")).Begin(lbLoseEstimatedPower); // Update stage Stage stage = Battle.Stage; string image = FileFolderUrl.ApplicationData + stage.Image; try { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image))); brush.Stretch = Stretch.UniformToFill; stg.Background = brush; stg.SetResourceReference(StageControl.ContentProperty, stage.Id.ToString()); ((Storyboard)FindResource("fade_in")).Begin(stg); } catch { // Download the image Downloader downloader = new Downloader(FileFolderUrl.SplatNet + stage.Image, image, Downloader.SourceType.Battle, Depot.Proxy); DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() => { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image))); brush.Stretch = Stretch.UniformToFill; stg.Background = brush; stg.SetResourceReference(StageControl.ContentProperty, stage.Id.ToString()); ((Storyboard)FindResource("fade_in")).Begin(stg); })); } // Update players if (Battle.IsWin) { if (Battle.MyPlayers.Count > 0) { plWin1.SetPlayer(Battle.MyPlayers[0], true); if (Battle.MyPlayers.Count > 1) { plWin2.SetPlayer(Battle.MyPlayers[1], true); if (Battle.MyPlayers.Count > 2) { plWin3.SetPlayer(Battle.MyPlayers[2], true); if (Battle.MyPlayers.Count > 3) { plWin4.SetPlayer(Battle.MyPlayers[3], true); } } } } if (Battle.OtherPlayers.Count > 0) { plLose1.SetPlayer(Battle.OtherPlayers[0], false); if (Battle.OtherPlayers.Count > 1) { plLose2.SetPlayer(Battle.OtherPlayers[1], false); if (Battle.OtherPlayers.Count > 2) { plLose3.SetPlayer(Battle.OtherPlayers[2], false); if (Battle.OtherPlayers.Count > 3) { plLose4.SetPlayer(Battle.OtherPlayers[3], false); } } } } } else { if (Battle.OtherPlayers.Count > 0) { plWin1.SetPlayer(Battle.OtherPlayers[0], false); if (Battle.OtherPlayers.Count > 1) { plWin2.SetPlayer(Battle.OtherPlayers[1], false); if (Battle.OtherPlayers.Count > 2) { plWin3.SetPlayer(Battle.OtherPlayers[2], false); if (Battle.OtherPlayers.Count > 3) { plWin4.SetPlayer(Battle.OtherPlayers[3], false); } } } } if (Battle.MyPlayers.Count > 0) { plLose1.SetPlayer(Battle.MyPlayers[0], true); if (Battle.MyPlayers.Count > 1) { plLose2.SetPlayer(Battle.MyPlayers[1], true); if (Battle.MyPlayers.Count > 2) { plLose3.SetPlayer(Battle.MyPlayers[2], true); if (Battle.MyPlayers.Count > 3) { plLose4.SetPlayer(Battle.MyPlayers[3], true); } } } } } } // Fade out loading ((Storyboard)FindResource("fade_out")).Begin(bdLoading); bdLoading.IsHitTestVisible = false; } }
public void SetWeapon(Weapon weapon, bool isMy) { // Remove previous Downloader's handlers (Believe every weapon has its sub weapon and special weapon, stop checking) //DownloadHelper.RemoveDownloaders(Downloader.SourceType.Weapon); Weapon = weapon; IsMy = isMy; // Fade out labels and images ((Storyboard)FindResource("fade_out")).Begin(tbName); ((Storyboard)FindResource("fade_out")).Begin(bdWeapon); ((Storyboard)FindResource("fade_out")).Begin(bdSubWeapon); ((Storyboard)FindResource("fade_out")).Begin(bdSubWeapon); if (Weapon != null) { // Update weapon tbName.SetResourceReference(TextBlock.TextProperty, Weapon.Id.ToString()); ((Storyboard)FindResource("fade_in")).Begin(tbName); string image = FileFolderUrl.ApplicationData + Weapon.Image; try { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image))); brush.Stretch = Stretch.Uniform; bdWeapon.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(bdWeapon); } catch { // Download the image Downloader downloader = new Downloader(FileFolderUrl.SplatNet + Weapon.Image, image, Downloader.SourceType.Weapon, Depot.Proxy); DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() => { if (System.IO.Path.GetFileName(image) == System.IO.Path.GetFileName(Weapon.Image)) { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image))); brush.Stretch = Stretch.Uniform; bdWeapon.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(bdWeapon); } })); } if (Weapon.SubWeapon != null) { string image2; if (IsMy) { image2 = FileFolderUrl.ApplicationData + Weapon.SubWeapon.Image1; } else { image2 = FileFolderUrl.ApplicationData + Weapon.SubWeapon.Image2; } try { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image2))); brush.Stretch = Stretch.Uniform; bdSubWeapon.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(bdSubWeapon); ((Storyboard)FindResource("fade_in")).Begin(bdSubWeaponBackground); } catch { // Download the image Downloader downloader; if (isMy) { downloader = new Downloader(FileFolderUrl.SplatNet + Weapon.SubWeapon.Image1, image2, Downloader.SourceType.Weapon, Depot.Proxy); } else { downloader = new Downloader(FileFolderUrl.SplatNet + Weapon.SubWeapon.Image2, image2, Downloader.SourceType.Weapon, Depot.Proxy); } DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() => { if (IsMy) { if (System.IO.Path.GetFileName(image2) == System.IO.Path.GetFileName(Weapon.SubWeapon.Image1)) { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image2))); brush.Stretch = Stretch.Uniform; bdSubWeapon.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(bdSubWeapon); ((Storyboard)FindResource("fade_in")).Begin(bdSubWeaponBackground); } } else { if (System.IO.Path.GetFileName(image2) == System.IO.Path.GetFileName(Weapon.SubWeapon.Image2)) { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image2))); brush.Stretch = Stretch.Uniform; bdSubWeapon.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(bdSubWeapon); ((Storyboard)FindResource("fade_in")).Begin(bdSubWeaponBackground); } } })); } } else { ((Storyboard)FindResource("fade_out")).Begin(bdSubWeaponBackground); } if (Weapon.SpecialWeapon != null) { string image3; if (isMy) { image3 = FileFolderUrl.ApplicationData + Weapon.SpecialWeapon.Image1; } else { image3 = FileFolderUrl.ApplicationData + Weapon.SpecialWeapon.Image2; } try { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image3))); brush.Stretch = Stretch.Uniform; bdSpecialWeapon.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(bdSpecialWeapon); ((Storyboard)FindResource("fade_in")).Begin(bdSpecialWeaponBackground); } catch { // Download the image Downloader downloader; if (IsMy) { downloader = new Downloader(FileFolderUrl.SplatNet + Weapon.SpecialWeapon.Image1, image3, Downloader.SourceType.Weapon, Depot.Proxy); } else { downloader = new Downloader(FileFolderUrl.SplatNet + Weapon.SpecialWeapon.Image2, image3, Downloader.SourceType.Weapon, Depot.Proxy); } DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() => { if (Weapon != null) { if (IsMy) { if (System.IO.Path.GetFileName(image3) == System.IO.Path.GetFileName(Weapon.SpecialWeapon.Image1)) { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image3))); brush.Stretch = Stretch.Uniform; bdSpecialWeapon.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(bdSpecialWeapon); ((Storyboard)FindResource("fade_in")).Begin(bdSpecialWeaponBackground); } } else { if (System.IO.Path.GetFileName(image3) == System.IO.Path.GetFileName(Weapon.SpecialWeapon.Image2)) { ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image3))); brush.Stretch = Stretch.Uniform; bdSpecialWeapon.Background = brush; ((Storyboard)FindResource("fade_in")).Begin(bdSpecialWeapon); ((Storyboard)FindResource("fade_in")).Begin(bdSpecialWeaponBackground); } } } })); } } else { ((Storyboard)FindResource("fade_out")).Begin(bdSpecialWeaponBackground); } } }