Пример #1
0
 public void SetWeapon(Weapon weapon)
 {
     Weapon = weapon;
     ((Storyboard)FindResource("fade_out")).Begin(bdWeapon);
     if (Weapon != null)
     {
         string image = FileFolderUrl.ApplicationData + Weapon.Image;
         try
         {
             ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image)));
             brush.Stretch       = Stretch.UniformToFill;
             bdWeapon.Background = brush;
             ((Storyboard)FindResource("fade_in")).Begin(bdWeapon);
         }
         catch
         {
             // Download the image
             Downloader downloader = new Downloader(FileFolderUrl.SplatNet + Weapon.Image, image, Downloader.SourceType.Battle, Depot.Proxy);
             DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() =>
             {
                 if (Weapon != null)
                 {
                     if (System.IO.Path.GetFileName(image) == System.IO.Path.GetFileName(Weapon.Image))
                     {
                         ImageBrush brush    = new ImageBrush(new BitmapImage(new Uri(image)));
                         brush.Stretch       = Stretch.UniformToFill;
                         bdWeapon.Background = brush;
                         ((Storyboard)FindResource("fade_in")).Begin(bdWeapon);
                     }
                 }
             }));
         }
     }
 }
Пример #2
0
 public void SetPlayer(JobPlayer player, Job job)
 {
     Player = player;
     Job    = job;
     // Fade out labels and images
     ((Storyboard)FindResource("fade_out")).Begin(tbName);
     ((Storyboard)FindResource("fade_out")).Begin(bdIcon);
     salGoldie.SetSalmoniod(Salmoniod.Key.goldie);
     salSteelhead.SetSalmoniod(Salmoniod.Key.steelhead);
     salFlyfish.SetSalmoniod(Salmoniod.Key.flyfish);
     salScrapper.SetSalmoniod(Salmoniod.Key.scrapper);
     salSteelEel.SetSalmoniod(Salmoniod.Key.steel_eel);
     salStinger.SetSalmoniod(Salmoniod.Key.stinger);
     salMaws.SetSalmoniod(Salmoniod.Key.maws);
     salGriller.SetSalmoniod(Salmoniod.Key.griller2);
     salDrizzler.SetSalmoniod(Salmoniod.Key.drizzler);
     if (Player != null && Job != null)
     {
         // Update player
         tbName.Text = Player.Nickname;
         ((Storyboard)FindResource("fade_in")).Begin(tbName);
         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.Player, Depot.Proxy);
             DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() =>
             {
                 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);
                 }
             }));
         }
         // Update salmoniods
         salGoldie.SetSalmoniod(Salmoniod.Key.goldie, Player, Job);
         salSteelhead.SetSalmoniod(Salmoniod.Key.steelhead, Player, Job);
         salFlyfish.SetSalmoniod(Salmoniod.Key.flyfish, Player, Job);
         salScrapper.SetSalmoniod(Salmoniod.Key.scrapper, Player, Job);
         salSteelEel.SetSalmoniod(Salmoniod.Key.steel_eel, Player, Job);
         salStinger.SetSalmoniod(Salmoniod.Key.stinger, Player, Job);
         salMaws.SetSalmoniod(Salmoniod.Key.maws, Player, Job);
         salGriller.SetSalmoniod(Salmoniod.Key.griller2, Player, Job);
         salDrizzler.SetSalmoniod(Salmoniod.Key.drizzler, Player, Job);
     }
 }
Пример #3
0
 public void SetPlayer(Player player)
 {
     Player = player;
     // Fade out labels and images
     ((Storyboard)FindResource("fade_out")).Begin(tbName);
     ((Storyboard)FindResource("fade_out")).Begin(bdIcon);
     gearHead.SetGear(null);
     gearClothes.SetGear(null);
     gearShoes.SetGear(null);
     if (Player != null)
     {
         // Update player
         tbName.Text = Player.Nickname;
         ((Storyboard)FindResource("fade_in")).Begin(tbName);
         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.Player, Depot.Proxy);
             DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() =>
             {
                 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);
                 }
             }));
         }
         gearHead.SetGear(Player.HeadGear);
         gearClothes.SetGear(Player.ClothesGear);
         gearShoes.SetGear(Player.ShoesGear);
     }
 }
