Exemple #1
0
        public MatchesPage()
        {
            this.InitializeComponent();

            this.NavigationCacheMode = NavigationCacheMode.Enabled;

            if (NetworkCheckHelper.CheckNetwork() == false)
            {
                return;
            }

            ID = DotaMatchHelper.GetSteamID();
            //读取用户ID,如果为空就显示绑定页面
            if (ID == "")
            {
                BindAccount();
            }
            else
            {
                try
                {
                    ShowPlayerProfileAsync(ID);
                    ShowPieChart(ID);
                    ShowPlayerTotalDataAsync(ID);
                    ShowRecentMatches(ID);
                    ShowHeroUsingInfo(ID);
                }
                catch
                {
                    ShowDialog("数据加载失败,请稍后重试");
                    this.Frame.Navigate(typeof(BlankPage));
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// 确认绑定
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (Regex.IsMatch(SteamIDTextBox.Text, @"^\d+$"))
     {
         try
         {
             DotaMatchHelper.SetSteamID(SteamIDTextBox.Text);
             this.NavigationCacheMode = NavigationCacheMode.Disabled;
             if (NetworkCheckHelper.CheckNetwork() == false)
             {
                 //断网
                 this.Frame.Navigate(typeof(NoNetworkPage));
             }
             else
             {
                 this.Frame.Navigate(typeof(MatchesPage));
             }
             this.NavigationCacheMode        = NavigationCacheMode.Enabled;
             BackgroundParticleCanvas.Paused = true;
         }
         catch
         {
             FailedTextBlock.Visibility = Visibility.Visible;
             SteamIDTextBox.Text        = "";
         }
     }
 }
Exemple #3
0
        /// <summary>
        /// 显示玩家的全期数据
        /// </summary>
        /// <param name="id"></param>
        public async void ShowPlayerTotalDataAsync(string id)
        {
            try
            {
                string[] total = await DotaMatchHelper.GetTotalAsync(id);

                if (total == null)
                {
                    ShowDialog("非常抱歉,连接至服务器时出现问题,请稍后重试。");
                    this.Frame.Navigate(typeof(BlankPage));
                    return;
                }

                MatchData_KillTextBlock.Text        = total[0];
                MatchData_DeadTextBlock.Text        = total[1];
                MatchData_AssistTextBlock.Text      = total[2];
                MatchData_KDATextBlock.Text         = total[3];
                MatchData_GPMTextBlock.Text         = total[4];
                MatchData_XPMTextBlock.Text         = total[5];
                MatchData_Last_hitTextBlock.Text    = total[6];
                MatchData_DeniesTextBlock.Text      = total[7];
                MatchData_LevelTextBlock.Text       = total[8];
                MatchData_HeroDamageTextBlock.Text  = total[9];
                MatchData_TowerDamageTextBlock.Text = total[10];
                MatchData_HealingTextBlock.Text     = total[11];
                MatchData_APMTextBlock.Text         = total[12];
            }
            catch
            {
                ShowDialog("非常抱歉,连接至服务器时出现问题,请稍后重试。");
                this.Frame.Navigate(typeof(BlankPage));
                return;
            }
        }
        public MainPage()
        {
            this.InitializeComponent();

            //初次启动显示更新日志
            if (SaveContainer.Values["first"] == null || SaveContainer.Values["first"].ToString() == "yes")
            {
                AboutGrid.Visibility = Visibility.Visible;
                SettingGridPopIn.Begin();
                AboutPivot.SelectedIndex      = 1;
                SaveContainer.Values["first"] = "no";
            }

            //自动切换主题
            if (SaveContainer.Values["theme"] == null || SaveContainer.Values["theme"].ToString() == "dark")
            {
                this.RequestedTheme = ElementTheme.Dark;
                ApplicationView.GetForCurrentView().TitleBar.ButtonForegroundColor = Colors.White;
                DarkRadioButton.IsChecked = true;
            }
            else
            {
                this.RequestedTheme = ElementTheme.Light;
                ApplicationView.GetForCurrentView().TitleBar.ButtonForegroundColor = Colors.Black;
                LightRadioButton.IsChecked = true;
            }

            //设置标题栏样式
            var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;

            coreTitleBar.ExtendViewIntoTitleBar = true;
            var titleBar = ApplicationView.GetForCurrentView().TitleBar;

            titleBar.ButtonBackgroundColor = new Color()
            {
                A = 0, R = 39, G = 40, B = 57
            };
            titleBar.ButtonInactiveBackgroundColor = new Color()
            {
                A = 0, R = 39, G = 40, B = 57
            };
            Window.Current.SetTitleBar(RealTitleGrid);

            SetTile(DotaMatchHelper.GetSteamID());

            Current = this;


            if (NetworkCheckHelper.CheckNetwork() == false)
            {
                //断网
                MainFrame.Navigate(typeof(NoNetworkPage));
            }
            else
            {
                MainFrame.Navigate(typeof(HeroesPage), 1);
            }
        }
Exemple #5
0
        /// <summary>
        /// 显示饼状图
        /// </summary>
        /// <param name="isWinRateBiggerThanHalf"></param>
        public async void ShowPieChart(string id)
        {
            wL = await DotaMatchHelper.GetPlayerWLAsync(id);

            SeriesCollection = new SeriesCollection
            {
                new PieSeries
                {
                    Title  = "胜",
                    Values = new ChartValues <ObservableValue> {
                        new ObservableValue(wL.win)
                    },
                    DataLabels = true,
                    FontSize   = 18,
                    Fill       = new SolidColorBrush(Colors.ForestGreen)
                },
                new PieSeries
                {
                    Title  = "负",
                    Values = new ChartValues <ObservableValue> {
                        new ObservableValue(wL.lose)
                    },
                    DataLabels = true,
                    FontSize   = 18,
                    Fill       = new SolidColorBrush(Colors.Firebrick)
                }
            };
            DataContext = this;

            double rate = wL.win / (wL.win + wL.lose);

            CountTextBlock.Text = (wL.win + wL.lose).ToString();
            RateTextBlock.Text  = (100 * rate).ToString("f1");

            //double[] point = GetPieChart(rate);
            //RateArcSegment.Point = new Point(point[0], point[1]);
            //RatePolyLineSegment.Points = new PointCollection { new Point(0, 0), new Point(0, 96), new Point(point[0], point[1]) };
            //RatePolyline.Points = new PointCollection { new Point(0, 0), new Point(0, 96), new Point(point[0], point[1]) };
            //ShowPieChartScale.Begin();

            //if (rate > 0.5/*如果胜率大于0.5*/)
            //{
            //    //那么就是左边显示胜利,填充颜色红色,文字显示胜利
            //    LeftTextBlock.Text = "胜:" + wL.win;
            //    RightTextBlock.Text = "负:" + wL.lose;
            //    LeftPieChart.Fill = new SolidColorBrush(Colors.ForestGreen);
            //    RightPieChart.Fill = new SolidColorBrush(Colors.Firebrick);
            //}
            //else /*胜率小于0.5*/
            //{
            //    //右边显示胜利,填充颜色红色,文字显示胜利
            //    RightTextBlock.Text = "胜:" + wL.win;
            //    LeftTextBlock.Text = "负:" + wL.lose;
            //    RightPieChart.Fill = new SolidColorBrush(Colors.ForestGreen);
            //    LeftPieChart.Fill = new SolidColorBrush(Colors.Firebrick);
            //}
        }
Exemple #6
0
        /// <summary>
        /// 显示绑定新账号窗口
        /// </summary>
        public void BindAccount()
        {
            BackgroundParticleCanvas.Paused = false;
            BindGrid.Visibility             = Visibility.Visible;
            BindingGridPopIn.Begin();
            string id = DotaMatchHelper.GetSteamID();

            if (id == "")
            {
                BackAppBarButton.IsEnabled = false;
            }
        }
Exemple #7
0
        /// <summary>
        /// 显示团战Json数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            if (TeamFightTextBox.Text != "")
            {
                return;
            }
            TeamFightWaitStackPanel.Visibility = Visibility.Visible;
            TeamFightProgressRing.IsActive     = true;
            TeamFightTextBox.Visibility        = Visibility.Visible;
            TeamFightTextBox.Text = await DotaMatchHelper.GetTeamfightInfoAsync(match_id);

            TeamFightProgressRing.IsActive     = false;
            TeamFightWaitStackPanel.Visibility = Visibility.Collapsed;
        }
Exemple #8
0
 /// <summary>
 /// 刷新数据
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void MenuFlyoutItem_Click_1(object sender, RoutedEventArgs e)
 {
     DotaMatchHelper.PostRefreshAsync(ID);
     this.NavigationCacheMode = NavigationCacheMode.Disabled;
     if (NetworkCheckHelper.CheckNetwork() == false)
     {
         //断网
         this.Frame.Navigate(typeof(NoNetworkPage));
     }
     else
     {
         this.Frame.Navigate(typeof(MatchesPage));
     }
     this.NavigationCacheMode = NavigationCacheMode.Enabled;
 }
Exemple #9
0
        /// <summary>
        /// 显示常用英雄信息
        /// </summary>
        public async void ShowHeroUsingInfo(string id)
        {
            heroUsingInfos = await DotaMatchHelper.GetHeroUsingAsync(id);

            if (heroUsingInfos == null)
            {
                FailedTextBlock.Visibility       = Visibility.Visible;
                UsingIndexGridView.SelectedIndex = -1;
                UsingIndexGridView.IsEnabled     = false;
                LeftHyperlinkButton.IsEnabled    = false;
                RightHyperlinkButton.IsEnabled   = false;
                return;
            }
            UsingIndexGridView.SelectedIndex = 0;
        }
Exemple #10
0
        private async void ShowPlayers(string match_id)
        {
            List <PlayersInfo> players = await DotaMatchHelper.GetPlayersInfoAsync(match_id);

            if (players == null)
            {
                ShowDialog("玩家列表数据格式错误无法解析,烦请将比赛编号 " + match_id + " 发送给开发者 [email protected],谢谢!");
                return;
            }

            double radiant_herodamage = 0;
            double radiant_score      = 0;
            double dire_herodamage    = 0;
            double dire_score         = 0;

            for (int i = 0; i < 5; i++)
            {
                radiantPlayersList.Add(new PlayersInfoViewModel(players[i])
                {
                    PlayerName = "匿名玩家", PlayerPhoto = "ms-appx:///Assets/Pictures/null.png"
                });
                radiant_herodamage += Convert.ToDouble(players[i].Hero_damage);
                radiant_score      += Convert.ToDouble(players[i].Kills);
            }
            foreach (PlayersInfoViewModel item in radiantPlayersList)
            {
                item.Fight_rate  = "参战率:" + (100 * (item.Kills + item.Assists) / radiant_score).ToString("0.0") + "%";
                item.Damage_rate = "伤害:" + (100 * Convert.ToDouble(item.Hero_damage) / radiant_herodamage).ToString("0.0") + "%";
            }
            for (int i = 5; i < 10; i++)
            {
                direPlayersList.Add(new PlayersInfoViewModel(players[i])
                {
                    PlayerName = "匿名玩家", PlayerPhoto = "ms-appx:///Assets/Pictures/null.png"
                });
                dire_herodamage += Convert.ToDouble(players[i].Hero_damage);
                dire_score      += Convert.ToDouble(players[i].Kills);
            }
            foreach (PlayersInfoViewModel item in direPlayersList)
            {
                item.Fight_rate  = "参战率:" + (100 * (item.Kills + item.Assists) / dire_score).ToString("0.0") + "%";
                item.Damage_rate = "伤害:" + (100 * Convert.ToDouble(item.Hero_damage) / dire_herodamage).ToString("0.0") + "%";
            }
            ShowPlayersPhoto(radiantPlayersList, direPlayersList);
        }
Exemple #11
0
        /// <summary>
        /// 点击查看指定玩家数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DireListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (DireListView.SelectedIndex >= 0)
            {
                //this.NavigationCacheMode = NavigationCacheMode.Enabled;

                HeroPlayerInfoViewModel heroPlayerInfoViewModel = DotaMatchHelper.GetHeroPlayerInfo(DireListView.SelectedIndex + 5);
                PlayersInfoViewModel    temp = direPlayers[DireListView.SelectedIndex];
                heroPlayerInfoViewModel.Account_id  = "ID: " + temp.Account_id;
                heroPlayerInfoViewModel.Personaname = temp.PlayerName;
                heroPlayerInfoViewModel.KDA         = Regex.Match(temp.KDA, "KDA:([\\d\\D]*)").Groups[1].Value;
                heroPlayerInfoViewModel.Level       = temp.Level + "级";
                heroPlayerInfoViewModel.Last_hits   = Regex.Match(temp.LD, "正/反:([\\d\\D]*?)/").Groups[1].Value;
                heroPlayerInfoViewModel.Denies      = Regex.Match(temp.LD, "正/反:[\\d\\D]*?/([\\d\\D]*)").Groups[1].Value;
                heroPlayerInfoViewModel.KDAString   = "KDA: " + temp.K_D_A.ToString();

                this.Frame.Navigate(typeof(MatchPlayerPage), heroPlayerInfoViewModel);
            }
        }
