private void SendAnswer(string answer) { JsonRequestPacketSerializer.SubmitAnswerRequest submitAnswerReq = new JsonRequestPacketSerializer.SubmitAnswerRequest(answer); try { JsonResponsePacketDeserializer.SubmitAnswerResponse submitAnswerResp = this.client.SendAndReceive <JsonResponsePacketDeserializer.SubmitAnswerResponse>(submitAnswerReq, (uint)JsonRequestPacketSerializer.reqCodes.SUBMITANSWER_REQ_CODE); if (submitAnswerResp.status == 1) { if (submitAnswerResp.hasFinished) { this.isForcedClosing = false; dt.Stop(); ResultsWindow rw = new ResultsWindow(this.client); this.Close(); rw.Show(); } JsonResponsePacketDeserializer.GetQuestionResponse questionResp = getQuestion(); this.answers = questionResp.answers; updateScreen(questionResp.question); } else { } } catch (Exception exception) { } }
public GameWindow(Client client, int time) { InitializeComponent(); this.client = new Client(client); this.isForcedClosing = true; JsonResponsePacketDeserializer.GetQuestionResponse questionResp = getQuestion(); this.answers = questionResp.answers; updateScreen(questionResp.question); this.KeyDown += new KeyEventHandler(KeyPressed); this.time = time; this.Time.Text = this.time.ToString(); this.dt = new DispatcherTimer(); this.dt.Tick += CountTime; this.dt.Interval = new TimeSpan(0, 0, 1); this.dt.Start(); }