示例#1
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.ChampionIcon = ((LegendaryClient.Controls.SmallChampionItem)(target));
                return;

            case 2:
                this.PlayerNameLabel = ((System.Windows.Controls.Label)(target));
                return;

            case 3:
                this.File = ((System.Windows.Controls.Label)(target));
                return;

            case 4:
                this.gameItem1 = ((LegendaryClient.Controls.SmallChampionItem)(target));
                return;

            case 5:
                this.gameItem2 = ((LegendaryClient.Controls.SmallChampionItem)(target));
                return;

            case 6:
                this.gameItem3 = ((LegendaryClient.Controls.SmallChampionItem)(target));
                return;

            case 7:
                this.gameItem4 = ((LegendaryClient.Controls.SmallChampionItem)(target));
                return;

            case 8:
                this.gameItem5 = ((LegendaryClient.Controls.SmallChampionItem)(target));
                return;

            case 9:
                this.gameTrinket = ((LegendaryClient.Controls.SmallChampionItem)(target));
                return;

            case 10:
                this.KDA = ((System.Windows.Controls.Label)(target));
                return;
            }
            this._contentLoaded = true;
        }
        void UpdateReplays()
        {
            GamePanel.Children.Clear();

            var dir = new DirectoryInfo("cabinet");
            var directories = dir.EnumerateDirectories()
                                .OrderBy(d => d.CreationTime);

            string[] Replays = Directory.GetDirectories("cabinet");

            foreach (DirectoryInfo di in directories)
            {
                string d = di.Name;
                if (!File.Exists(Path.Combine("cabinet", d, "token")) ||
                    !File.Exists(Path.Combine("cabinet", d, "key")) ||
                    !File.Exists(Path.Combine("cabinet", d, "endOfGameStats")))
                    continue;

                byte[] Base64Stats = Convert.FromBase64String(File.ReadAllText(Path.Combine("cabinet", d, "endOfGameStats")));
                AmfReader statsReader = new AmfReader(new MemoryStream(Base64Stats), context);

                EndOfGameStats stats = (EndOfGameStats)statsReader.ReadAmf3Item();

                ReplayItem item = new ReplayItem();

                //Use unoccupied variable
                stats.Difficulty = d;

                item.Tag = stats;
                item.GameId.Content = d;
                item.GameType.Content = stats.GameMode.ToLower();
                item.GameDate.Content = di.CreationTime.ToShortTimeString() + " " + di.CreationTime.ToShortDateString();
                double seconds = stats.GameLength % 60;
                double minutes = stats.GameLength / 60;
                item.GameTime.Content = string.Format("{0:0}:{1:00}", minutes, seconds);
                item.Margin = new Thickness(0, 5, 0, 0);

                foreach (PlayerParticipantStatsSummary summary in stats.TeamPlayerParticipantStats)
                {
                    SmallChampionItem image = new SmallChampionItem();
                    image.Width = 38;
                    image.Height = 38;

                    Uri UriSource = new Uri("/LegendaryClient;component/Assets/champion/" + summary.SkinName + ".png", UriKind.RelativeOrAbsolute);
                    image.ChampionImage.Source = new BitmapImage(UriSource);

                    item.TeamOnePanel.Children.Add(image);
                }

                foreach (PlayerParticipantStatsSummary summary in stats.OtherTeamPlayerParticipantStats)
                {
                    SmallChampionItem image = new SmallChampionItem();
                    image.Width = 38;
                    image.Height = 38;

                    Uri UriSource = new Uri("/LegendaryClient;component/Assets/champion/" + summary.SkinName + ".png", UriKind.RelativeOrAbsolute);
                    image.ChampionImage.Source = new BitmapImage(UriSource);

                    item.TeamTwoPanel.Children.Add(image);
                }

                item.MouseDown += item_MouseDown;

                //Insert on top
                GamePanel.Children.Insert(0, item);
            }
        }