コード例 #1
0
        private void SetInfo(SmashGGInfoModel info)
        {
            if (info.set == null)
            {
                errorsTextBlock.Text = "Could not find set with that id";
                return;
            }

            errorsTextBlock.Text = "";


            //bracket name
            string bracketName = info.set.fullRoundText;

            //player 1 name
            string p1Name = info.set.slots[0].entrant.name;

            //player 2 name
            string p2Name = info.set.slots[1].entrant.name;

            //player 1 score
            //float p1Score = info.set.slots[0].standing.stats.score.value;

            //player 2 score
            //float p2Score = info.set.slots[1].standing.stats.score.value;

            p1TextBox.Text      = p1Name;
            p2TextBox.Text      = p2Name;
            this.p1Score.Text   = "0";
            this.p2Score.Text   = "0";
            bracketTextBox.Text = bracketName;
        }
コード例 #2
0
        async Task GetAPIInfo(string id)
        {
            if (id == "")
            {
                return;
            }

            string sId = id;

            //check if id starts with h, indicating its a link (starting with http). if so, only get the id part
            if (sId[0] == 'h')
            {
                string[] split = id.Split('/');
                sId = split[split.Length - 1];
            }

            //check the new id is actually a number
            if (!int.TryParse(sId, out _))
            {
                errorsTextBlock.Text = "Invalid link or set id";
                return;
            }

            try
            {
                SmashGGInfoModel info = await ApiHelper.GetSetInfo(sId);

                //SetInfo(info);
            }
            catch (Exception e)
            {
                errorsTextBlock.Text = e.Message;
            }
            finally
            {
                SmashGGInfoModel info = await ApiHelper.GetSetInfo(sId);

                SetInfo(info);
            }
        }