예제 #1
0
파일: Form1.cs 프로젝트: artykisa/QuizGame
        private void butsend_Click(object sender, EventArgs e)
        {
            var b4 = new SafeCallDelegateChangeEnable(ChangeEnable);

            butsend.Invoke(b4, butsend, false);
            SocketSend.sendanswer(answertextbox.Text);
        }
예제 #2
0
파일: Form1.cs 프로젝트: artykisa/QuizGame
        private void butvarq1_Click(object sender, EventArgs e)
        {
            var b = new SafeCallDelegateChangeEnable(ChangeEnable);

            butvarq1.Invoke(b, butvarq1, false);
            var b1 = new SafeCallDelegateChangeEnable(ChangeEnable);

            butvarq2.Invoke(b1, butvarq2, false);
            var b2 = new SafeCallDelegateChangeEnable(ChangeEnable);

            butvarq3.Invoke(b2, butvarq3, false);
            var b3 = new SafeCallDelegateChangeEnable(ChangeEnable);

            butvarq4.Invoke(b3, butvarq4, false);
            SocketSend.sendanswer("1");
        }
예제 #3
0
파일: Form1.cs 프로젝트: artykisa/QuizGame
        void Connection()
        {
            SocketSend.sendstart();
            while (true)
            {
                string rec = SocketRecieve.Recieve("wait");
                if (rec[0] == 'W' && rec[1] == '8')
                {
                    var d = new SafeCallDelegateStr(WriteTextSafe);
                    question.Invoke(d, new object[] { "Ожидание игроков:" + rec[2] });
                    continue;
                }
                else if (rec[0] == 'S' && rec[1] == 't' && rec[2] == 'a' && rec[3] == 'r' && rec[4] == 't')
                {
                    break;
                }
            }
            while (true)
            {
                string rec = SocketRecieve.Recieve("question");
                var    b   = new SafeCallDelegateChangeEnable(ChangeEnable);
                butvarq1.Invoke(b, butvarq1, true);
                var b1 = new SafeCallDelegateChangeEnable(ChangeEnable);
                butvarq2.Invoke(b1, butvarq2, true);
                var b2 = new SafeCallDelegateChangeEnable(ChangeEnable);
                butvarq3.Invoke(b2, butvarq3, true);
                var b3 = new SafeCallDelegateChangeEnable(ChangeEnable);
                butvarq4.Invoke(b3, butvarq4, true);
                var b4 = new SafeCallDelegateChangeEnable(ChangeEnable);
                butsend.Invoke(b4, butsend, true);
                if (rec[0] == 'n')
                {
                    Question Question = new Question();
                    for (int i = 1; i < rec.Length; i++)
                    {
                        Question.question += rec[i];
                    }
                    fornum();
                    var d = new SafeCallDelegateStr(WriteTextSafe);
                    question.Invoke(d, new object[] { Question.question });
                }
                else if (rec[0] == 'v')
                {
                    Question Question = new Question();
                    int      temp     = 0;
                    int      tempo    = 0;
                    for (int i = 1; ; i++)
                    {
                        if (rec[i] == '!' || rec[i] == '?' || rec[i] == '.')
                        {
                            temp++;
                        }
                        if (temp == 2)
                        {
                            break;
                        }
                        if (rec[i] == ',' || rec[i] == '.')
                        {
                            tempo++;
                            continue;
                        }
                        else if (temp == 0)
                        {
                            Question.question += rec[i];
                        }
                        else if (temp == 1)
                        {
                            if (tempo == 0)
                            {
                                Question.variant1 += rec[i];
                            }
                            else if (tempo == 1)
                            {
                                Question.variant2 += rec[i];
                            }
                            else if (tempo == 2)
                            {
                                Question.variant3 += rec[i];
                            }
                            else if (tempo == 3)
                            {
                                Question.variant4 += rec[i];
                            }
                        }
                    }

                    forvar();
                    var d = new SafeCallDelegateStr(WriteTextSafe);
                    question.Invoke(d, new object[] { Question.question });
                    var d2 = new SafeCallDelegateStrObj(WriteTextSafe);
                    question.Invoke(d2, Question.variant1, butvarq1);
                    var d3 = new SafeCallDelegateStrObj(WriteTextSafe);
                    question.Invoke(d3, Question.variant2, butvarq2);
                    var d4 = new SafeCallDelegateStrObj(WriteTextSafe);
                    question.Invoke(d4, Question.variant3, butvarq3);
                    var d5 = new SafeCallDelegateStrObj(WriteTextSafe);
                    question.Invoke(d5, Question.variant4, butvarq4);
                }
                else if (rec[0] == 'r')
                {
                    var d = new SafeCallDelegateStr(WriteTextSafe);
                    question.Invoke(d, new object[] { "Result=" + rec });
                    var d2 = new SafeCallDelegate(answertextbox.Hide);
                    answertextbox.Invoke(d2);
                    d2 = new SafeCallDelegate(butsend.Hide);

                    butsend.Invoke(d2);
                    d2 = new SafeCallDelegate(butvarq1.Hide);

                    butvarq1.Invoke(d2);
                    d2 = new SafeCallDelegate(butvarq2.Hide);

                    butvarq2.Invoke(d2);
                    d2 = new SafeCallDelegate(butvarq3.Hide);
                    butvarq3.Invoke(d2);
                    d2 = new SafeCallDelegate(butvarq4.Hide);
                    butvarq4.Invoke(d2);
                    break;
                }
            }
        }