Пример #4
0
        public void SetPlayer(JobPlayer player)
        {
            Player = player;
            ((Storyboard)FindResource("fade_out")).Begin(gridMain);
            ((Storyboard)FindResource("fade_out")).Begin(bdIcon);
            ((Storyboard)FindResource("fade_out")).Begin(bdSpecialWeapon);
            wp1.SetWeapon(null);
            wp2.SetWeapon(null);
            wp3.SetWeapon(null);
            ((Storyboard)FindResource("bg_to_black")).Begin(bdMain);
            if (Player != null)
            {
                // Background change
                if (Player.IsSelf)
                {
                    ((Storyboard)FindResource("bg_to_white")).Begin(bdMain);
                }
                // 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.Job, 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);
                            }
                        }
                    }));
                }
                // Nickname
                tbNickname.Text = Player.Nickname;
                // Weapons
                wp1.SetWeapon(Player.Weapons[0]);
                if (Player.Weapons.Count > 1)
                {
                    wp2.SetWeapon(Player.Weapons[1]);
                    if (Player.Weapons.Count > 2)
                    {
                        wp3.SetWeapon(Player.Weapons[2]);
                    }
                }
                // Special
                string image2 = FileFolderUrl.ApplicationData + Player.Weapons[0].SpecialWeapon.Image1;
                try
                {
                    ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image2)));
                    brush.Stretch = Stretch.UniformToFill;
                    bdSpecialWeapon.Background = brush;
                    ((Storyboard)FindResource("fade_in")).Begin(bdSpecialWeapon);
                }
                catch
                {
                    // Download the image
                    Downloader downloader = new Downloader(FileFolderUrl.SplatNet + Player.Weapons[0].SpecialWeapon.Image1, 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.Weapons[0].SpecialWeapon.Image1))
                            {
                                ImageBrush brush           = new ImageBrush(new BitmapImage(new Uri(image2)));
                                brush.Stretch              = Stretch.UniformToFill;
                                bdSpecialWeapon.Background = brush;
                                ((Storyboard)FindResource("fade_in")).Begin(bdSpecialWeapon);
                            }
                        }
                    }));
                }
                // Golden egg, power egg, save, dead
                lbGoldenEgg.Content = string.Format(Translate("x{0}", true), Player.GoldenEgg);
                lbPowerEgg.Content  = string.Format(Translate("x{0}", true), Player.PowerEgg);
                lbHelp.Content      = string.Format(Translate("x{0}", true), Player.Help);
                lbDead.Content      = string.Format(Translate("x{0}", true), Player.Dead);
                switch (player.Species)
                {
                case JobPlayer.SpeciesType.inklings:
                    ((Storyboard)FindResource("fade_in")).Begin(imgInklingsSave);
                    ((Storyboard)FindResource("fade_in")).Begin(imgInklingsDead);
                    ((Storyboard)FindResource("fade_out")).Begin(imgOctolingsSave);
                    ((Storyboard)FindResource("fade_out")).Begin(imgOctolingsDead);
                    break;

                case JobPlayer.SpeciesType.octolings:
                    ((Storyboard)FindResource("fade_in")).Begin(imgOctolingsSave);
                    ((Storyboard)FindResource("fade_in")).Begin(imgOctolingsDead);
                    ((Storyboard)FindResource("fade_out")).Begin(imgInklingsSave);
                    ((Storyboard)FindResource("fade_out")).Begin(imgInklingsDead);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                // Show all
                ((Storyboard)FindResource("fade_in")).Begin(gridMain);
            }
        }
Пример #5
0
        private void JobNotifying()
        {
            if (Depot.Notification)
            {
                Job job = Depot.Job;
                // Send job notification
                DateTime endTime  = job.StartTime.AddSeconds(60 * 7);
                double   diffTime = (DateTime.Now - endTime).TotalSeconds;
                if (diffTime <= 300)
                {
                    // Format title
                    string title;
                    if (job.IsClear)
                    {
                        title = string.Format(Translate("{0}_(No._{1})", true), Translate("clear", true), Translate(job.Number.ToString()));
                    }
                    else
                    {
                        title = string.Format(Translate("{0}_(No._{1})", true), Translate("defeat", true), Translate(job.Number.ToString()));
                    }
                    // Format content
                    string content = Translate(job.Stage.Id.ToString());
                    // Format scoreTitle
                    string scoreTitle;
                    if (job.HazardLevel == 200)
                    {
                        scoreTitle = string.Format("{0} {1}{2}", Translate("hazard_level", true), Translate("max", true), Translate("%", true));
                    }
                    else
                    {
                        scoreTitle = string.Format("{0} {1}{2}", Translate("hazard_level", true), job.HazardLevel.ToString(), Translate("%", true));
                    }
                    // Format status and value string
                    string goldenEgg = job.GoldenEgg.ToString();
                    string quota     = job.Quota.ToString();
                    // Format ratio
                    double ratio = 0;
                    if (job.IsClear)
                    {
                        ratio = 1;
                    }
                    else
                    {
                        switch (job.FailureWave)
                        {
                        case 1:
                            ratio = job.Waves[0].GoldenEgg * 1.0 / job.Waves[0].Quota;
                            break;

                        case 2:
                            ratio = 1.0 / 3 + job.Waves[1].GoldenEgg * 1.0 / job.Waves[1].Quota;
                            break;

                        case 3:
                            ratio = 2.0 / 3 + job.Waves[2].GoldenEgg * 1.0 / job.Waves[2].Quota;
                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                        }
                    }
                    // Get player icon
                    JobPlayer player = job.MyPlayer;
                    string    image  = FileFolderUrl.ApplicationData + FileFolderUrl.IconFolder + @"\" + System.IO.Path.GetFileName(player.Image) + ".jpg";
                    try
                    {
                        // Show notification
                        NotificationHelper.SendJobNotification(title, content, scoreTitle, goldenEgg, quota, ratio, image);
                    }
                    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")
                                {
                                    // Show notification
                                    NotificationHelper.SendJobNotification(title, content, scoreTitle, goldenEgg, quota, ratio, image);
                                }
                            }
                        }));
                    }
                }
            }
        }