Exemple #12
0
        private async void ShowMatchInfo(string match_id)
        {
            List <string> list = await DotaMatchHelper.GetMatchInfoAsync(match_id);

            if (list[0] == "time_limit")
            {
                ShowDialog("好像获取不到数据了(超时),请稍等一会儿再查看");
                this.Frame.Navigate(typeof(BlankPage));
                return;
            }
            else if (list[0] == "server_error")
            {
                ShowDialog("抱歉,OpenDota 服务器连接错误,请过一段时间再试");
                this.Frame.Navigate(typeof(BlankPage));
                return;
            }
            else if (list[0] == "data_error")
            {
                ShowDialog("非常抱歉,解析比赛数据时出现故障,烦请发送比赛编号 " + match_id + " 给 [email protected],感谢!");
                this.Frame.Navigate(typeof(BlankPage));
                return;
            }

            try
            {
                MatchData_FBTextBlock.Text = (Convert.ToInt32(list[0]) / 60) + ":" + (Convert.ToInt32(list[1]) % 60);
            }
            catch { }
            try
            {
                MatchData_GameTimeTextBlock.Text = (Convert.ToInt32(list[1]) / 60) + "分钟";
            }
            catch { }
            try
            {
                MatchData_GameModeTextBlock.Text = ConstantsHelper.GameModeID[Convert.ToInt32(list[2])];
                if (MatchData_GameModeTextBlock.Text == "暗月来袭" || MatchData_GameModeTextBlock.Text == "小贪魔节" || MatchData_GameModeTextBlock.Text == "-")
                {
                    MaskGrid.Visibility             = Visibility.Visible;
                    MatchInfoScrollViewer.IsEnabled = false;
                    return;
                }
            }
            catch { }
            try
            {
                DownloadHyperlinkButton.NavigateUri = new Uri(list[3]);
            }
            catch
            {
                DownloadHyperlinkButton.IsEnabled = false;
            }
            RadiantScoreTextBlock.Text = "得分:" + list[4];
            DireScoreTextBlock.Text    = "得分:" + list[5];
            switch (list[6])
            {
            case "9":
                MatchData_GameModeTextBlock.Foreground = new SolidColorBrush(Colors.Brown);    //"勇士联赛"
                break;

            case "5":
            case "6":
            case "7":
                MatchData_GameModeTextBlock.Foreground = new SolidColorBrush(Colors.DarkGoldenrod);    //"天梯"
                break;

            default:
                break;
            }
            try
            {
                DireWinTextBlock.Text    = list[7] == "true" ? "失败" : "胜利";
                RadiantWinTextBlock.Text = list[7] == "true" ? "胜利" : "失败";
            }
            catch { }
            string[] radiant_gold_adv = list[8].Split(',');
            string[] radiant_xp_adv   = list[9].Split(',');
            try
            {
                DrawChart(radiant_gold_adv, radiant_xp_adv);
            }
            catch
            {
                ChartGrid.Visibility             = Visibility.Collapsed;
                NoChartNoteStackPanel.Visibility = Visibility.Visible;
            }
        }
