示例#1
0
 void ReleaseDesignerOutlets()
 {
     if (CheckAnswerButton != null)
     {
         CheckAnswerButton.Dispose();
         CheckAnswerButton = null;
     }
     if (ClearButton != null)
     {
         ClearButton.Dispose();
         ClearButton = null;
     }
     if (ResultTextView != null)
     {
         ResultTextView.Dispose();
         ResultTextView = null;
     }
     if (SampleButton != null)
     {
         SampleButton.Dispose();
         SampleButton = null;
     }
     if (TextMathiraiCount != null)
     {
         TextMathiraiCount.Dispose();
         TextMathiraiCount = null;
     }
     if (TextWord != null)
     {
         TextWord.Dispose();
         TextWord = null;
     }
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            SampleButton.TouchUpInside += async(object sender, EventArgs e) =>
            {
                var result =
                    await
                    MenYappuRestServiceWrapper.GetSampleSeerAsync(string.Format(MenYappuServiceUrls.BaseUrlFormat,
                                                                                MenYappuServiceUrls.Seergal));

                var seergal     = JsonConvert.DeserializeObject <List <Item> >(result);
                var randomIndex = new Random().Next(0, seergal.Count);
                TextWord.Text = seergal[randomIndex].Seer;
                TextMathiraiCount.BecomeFirstResponder();
            };

            ClearButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                TextWord.Text = "";
            };

            CheckAnswerButton.TouchUpInside += async(object sender, EventArgs e) =>
            {
                var jsonData = new JObject();
                jsonData.Add("inputText", TextWord.Text);

                var result =
                    await
                    MenYappuRestServiceWrapper.CalculateMathiraiAsync(
                        string.Format(MenYappuServiceUrls.BaseUrlFormat, MenYappuServiceUrls.MathiraiCount),
                        JsonConvert.SerializeObject(jsonData));

                var resultJsonObject = JObject.Parse(result);

                // Check if the entered Mathirai Count is the same as the one returned by MenYappu REST service
                if (TextMathiraiCount.Text == (string)resultJsonObject["totalMathiraiCount"])
                {
                    ResultTextView.Text = "சரியான விடை";
                }
                else
                {
                    var correctAnswer = string.Format("சரியான மாத்திரை எண்ணிக்கை: {0}",
                                                      (string)resultJsonObject["totalMathiraiCount"]);
                    ResultTextView.Text = "தவறான விடை\r\n" + correctAnswer;
                }
            };
        }