Пример #6
0
        private void BattleNotifying()
        {
            if (Depot.Notification)
            {
                Battle battle = Depot.Battle;
                // Send battle notification
                DateTime endTime  = battle.StartTime.AddSeconds(battle.ElapsedTime);
                double   diffTime = (DateTime.Now - endTime).TotalSeconds;
                if (diffTime <= 300)
                {
                    // Format title
                    string title;
                    if (battle.IsWin)
                    {
                        title = string.Format(Translate("{0}_(No._{1})", true), Translate("win", true), Translate(battle.Number.ToString()));
                    }
                    else
                    {
                        title = string.Format(Translate("{0}_(No._{1})", true), Translate("lose", true), Translate(battle.Number.ToString()));
                    }
                    // Format content
                    string content = string.Format(Translate("{0}_-_{1}", true), Translate(battle.Stage.Id.ToString()), battle.StartTime.ToString("yyyy/M/dd HH:mm"));
                    // Format progressTitle
                    string scoreTitle = string.Format(Translate("{0}_-_{1}", true), Translate(battle.Mode.ToString()), Translate(battle.Rule.ToString()));
                    // Format status and value string
                    string myScore, otherScore;
                    switch (battle.Type)
                    {
                    case Mode.Key.regular_battle:
                    case Mode.Key.splatfest:
                        myScore    = string.Format("{0}{1}", battle.MyScore, Translate("%", true));
                        otherScore = string.Format("{0}{1}", battle.OtherScore, Translate("%", true));
                        break;

                    case Mode.Key.ranked_battle:
                        if ((battle as RankedBattle).IsKo)
                        {
                            myScore    = Translate("knock_out", true);
                            otherScore = string.Format(Translate("{0}_count", true), battle.OtherScore);
                        }
                        else if ((battle as RankedBattle).IsBeKoed)
                        {
                            myScore    = string.Format(Translate("{0}_count", true), battle.MyScore);
                            otherScore = Translate("knock_out", true);
                        }
                        else
                        {
                            myScore    = string.Format(Translate("{0}_count", true), battle.MyScore);
                            otherScore = string.Format(Translate("{0}_count", true), battle.OtherScore);
                        }
                        break;

                    case Mode.Key.league_battle:
                        if ((battle as LeagueBattle).IsKo)
                        {
                            myScore    = Translate("knock_out", true);
                            otherScore = string.Format(Translate("{0}_count", true), battle.OtherScore);
                        }
                        else if ((battle as LeagueBattle).IsBeKoed)
                        {
                            myScore    = string.Format(Translate("{0}_count", true), battle.MyScore);
                            otherScore = Translate("knock_out", true);
                        }
                        else
                        {
                            myScore    = string.Format(Translate("{0}_count", true), battle.MyScore);
                            otherScore = string.Format(Translate("{0}_count", true), battle.OtherScore);
                        }
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                    // Get player icon
                    Player player = battle.SelfPlayer;
                    string image  = FileFolderUrl.ApplicationData + FileFolderUrl.IconFolder + @"\" + System.IO.Path.GetFileName(player.Image) + ".jpg";
                    try
                    {
                        // Show notification
                        NotificationHelper.SendBattleNotification(title, content, scoreTitle, myScore, otherScore, battle.ScoreRatio, image);
                    }
                    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")
                                {
                                    // Show notification
                                    NotificationHelper.SendBattleNotification(title, content, scoreTitle, myScore, otherScore, battle.ScoreRatio, image);
                                }
                            }
                        }));
                    }
                }
            }
        }
Пример #7
0
        private void ShiftUpdated()
        {
            if (Depot.CurrentMode == Depot.Mode.salmon_run)
            {
                ((Storyboard)FindResource("fade_in")).Begin(spJob);
                lbGrade.IsHitTestVisible = true;
                bdShiftStageBackground.IsHitTestVisible = true;
            }
            Shift shift = Depot.Shift;

            if (shift.Stages.Count > 0)
            {
                // Change UI
                if (Depot.CurrentMode == Depot.Mode.salmon_run)
                {
                    lbMode.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonOrange));
                    lbMode.Content    = Translate("job", true);
                    // Fade in label
                    ((Storyboard)FindResource("fade_in")).Begin(lbMode);
                }
                if (Depot.SalmonRunGrade >= 0)
                {
                    lbGrade.Content = Translate(Depot.SalmonRunGrade.ToString());
                }
                else
                {
                    lbGrade.Content = Translate("--", true);
                }
                // Fade in label
                ((Storyboard)FindResource("fade_in")).Begin(lbGrade);
                // Update stages
                Stage  stage = shift.Stages[0];
                string image = FileFolderUrl.ApplicationData + stage.Image;
                try
                {
                    ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image)));
                    brush.Stretch           = Stretch.UniformToFill;
                    bdShiftStage.Background = brush;
                    ((Storyboard)FindResource("fade_in")).Begin(bdShiftStage);
                }
                catch
                {
                    // Download the image
                    Downloader downloader = new Downloader(FileFolderUrl.SplatNet + stage.Image, image, Downloader.SourceType.Shift, Depot.Proxy);
                    DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() =>
                    {
                        ImageBrush brush        = new ImageBrush(new BitmapImage(new Uri(image)));
                        brush.Stretch           = Stretch.UniformToFill;
                        bdShiftStage.Background = brush;
                        ((Storyboard)FindResource("fade_in")).Begin(bdShiftStage);
                    }));
                }
            }
            // Change interval to mitigate server load
            if (shift.Error == Base.ErrorType.no_error)
            {
                if (shift.Stages.Count > 0)
                {
                    bool isStart = (DateTime.UtcNow - shift.Stages[0].StartTime).TotalSeconds > 0;
                    if (isStart)
                    {
                        if ((DateTime.UtcNow - shift.Stages[0].StartTime).TotalMinutes > 5)
                        {
                            tmShift.Interval = new TimeSpan(0, 5, 0);
                        }
                        else if ((DateTime.UtcNow - shift.Stages[0].StartTime).TotalMinutes > 1)
                        {
                            tmShift.Interval = new TimeSpan(0, 1, 0);
                        }
                        else
                        {
                            tmShift.Interval = new TimeSpan(0, 0, 15);
                        }
                    }
                    else
                    {
                        if ((shift.Stages[0].EndTime - DateTime.UtcNow).TotalMinutes > 5)
                        {
                            tmShift.Interval = new TimeSpan(0, 5, 0);
                        }
                        else if ((shift.Stages[0].EndTime - DateTime.UtcNow).TotalMinutes > 1)
                        {
                            tmShift.Interval = new TimeSpan(0, 1, 0);
                        }
                        else
                        {
                            tmShift.Interval = new TimeSpan(0, 0, 15);
                        }
                    }
                }
                else
                {
                    tmShift.Interval = new TimeSpan(0, 0, 15);
                }
            }
            else
            {
                tmShift.Interval = new TimeSpan(0, 0, 15);
            }
            // Set shift
            shiftWindow.SetShift(Depot.Shift);
        }
