Ejemplo n.º 1
0
        private void OnReceiver(Object _object, TcpReceiverEventArgs _tcpReceiverEventArgs)
        {
            String Client  = TcpServer.GetHostName(_tcpReceiverEventArgs.Socket);
            String Message = Encoding.UTF8.GetString(_tcpReceiverEventArgs.Buffer, 0, _tcpReceiverEventArgs.Length);

            QuestionResult _result = new QuestionResult(XElement.Parse(Message));

            _statistics.Add(_result);
            //_statistics.SetChart(ref chart1);
        }
Ejemplo n.º 2
0
        private void OnReceiver(Object _object, TcpReceiverEventArgs _tcpEventArgs)
        {
            String Client  = TcpServer.GetHostName(_tcpEventArgs.Socket);
            String Message = Encoding.UTF8.GetString(_tcpEventArgs.Buffer, 0, _tcpEventArgs.Length);

            if (Message != "")
            {
                if (Message.IsConnect())
                {
                    if (_clients.IndexOf(Client) == -1)
                    {
                        _clients.Add(Client);
                    }
                }

                if (_clients.Count > 0)
                {
                    List <String> _temp = new List <String>();
                    foreach (String _client in _clients)
                    {
                        try
                        {
                            Byte[] Request = Encoding.UTF8.GetBytes(TcpRequest.Connect);
                            Program.Server.Send(_client, Program.Config.Port, Request);
                        }
                        catch { _temp.Add(_client); }
                    }

                    foreach (String _client in _temp)
                    {
                        _clients.Remove(_client);
                    }
                }

                BeginInvoke(
                    new MethodInvoker(delegate { label1.Text = _clients.Count.ToString(); }));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Получает данные сервера.
        /// </summary>
        /// <param name="_object"></param>
        /// <param name="_tcpEventArgs"></param>
        private void OnReceiver(Object _object, TcpReceiverEventArgs _tcpEventArgs)
        {
            String Client  = TcpServer.GetHostName(_tcpEventArgs.Socket);
            String Message = Encoding.UTF8.GetString(_tcpEventArgs.Buffer, 0, _tcpEventArgs.Length);

            BeginInvoke(new MethodInvoker(delegate
            {
                switch (Message)
                {
                case "_request:connect":
                    MainMenu.Items["mmTitle"].Text = "Опросник";
                    break;

                case "_request:start":
                    MainMenu.Items["mmTitle"].Text = "Опросник";
                    mmMinimum.Enabled = false;
                    mmClose.Enabled   = false;
                    _translation      = true;
                    break;

                case "_request:stop":
                    materialTabControl1.SelectTab(pStartPage);
                    mmMinimum.Enabled = true;
                    mmClose.Enabled   = true;
                    _translation      = false;
                    break;

                case "_request:disconnect":
                    MainMenu.Items["mmTitle"].Text = "Опросник (нет подключения)";
                    materialTabControl1.SelectTab(pStartPage);
                    mmMinimum.Enabled = true;
                    mmClose.Enabled   = true;
                    _translation      = false;
                    break;

                default:
                    try
                    {
                        _question   = new Question(XElement.Parse(Message));
                        label3.Text = _question.Name;

                        switch (_question.Type)
                        {
                        case "Выбор одного правильного ответа":
                            materialTabControl2.SelectTab(pSingleAnswerSelection);
                            panel2.Height = 200;

                            listAnswers.Items.Clear();
                            foreach (String Answer in _question.Answers)
                            {
                                listAnswers.Items.Add(Answer);
                            }
                            break;

                        case "Свободный ответ":
                            materialTabControl2.SelectTab(pFreeAnswer);
                            panel2.Height = 100;

                            textBox1.Text = "";
                            textBox1.Focus();
                            break;
                        }

                        if (_question.Image != null)
                        {
                            pictureBox1.Image   = _question.Image;
                            pictureBox1.Visible = true;
                            pictureBox2.Visible = true;
                        }
                        else
                        {
                            pictureBox1.Visible = false;
                            pictureBox2.Visible = false;
                        }

                        //listAnswers.Enabled = true;
                        //textBox1.Enabled = true;
                        materialTabControl2.Enabled = true;
                        m_Send.Enabled = true;
                        materialTabControl1.SelectTab(pQuestion);
                    }
                    catch { }
                    break;
                }
            }));
        }