Exemple #13
0
        /// <summary>
        /// 显示最近20场比赛
        /// </summary>
        public async void ShowRecentMatches(string id)
        {
            try
            {
                List <RecentMatch> result = await DotaMatchHelper.GetRecentMatchAsync(id);

                if (result == null)
                {
                    ShowDialog("可能是数据查询太过频繁,请稍后再尝试");
                    return;
                }
                foreach (RecentMatch item in result)
                {
                    //处理评级(skill)的字符串
                    string skill;
                    switch (item.skill)
                    {
                    case "1":
                        skill = "Normal";
                        break;

                    case "2":
                        skill = "High";
                        break;

                    case "3":
                        skill = "Very High";
                        break;

                    default:
                        skill = "";
                        break;
                    }
                    //处理时间
                    string time = ComputeTime(item.start_time);
                    //处理胜负
                    Visibility win  = Visibility.Collapsed;
                    Visibility lose = Visibility.Collapsed;
                    if ((item.radiant_win == "true" && (item.player_slot == "0" || item.player_slot == "1" || item.player_slot == "2" || item.player_slot == "3" || item.player_slot == "4")) ||
                        (item.radiant_win == "false" && (item.player_slot == "128" || item.player_slot == "129" || item.player_slot == "130" || item.player_slot == "131" || item.player_slot == "132")))
                    {
                        win  = Visibility.Visible;
                        lose = Visibility.Collapsed;
                    }
                    else
                    {
                        win  = Visibility.Collapsed;
                        lose = Visibility.Visible;
                    }
                    //将这些数据整理起来添加到列表中
                    recentMatchesObservableCollection.Add(
                        new RecentMatchViewModel()
                    {
                        SelectedHero = ConstantsHelper.dotaHerosDictionary[ConstantsHelper.HeroID[Convert.ToInt32(item.hero_id)]].Name,
                        HeroPhoto    = ConstantsHelper.dotaHerosDictionary[ConstantsHelper.HeroID[Convert.ToInt32(item.hero_id)]].LargePic,
                        Skill        = skill,
                        Time         = time,
                        KDA          = item.kills + "/" + item.deaths + "/" + item.assists,
                        PlayerWin    = win,
                        PlayerLose   = lose,
                        GPM          = item.gold_per_min,
                        XPM          = item.xp_per_min,
                        Match_ID     = item.match_id
                    });
                }
            }
            catch
            {
                ShowDialog("非常抱歉,获取比赛记录时连接至服务器出现问题,请稍后重试。");
                return;
            }
        }