Пример #8
0
        private void ScheduleUpdated()
        {
            if (Depot.CurrentMode != Depot.Mode.salmon_run)
            {
                ((Storyboard)FindResource("fade_in")).Begin(spBattle);
                lbLevel.IsHitTestVisible  = true;
                bdStage1.IsHitTestVisible = true;
                bdStage2.IsHitTestVisible = true;
            }
            Schedule schedule = Depot.Schedule;

            Mode.Key mode = Mode.Key.regular_battle;
            switch (Depot.CurrentMode)
            {
            case Depot.Mode.regular_battle:
            case Depot.Mode.salmon_run:
                mode = Mode.Key.regular_battle;
                break;

            case Depot.Mode.ranked_battle:
                mode = Mode.Key.ranked_battle;
                break;

            case Depot.Mode.league_battle:
                mode = Mode.Key.league_battle;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            List <ScheduledStage> scheduledStages = schedule.GetStages(mode);

            if (scheduledStages.Count > 0)
            {
                // Change UI
                if (Depot.CurrentMode != Depot.Mode.salmon_run)
                {
                    switch (mode)
                    {
                    case Mode.Key.regular_battle:
                        lbMode.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonGreen));
                        // tbStar.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonGreen));
                        break;

                    case Mode.Key.ranked_battle:
                        lbMode.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonOrange));
                        // tbStar.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonOrange));
                        break;

                    case Mode.Key.league_battle:
                        lbMode.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonRed));
                        // tbStar.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonRed));
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                    lbMode.Content = Translate(((Rule.ShortName)scheduledStages[0].Rule).ToString());
                    // Fade in label
                    ((Storyboard)FindResource("fade_in")).Begin(lbMode);
                }
                switch (scheduledStages[0].Rule)
                {
                case Rule.Key.turf_war:
                    if (Depot.Level > 0)
                    {
                        if (Depot.Level > 100)
                        {
                            tbLevel.Text = (Depot.Level - Depot.Level / 100 * 100).ToString();
                            tbStar.Text  = Translate("★", true);
                        }
                        else
                        {
                            tbLevel.Text = Depot.Level.ToString();
                            tbStar.Text  = "";
                        }
                    }
                    else
                    {
                        tbLevel.Text = Translate("--", true);
                        tbStar.Text  = "";
                    }
                    break;

                case Rule.Key.splat_zones:
                    if (Depot.SplatZonesRank > Rank.Key.s && Depot.SplatZonesRank < Rank.Key.x)
                    {
                        tbLevel.Text = Translate(Depot.SplatZonesRank.ToString());
                        tbStar.Text  = (Depot.SplatZonesRank - Rank.Key.s_plus_0).ToString();
                    }
                    else
                    {
                        tbLevel.Text = Translate(Depot.SplatZonesRank.ToString());
                        tbStar.Text  = "";
                    }
                    break;

                case Rule.Key.tower_control:
                    if (Depot.TowerControlRank > Rank.Key.s && Depot.TowerControlRank < Rank.Key.x)
                    {
                        tbLevel.Text = Translate(Depot.TowerControlRank.ToString());
                        tbStar.Text  = (Depot.TowerControlRank - Rank.Key.s_plus_0).ToString();
                    }
                    else
                    {
                        tbLevel.Text = Translate(Depot.TowerControlRank.ToString());
                        tbStar.Text  = "";
                    }
                    break;

                case Rule.Key.rainmaker:
                    if (Depot.RainmakerRank > Rank.Key.s && Depot.RainmakerRank < Rank.Key.x)
                    {
                        tbLevel.Text = Translate(Depot.RainmakerRank.ToString());
                        tbStar.Text  = (Depot.RainmakerRank - Rank.Key.s_plus_0).ToString();
                    }
                    else
                    {
                        tbLevel.Text = Translate(Depot.RainmakerRank.ToString());
                        tbStar.Text  = "";
                    }
                    break;

                case Rule.Key.clam_blitz:
                    if (Depot.ClamBlitzRank > Rank.Key.s && Depot.ClamBlitzRank < Rank.Key.x)
                    {
                        tbLevel.Text = Translate(Depot.ClamBlitzRank.ToString());
                        tbStar.Text  = (Depot.ClamBlitzRank - Rank.Key.s_plus_0).ToString();
                    }
                    else
                    {
                        tbLevel.Text = Translate(Depot.ClamBlitzRank.ToString());
                        tbStar.Text  = "";
                    }
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                // Fade in label
                ((Storyboard)FindResource("fade_in")).Begin(lbLevel);
                // Update stages
                Stage  stage = scheduledStages[0];
                string image = FileFolderUrl.ApplicationData + stage.Image;
                try
                {
                    ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image)));
                    brush.Stretch       = Stretch.UniformToFill;
                    bdStage1.Background = brush;
                    ((Storyboard)FindResource("fade_in")).Begin(bdStage1);
                }
                catch
                {
                    // Download the image
                    Downloader downloader = new Downloader(FileFolderUrl.SplatNet + stage.Image, image, Downloader.SourceType.Schedule, Depot.Proxy);
                    DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() =>
                    {
                        ImageBrush brush    = new ImageBrush(new BitmapImage(new Uri(image)));
                        brush.Stretch       = Stretch.UniformToFill;
                        bdStage1.Background = brush;
                        ((Storyboard)FindResource("fade_in")).Begin(bdStage1);
                    }));
                }
                if (scheduledStages.Count > 1)
                {
                    Stage  stage2 = scheduledStages[1];
                    string image2 = FileFolderUrl.ApplicationData + stage2.Image;
                    try
                    {
                        ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image2)));
                        brush.Stretch       = Stretch.UniformToFill;
                        bdStage2.Background = brush;
                        ((Storyboard)FindResource("fade_in")).Begin(bdStage2);
                    }
                    catch
                    {
                        Downloader downloader = new Downloader(FileFolderUrl.SplatNet + stage2.Image, image2, Downloader.SourceType.Schedule, Depot.Proxy);
                        DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() =>
                        {
                            ImageBrush brush    = new ImageBrush(new BitmapImage(new Uri(image2)));
                            brush.Stretch       = Stretch.UniformToFill;
                            bdStage2.Background = brush;
                            ((Storyboard)FindResource("fade_in")).Begin(bdStage2);
                        }));
                    }
                }
            }
            // Change interval to mitigate server load
            if (schedule.Error == Base.ErrorType.no_error)
            {
                if ((schedule.EndTime - DateTime.UtcNow).TotalMinutes > 5)
                {
                    tmSchedule.Interval = new TimeSpan(0, 5, 0);
                }
                else if ((schedule.EndTime - DateTime.UtcNow).TotalMinutes > 1)
                {
                    tmSchedule.Interval = new TimeSpan(0, 1, 0);
                }
                else
                {
                    tmSchedule.Interval = new TimeSpan(0, 0, 15);
                }
            }
            else
            {
                tmSchedule.Interval = new TimeSpan(0, 0, 15);
            }
            // Set schedule
            scheduleWindow.SetSchedule(Depot.Schedule, mode);
        }
Пример #9
0
        public void SetSchedule(Schedule schedule, Mode.Key mode)
        {
            Schedule = schedule;
            Mode     = mode;
            // Fade in loading
            bdLoading.IsHitTestVisible = true;
            ((Storyboard)FindResource("fade_in")).Begin(bdLoading);
            // Fade out labels and images
            ((Storyboard)FindResource("fade_out")).Begin(imgMode);
            ((Storyboard)FindResource("fade_out")).Begin(lbMode);
            ((Storyboard)FindResource("fade_out")).Begin(lbRule);
            ((Storyboard)FindResource("fade_out")).Begin(lbTime);
            ((Storyboard)FindResource("fade_out")).Begin(stg1);
            ((Storyboard)FindResource("fade_out")).Begin(stg2);
            ((Storyboard)FindResource("fade_out")).Begin(tagNext);
            ((Storyboard)FindResource("fade_out")).Begin(lbNextRule);
            ((Storyboard)FindResource("fade_out")).Begin(lbNextTime);
            ((Storyboard)FindResource("fade_out")).Begin(stgNext1);
            ((Storyboard)FindResource("fade_out")).Begin(stgNext2);
            if (Schedule != null)
            {
                // Update current Schedule
                List <ScheduledStage> scheduledStages = Schedule.GetStages(Mode);
                if (scheduledStages.Count > 0)
                {
                    // Change UI
                    switch (Mode)
                    {
                    case Class.Mode.Key.regular_battle:
                        imgMode.Source     = (BitmapImage)FindResource("image_battle_regular");
                        tagNext.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonGreen));
                        break;

                    case Class.Mode.Key.ranked_battle:
                        imgMode.Source     = (BitmapImage)FindResource("image_battle_ranked");
                        tagNext.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonOrange));
                        break;

                    case Class.Mode.Key.league_battle:
                        imgMode.Source     = (BitmapImage)FindResource("image_battle_league");
                        tagNext.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF" + Design.NeonRed));
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                    lbMode.SetResourceReference(ContentProperty, scheduledStages[0].Mode.ToString());
                    lbRule.SetResourceReference(ContentProperty, scheduledStages[0].Rule.ToString());
                    DateTime startTime = Schedule.EndTime.AddHours(-2).ToLocalTime();
                    DateTime endTime   = Schedule.EndTime.ToLocalTime();
                    lbTime.Content = string.Format(Translate("{0}_-_{1}", true), startTime.ToString("HH:mm"), endTime.ToString("HH:mm"));
                    // Fade in labels
                    ((Storyboard)FindResource("fade_in")).Begin(imgMode);
                    ((Storyboard)FindResource("fade_in")).Begin(lbMode);
                    ((Storyboard)FindResource("fade_in")).Begin(lbRule);
                    ((Storyboard)FindResource("fade_in")).Begin(lbTime);
                    ((Storyboard)FindResource("fade_in")).Begin(tagNext);
                    // Update stages
                    Stage  stage = scheduledStages[0];
                    string image = FileFolderUrl.ApplicationData + stage.Image;
                    try
                    {
                        ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image)));
                        brush.Stretch   = Stretch.UniformToFill;
                        stg1.Background = brush;
                        stg1.SetResourceReference(StageControl.ContentProperty, stage.Id.ToString());
                        ((Storyboard)FindResource("fade_in")).Begin(stg1);
                    }
                    catch
                    {
                        // Download the image
                        Downloader downloader = new Downloader(FileFolderUrl.SplatNet + stage.Image, image, Downloader.SourceType.Schedule, Depot.Proxy);
                        DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() =>
                        {
                            ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image)));
                            brush.Stretch    = Stretch.UniformToFill;
                            stg1.Background  = brush;
                            stg1.SetResourceReference(StageControl.ContentProperty, stage.Id.ToString());
                            ((Storyboard)FindResource("fade_in")).Begin(stg1);
                        }));
                    }
                    if (scheduledStages.Count > 1)
                    {
                        Stage  stage2 = scheduledStages[1];
                        string image2 = FileFolderUrl.ApplicationData + stage2.Image;
                        try
                        {
                            ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image2)));
                            brush.Stretch   = Stretch.UniformToFill;
                            stg2.Background = brush;
                            stg2.SetResourceReference(StageControl.ContentProperty, stage2.Id.ToString());
                            ((Storyboard)FindResource("fade_in")).Begin(stg2);
                        }
                        catch
                        {
                            Downloader downloader = new Downloader(FileFolderUrl.SplatNet + stage2.Image, image2, Downloader.SourceType.Schedule, Depot.Proxy);
                            DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() =>
                            {
                                ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image2)));
                                brush.Stretch    = Stretch.UniformToFill;
                                stg2.Background  = brush;
                                stg2.SetResourceReference(StageControl.ContentProperty, stage2.Id.ToString());
                                ((Storyboard)FindResource("fade_in")).Begin(stg2);
                            }));
                        }
                    }
                }
                // Update next schedule
                List <ScheduledStage> nextScheduledStages = Schedule.GetNextStages(Mode);
                if (nextScheduledStages.Count > 0)
                {
                    // Change UI
                    lbNextRule.SetResourceReference(ContentProperty, nextScheduledStages[0].Rule.ToString());
                    TimeSpan dTime = Schedule.EndTime - DateTime.UtcNow;
                    if (dTime.Hours > 0)
                    {
                        lbNextTime.Content = string.Format(Translate("in_{0}_hour_{1}_min", true), dTime.Hours, dTime.Minutes);
                    }
                    else
                    {
                        lbNextTime.Content = string.Format(Translate("in_{0}_min", true), dTime.Minutes);
                    }
                    // Fade in labels
                    ((Storyboard)FindResource("fade_in")).Begin(lbNextRule);
                    ((Storyboard)FindResource("fade_in")).Begin(lbNextTime);
                    // Update Stages
                    Stage  stage = nextScheduledStages[0];
                    string image = FileFolderUrl.ApplicationData + stage.Image;
                    try
                    {
                        ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image)));
                        brush.Stretch       = Stretch.UniformToFill;
                        stgNext1.Background = brush;
                        stgNext1.SetResourceReference(StageControl.ContentProperty, stage.Id.ToString());
                        ((Storyboard)FindResource("fade_in")).Begin(stgNext1);
                    }
                    catch
                    {
                        // Download the image
                        Downloader downloader = new Downloader(FileFolderUrl.SplatNet + stage.Image, image, Downloader.SourceType.Schedule, Depot.Proxy);
                        DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() =>
                        {
                            ImageBrush brush    = new ImageBrush(new BitmapImage(new Uri(image)));
                            brush.Stretch       = Stretch.UniformToFill;
                            stgNext1.Background = brush;
                            stgNext1.SetResourceReference(StageControl.ContentProperty, stage.Id.ToString());
                            ((Storyboard)FindResource("fade_in")).Begin(stgNext1);
                        }));
                    }
                    if (nextScheduledStages.Count > 1)
                    {
                        Stage  stage2 = nextScheduledStages[1];
                        string image2 = FileFolderUrl.ApplicationData + stage2.Image;
                        try
                        {
                            ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image2)));
                            brush.Stretch       = Stretch.UniformToFill;
                            stgNext2.Background = brush;
                            stgNext2.SetResourceReference(StageControl.ContentProperty, stage2.Id.ToString());
                            ((Storyboard)FindResource("fade_in")).Begin(stgNext2);
                        }
                        catch
                        {
                            Downloader downloader = new Downloader(FileFolderUrl.SplatNet + stage2.Image, image2, Downloader.SourceType.Schedule, Depot.Proxy);
                            DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() =>
                            {
                                ImageBrush brush    = new ImageBrush(new BitmapImage(new Uri(image2)));
                                brush.Stretch       = Stretch.UniformToFill;
                                stgNext2.Background = brush;
                                stgNext2.SetResourceReference(StageControl.ContentProperty, stage2.Id.ToString());
                                ((Storyboard)FindResource("fade_in")).Begin(stgNext2);
                            }));
                        }
                    }
                }
                // Fade out loading
                ((Storyboard)FindResource("fade_out")).Begin(bdLoading);
                bdLoading.IsHitTestVisible = false;
            }
        }