Exemple #14
0
        //private async void RegisterBackgroundTask()
        //{
        //    var backgroundAccessStatus = await BackgroundExecutionManager.RequestAccessAsync();
        //    if (backgroundAccessStatus == BackgroundAccessStatus.AlwaysAllowed || backgroundAccessStatus == BackgroundAccessStatus.AllowedSubjectToSystemPolicy)
        //    {
        //        foreach (var task in BackgroundTaskRegistration.AllTasks)
        //        {
        //            if (task.Value.Name == taskName)
        //            {
        //                task.Value.Unregister(true);
        //            }
        //        }

        //        BackgroundTaskBuilder taskBuilder = new BackgroundTaskBuilder();
        //        taskBuilder.Name = taskName;
        //        taskBuilder.TaskEntryPoint = taskEntryPoint;
        //        taskBuilder.SetTrigger(new TimeTrigger(60, false));
        //        var registration = taskBuilder.Register();
        //    }
        //}

        //private const string taskName = "MatchBackgroundTask";
        //private const string taskEntryPoint = "BackgroundTasks.MatchBackgroundTask";


        /// <summary>
        /// 显示玩家资料
        /// </summary>
        public async void ShowPlayerProfileAsync(string id)
        {
            try
            {
                MatchPlayerProfile = await GetPlayerProfileAsync(id);

                if (MatchPlayerProfile == null)
                {
                    //ShowDialog("抱歉,可能是查询数据太频繁,请稍后尝试");
                    return;
                }
                MatchBackgroundImageBrush.ImageSource = new BitmapImage(new Uri(MatchPlayerProfile.profile.avatarfull));
                PlayerPhotoBitmapImage.UriSource      = new Uri(MatchPlayerProfile.profile.avatarfull);
                PersonNameTextBlock.Text = MatchPlayerProfile.profile.personaname;
                GameIDTextBlock.Text     = "ID: " + MatchPlayerProfile.profile.account_id.ToString();
                SteamCommunityLink       = MatchPlayerProfile.profile.profileurl;

                CurrentNumberTextBlock.Text = await DotaMatchHelper.GetNumberOfCurrentPlayers();

                string rankMedalSource = "ms-appx:///Assets/RankMedal/SeasonalRank0-0.png";
                MatchData_LeaderboardTextBlock.Text = "—";
                //没有分段
                if (MatchPlayerProfile.rank_tier == null)
                {
                }
                //如果是冠绝一世即“80”
                else if (MatchPlayerProfile.rank_tier == "80")
                {
                    //如果有排名
                    if ((MatchPlayerProfile.leaderboard_rank != null && MatchPlayerProfile.leaderboard_rank != "null" && Regex.IsMatch(MatchPlayerProfile.leaderboard_rank, "^[\\d]+$")))
                    {
                        int leaderboard_rank = Convert.ToInt32(MatchPlayerProfile.leaderboard_rank);
                        MatchData_LeaderboardTextBlock.Text = MatchPlayerProfile.leaderboard_rank;
                        if (leaderboard_rank > 1000)
                        {
                            rankMedalSource = "ms-appx:///Assets/RankMedal/SeasonalRankTop0.png";
                        }
                        else if (leaderboard_rank <= 1000 && leaderboard_rank > 100)
                        {
                            rankMedalSource = "ms-appx:///Assets/RankMedal/SeasonalRankTop1.png";
                        }
                        else if (leaderboard_rank <= 100 && leaderboard_rank > 10)
                        {
                            rankMedalSource = "ms-appx:///Assets/RankMedal/SeasonalRankTop2.png";
                        }
                        else if (leaderboard_rank <= 10 && leaderboard_rank > 1)
                        {
                            rankMedalSource = "ms-appx:///Assets/RankMedal/SeasonalRankTop3.png";
                        }
                        else if (leaderboard_rank == 1)
                        {
                            rankMedalSource = "ms-appx:///Assets/RankMedal/SeasonalRankTop4.png";
                        }
                        else
                        {
                            rankMedalSource = String.Format("ms-appx:///Assets/RankMedal/SeasonalRankTop0.png");
                        }
                    }
                    else
                    {
                        rankMedalSource = "ms-appx:///Assets/RankMedal/SeasonalRankTop0.png";
                    }
                }
                else if (MatchPlayerProfile.rank_tier.Length == 2)
                {
                    rankMedalSource = String.Format("ms-appx:///Assets/RankMedal/SeasonalRank{0}-{1}.png", MatchPlayerProfile.rank_tier[0], MatchPlayerProfile.rank_tier[1]);
                    MatchData_LeaderboardTextBlock.Text = "—";
                }
                else
                {
                    rankMedalSource = "ms-appx:///Assets/RankMedal/SeasonalRank0-0.png";
                }
                MatchData_RankMedalImage.Source = new BitmapImage(new Uri(rankMedalSource));
                MatchData_MMRTextBlock.Text     = MatchPlayerProfile.mmr_estimate.estimate.ToString();
            }
            catch
            {
                //ShowDialog("无法获取当前绑定账号的信息,请重新绑定");
                //this.Frame.Navigate(typeof(BlankPage));
                return;
            }

            //更新磁贴
            SetTile(MatchPlayerProfile);
        }