Пример #10
0
        public void SetGear(Gear gear)
        {
            // Remove previous Downloader's handlers (Believe every gear has its brand, stop checking)
            //DownloadHelper.RemoveDownloaders(Downloader.SourceType.Gear);
            Gear = gear;
            // Fade out labels and images
            ((Storyboard)FindResource("fade_out")).Begin(tbName);
            ((Storyboard)FindResource("fade_out")).Begin(bdGear);
            ((Storyboard)FindResource("fade_out")).Begin(bdBrand);
            if (Gear != null)
            {
                // Update weapon
                switch (Gear.Kind)
                {
                case Gear.KindType.Head:
                    tbName.SetResourceReference(TextBlock.TextProperty, ((HeadGear.Key)Gear.Id).ToString());
                    break;

                case Gear.KindType.Clothes:
                    tbName.SetResourceReference(TextBlock.TextProperty, ((ClothesGear.Key)Gear.Id).ToString());
                    break;

                case Gear.KindType.Shoes:
                    tbName.SetResourceReference(TextBlock.TextProperty, ((ShoesGear.Key)Gear.Id).ToString());
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                ((Storyboard)FindResource("fade_in")).Begin(tbName);
                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);
                        }
                    }));
                }
                string image2 = FileFolderUrl.ApplicationData + Gear.Brand.Image;
                try
                {
                    ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image2)));
                    brush.Stretch      = Stretch.Uniform;
                    bdBrand.Background = brush;
                    ((Storyboard)FindResource("fade_in")).Begin(bdBrand);
                }
                catch
                {
                    // Download the image
                    Downloader downloader = new Downloader(FileFolderUrl.SplatNet + Gear.Brand.Image, image2, Downloader.SourceType.Gear, Depot.Proxy);
                    DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() =>
                    {
                        if (System.IO.Path.GetFileName(image2) == System.IO.Path.GetFileName(Gear.Brand.Image))
                        {
                            ImageBrush brush   = new ImageBrush(new BitmapImage(new Uri(image2)));
                            brush.Stretch      = Stretch.Uniform;
                            bdBrand.Background = brush;
                            ((Storyboard)FindResource("fade_in")).Begin(bdBrand);
                        }
                    }));
                }
            }
        }
Пример #11
0
 public void SetShift(Shift shift)
 {
     Shift = shift;
     // Fade in loading
     bdLoading.IsHitTestVisible = true;
     ((Storyboard)FindResource("fade_in")).Begin(bdLoading);
     // Fade out labels and images
     ((Storyboard)FindResource("fade_out")).Begin(imgMode);
     ((Storyboard)FindResource("fade_out")).Begin(lbMode);
     ((Storyboard)FindResource("fade_out")).Begin(tagOpenOrSoon);
     ((Storyboard)FindResource("fade_out")).Begin(lbTime1);
     ((Storyboard)FindResource("fade_out")).Begin(stg1);
     ((Storyboard)FindResource("fade_out")).Begin(lbWeapon1);
     ((Storyboard)FindResource("fade_out")).Begin(tagNext);
     ((Storyboard)FindResource("fade_out")).Begin(lbTime2);
     ((Storyboard)FindResource("fade_out")).Begin(stg2);
     ((Storyboard)FindResource("fade_out")).Begin(lbWeapon2);
     wp11.SetWeapon(null);
     wp12.SetWeapon(null);
     wp13.SetWeapon(null);
     wp14.SetWeapon(null);
     wp21.SetWeapon(null);
     wp22.SetWeapon(null);
     wp23.SetWeapon(null);
     wp24.SetWeapon(null);
     if (Shift != null)
     {
         // Update shift
         if (Shift.Stages.Count > 0)
         {
             if (Shift.IsOpen)
             {
                 tagOpenOrSoon.SetResourceReference(TagControl.ContentProperty, "shift_window-open");
             }
             else
             {
                 tagOpenOrSoon.SetResourceReference(TagControl.ContentProperty, "shift_window-soon");
             }
             // Fade in labels
             ((Storyboard)FindResource("fade_in")).Begin(imgMode);
             ((Storyboard)FindResource("fade_in")).Begin(lbMode);
             ((Storyboard)FindResource("fade_in")).Begin(tagOpenOrSoon);
             ((Storyboard)FindResource("fade_in")).Begin(tagNext);
             ShiftStage stage     = Shift.Stages[0];
             DateTime   startTime = stage.StartTime.ToLocalTime();
             DateTime   endTime   = stage.EndTime.ToLocalTime();
             lbTime1.Content = string.Format(Translate("{0}_-_{1}", true), startTime.ToString("M/dd HH:mm"), endTime.ToString("M/dd HH:mm"));
             ((Storyboard)FindResource("fade_in")).Begin(lbTime1);
             ((Storyboard)FindResource("fade_in")).Begin(lbWeapon1);
             // Update stage
             string image = FileFolderUrl.ApplicationData + stage.Image;
             try
             {
                 ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image)));
                 brush.Stretch   = Stretch.UniformToFill;
                 stg1.Background = brush;
                 stg1.SetResourceReference(StageControl.ContentProperty, stage.Id.ToString());
                 ((Storyboard)FindResource("fade_in")).Begin(stg1);
             }
             catch
             {
                 // Download the image
                 Downloader downloader = new Downloader(FileFolderUrl.SplatNet + stage.Image, image, Downloader.SourceType.Shift, Depot.Proxy);
                 DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() =>
                 {
                     ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image)));
                     brush.Stretch    = Stretch.UniformToFill;
                     stg1.Background  = brush;
                     stg1.SetResourceReference(StageControl.ContentProperty, stage.Id.ToString());
                     ((Storyboard)FindResource("fade_in")).Begin(stg1);
                 }));
             }
             if (stage.Weapons.Count > 0)
             {
                 // Update weapons
                 wp11.SetWeapon(stage.Weapons[0]);
                 if (stage.Weapons.Count > 1)
                 {
                     wp12.SetWeapon(stage.Weapons[1]);
                     if (stage.Weapons.Count > 2)
                     {
                         wp13.SetWeapon(stage.Weapons[2]);
                         if (stage.Weapons.Count > 3)
                         {
                             wp14.SetWeapon(stage.Weapons[3]);
                         }
                     }
                 }
             }
             if (Shift.Stages.Count > 1)
             {
                 // Update next shift
                 ShiftStage stage2 = Shift.Stages[1];
                 startTime       = stage2.StartTime.ToLocalTime();
                 endTime         = stage2.EndTime.ToLocalTime();
                 lbTime2.Content = string.Format(Translate("{0}_-_{1}", true), startTime.ToString("M/dd HH:mm"), endTime.ToString("M/dd HH:mm"));
                 ((Storyboard)FindResource("fade_in")).Begin(lbTime2);
                 ((Storyboard)FindResource("fade_in")).Begin(lbWeapon2);
                 // Update next stage
                 string image6 = FileFolderUrl.ApplicationData + stage2.Image;
                 try
                 {
                     ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image6)));
                     brush.Stretch   = Stretch.UniformToFill;
                     stg2.Background = brush;
                     stg2.SetResourceReference(StageControl.ContentProperty, stage2.Id.ToString());
                     ((Storyboard)FindResource("fade_in")).Begin(stg2);
                 }
                 catch
                 {
                     // Download the image
                     Downloader downloader = new Downloader(FileFolderUrl.SplatNet + stage2.Image, image6, Downloader.SourceType.Shift, Depot.Proxy);
                     DownloadHelper.AddDownloader(downloader, new DownloadCompletedEventHandler(() =>
                     {
                         ImageBrush brush = new ImageBrush(new BitmapImage(new Uri(image6)));
                         brush.Stretch    = Stretch.UniformToFill;
                         stg2.Background  = brush;
                         stg2.SetResourceReference(StageControl.ContentProperty, stage2.Id.ToString());
                         ((Storyboard)FindResource("fade_in")).Begin(stg2);
                     }));
                 }
                 if (stage2.Weapons.Count > 0)
                 {
                     // Update weapons
                     wp21.SetWeapon(stage2.Weapons[0]);
                     if (stage2.Weapons.Count > 1)
                     {
                         wp22.SetWeapon(stage2.Weapons[1]);
                         if (stage2.Weapons.Count > 2)
                         {
                             wp23.SetWeapon(stage2.Weapons[2]);
                             if (stage2.Weapons.Count > 3)
                             {
                                 wp24.SetWeapon(stage2.Weapons[3]);
                             }
                         }
                     }
                 }
             }
         }
         // Fade out loading
         ((Storyboard)FindResource("fade_out")).Begin(bdLoading);
         bdLoading.IsHitTestVisible = false;
     }
 }
Пример #12
0
 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);
         }
     }
 }
Пример #13
0
        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);
            }
        }
Пример #14
0
        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;
            }
        }
Пример #15
0
        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);
            }
        }
Пример #16
0
 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);
         }
     }
 }