Пример #1
0
        private void ProcessPromptResponseMessage(CommonInformation.Message message)
        {
            ProcessFormFilling FormPromptResponse = delegate
            {
                if (message.is5050Prompt)
                {
                    RemoveOneIncorrectAnswer(message.twoWrongAnswersFor5050Prompt[0]);
                    RemoveOneIncorrectAnswer(message.twoWrongAnswersFor5050Prompt[1]);
                }
                else
                {
                    buttonAnswerA.Text = "A   " + message.probabilityOfAnswersCorrectness[0].ToString() + Percent;
                    buttonAnswerB.Text = "B   " + message.probabilityOfAnswersCorrectness[1].ToString() + Percent;
                    buttonAnswerC.Text = "C   " + message.probabilityOfAnswersCorrectness[2].ToString() + Percent;
                    buttonAnswerD.Text = "D   " + message.probabilityOfAnswersCorrectness[3].ToString() + Percent;

                    ChangeButtonColorAccordingToProbabilityOfVarian(buttonAnswerA, message.probabilityOfAnswersCorrectness[0]);
                    ChangeButtonColorAccordingToProbabilityOfVarian(buttonAnswerB, message.probabilityOfAnswersCorrectness[1]);
                    ChangeButtonColorAccordingToProbabilityOfVarian(buttonAnswerC, message.probabilityOfAnswersCorrectness[2]);
                    ChangeButtonColorAccordingToProbabilityOfVarian(buttonAnswerD, message.probabilityOfAnswersCorrectness[3]);
                }
            };

            if (InvokeRequired)
            {
                Invoke(FormPromptResponse);
            }
            else
            {
                FormPromptResponse();
            }
        }
Пример #2
0
        private void ProcessClientsListMessage(CommonInformation.Message message)
        {
            ProcessFormFilling FormFillingNewClient = delegate
            {
                clientsInfo.Clear();
                clientsInfo.Add(new ClientsInfo()
                {
                    clientID = ChatDialog, clientName = ChatName
                });
                foreach (ClientsInfo nameClient in message.clientsInfo)
                {
                    clientsInfo.Add(nameClient);
                    if (!chatDialogsInfo.ContainsKey(nameClient.clientID))
                    {
                        chatDialogsInfo.Add(nameClient.clientID, new AllDialogsMessages(nameClient.clientName));
                    }
                }
            };

            if (InvokeRequired)
            {
                Invoke(FormFillingNewClient);
            }
            else
            {
                FormFillingNewClient();
            }
        }
Пример #3
0
        private void ProcessYourAnswerStatusMessage(CommonInformation.Message message)
        {
            ProcessFormFilling FormAnswerStatus = delegate
            {
                if (message.isCorrectAnswer)
                {
                    labelAnswerStatus.Text = "Верно!";
                    int points = int.Parse(labelYourPointsNumber.Text);
                    points++;
                    labelYourPointsNumber.Text = points.ToString();
                }
                else
                {
                    labelAnswerStatus.Text = "Неверно!";
                }
            };

            if (InvokeRequired)
            {
                Invoke(FormAnswerStatus);
            }
            else
            {
                FormAnswerStatus();
            }
        }
Пример #4
0
        private void ProcessGetStatisticsMessage(CommonInformation.Message message)
        {
            ProcessFormFilling FormGetStatisticsResult = delegate
            {
                if (message.messageReceiverID != 0)
                {
                    richTextBoxStatistics.Visible = true;
                    richTextBoxStatistics.Clear();
                    if (message.isfailedToGetStatistics)
                    {
                        richTextBoxStatistics.Text = "Данный участник чата ещё ни разу не играл!";
                    }
                    else
                    {
                        richTextBoxStatistics.Text = message.playerInfo.playerName + "(" + message.playerInfo.playerStatus
                                                     + ")" + "\r\n";
                        richTextBoxStatistics.Text += "Игры                     " + message.playerInfo.numberOfPlayedGames + "\r\n";
                        richTextBoxStatistics.Text += "Победы/ничьи/поражения   " + message.playerInfo.winsNumber
                                                      + "/" + message.playerInfo.drawsNumber + "/" + message.playerInfo.losesNumber + "\r\n";
                        richTextBoxStatistics.Text += "Верные/неверные ответы   " + message.playerInfo.rightAnswersNumber
                                                      + "/" + message.playerInfo.wrongAnswersNumber + "\r\n";
                        richTextBoxStatistics.Text += "Количество очков         " + message.playerInfo.pointsNumber + "\r\n";
                    }
                }
                else
                {
                    dataGridViewStatistics.Rows.Clear();
                    dataGridViewStatistics.Visible = true;
                    foreach (PlayerInfo playerInfo in message.playerInfoList)
                    {
                        dataGridViewStatistics.Rows.Add(playerInfo.playerName, playerInfo.numberOfPlayedGames,
                                                        playerInfo.winsNumber, playerInfo.drawsNumber, playerInfo.losesNumber, playerInfo.rightAnswersNumber,
                                                        playerInfo.wrongAnswersNumber, playerInfo.pointsNumber);
                    }
                }
            };

            if (InvokeRequired)
            {
                Invoke(FormGetStatisticsResult);
            }
            else
            {
                FormGetStatisticsResult();
            }
        }
Пример #5
0
        private void ProcessGameStatusMessage(CommonInformation.Message message)
        {
            ProcessFormFilling FormGameStatus = delegate
            {
                ClearGameField();
                richTextBoxGameStatus.Text = message.gameStatus;
            };

            if (InvokeRequired)
            {
                Invoke(FormGameStatus);
            }
            else
            {
                FormGameStatus();
            }
        }
Пример #6
0
        public void UpdateView()
        {
            ProcessFormFilling FormUpdate = delegate
            {
                richTextBoxChatContent.Clear();
                if (chatDialogsInfo != null)
                {
                    string[] messages = new string[chatDialogsInfo[currentDialog].messages.Count];
                    chatDialogsInfo[currentDialog].messages.CopyTo(messages);
                    foreach (string messageContent in messages)
                    {
                        richTextBoxChatContent.Text += messageContent + "\r\n";
                    }
                }
                comboBoxParticipants.Items.Clear();
                foreach (ClientsInfo clientInfo in clientsInfo)
                {
                    comboBoxParticipants.Items.Add(clientInfo.clientName);
                }

                labelCurrentClientDialog.Text = chatDialogsInfo[currentDialog].dialogName;

                if (currentDialog != ChatDialog)
                {
                    buttonPlay.Visible         = true;
                    labelSelectTopic.Visible   = true;
                    comboBoxGameTopics.Visible = true;
                }
                else
                {
                    buttonPlay.Visible         = false;
                    labelSelectTopic.Visible   = false;
                    comboBoxGameTopics.Visible = false;
                }
            };

            if (InvokeRequired)
            {
                Invoke(FormUpdate);
            }
            else
            {
                FormUpdate();
            }
        }
Пример #7
0
        private void ProcessOpponentRightAnswerMessage(CommonInformation.Message message)
        {
            ProcessFormFilling FormOpponentAnswerStatus = delegate
            {
                int opponentPoints = int.Parse(labelOpponentPointsNumber.Text);
                opponentPoints++;
                labelOpponentPointsNumber.Text = opponentPoints.ToString();
            };

            if (InvokeRequired)
            {
                Invoke(FormOpponentAnswerStatus);
            }
            else
            {
                FormOpponentAnswerStatus();
            }
        }
Пример #8
0
        private void ProcessServerResponseMessage(CommonInformation.Message message)
        {
            ProcessFormFilling FormFillingServerResponse = delegate
            {
                textBoxServerIPAddress.Text    = message.IPAdress;
                textBoxServerPort.Text         = message.serverPort.ToString();
                textBoxServerIPAddress.Enabled = false;
                textBoxServerPort.Enabled      = false;
            };

            if (InvokeRequired)
            {
                Invoke(FormFillingServerResponse);
            }
            else
            {
                FormFillingServerResponse();
            }
        }
Пример #9
0
        private void ProcessSendGameTopicsMessage(CommonInformation.Message message)
        {
            ProcessFormFilling FormFillingGameTopics = delegate
            {
                foreach (string topic in message.gameTopics)
                {
                    comboBoxGameTopics.Items.Add(topic);
                }
            };

            if (InvokeRequired)
            {
                Invoke(FormFillingGameTopics);
            }
            else
            {
                FormFillingGameTopics();
            }
        }
Пример #10
0
        private void ProcessGameResultsMessage(CommonInformation.Message message)
        {
            ProcessFormFilling FormGameResult = delegate
            {
                ClearGameField();
                labelOpponent.Text         = Nothing;
                panelGame.Visible          = false;
                richTextBoxGameStatus.Text = message.gameStatus;
                GiveAccessToPlayButtons(true);
            };

            if (InvokeRequired)
            {
                Invoke(FormGameResult);
            }
            else
            {
                FormGameResult();
            }
        }
Пример #11
0
        private void ProcessStartGameResponseMessage(CommonInformation.Message message)
        {
            ProcessFormFilling FormAddGameResponse = delegate
            {
                if (message.mayStartGame == false)
                {
                    richTextBoxGameStatus.Text = message.gameStartDetails;
                }
                else
                {
                    questions             = message.questionsToSend;
                    answers               = message.answersToSend;
                    currentQuestionNumber = StartNumber;
                    currentAnswerNumber   = StartNumber;
                    HideStatisticsTables();
                    ShowDetailsOfTheBeginningOfTheGameWithRandomPlayer(false);
                    GiveAccessToPlayButtons(false);
                    panelGame.Visible          = true;
                    labelOpponent.Text         = message.opponentForGameName;
                    richTextBoxGameStatus.Text = NullString;
                    labelAnswerStatus.Text     = Nothing;
                    buttonAnswerA.Enabled      = true;
                    buttonAnswerB.Enabled      = true;
                    buttonAnswerC.Enabled      = true;
                    buttonAnswerD.Enabled      = true;
                    SetPromptsButtonsEnable(true);
                    ShowQuestion();
                    labelYourPointsNumber.Text     = StringWithNull;
                    labelOpponentPointsNumber.Text = StringWithNull;
                }
            };

            if (InvokeRequired)
            {
                Invoke(FormAddGameResponse);
            }
            else
            {
                FormAddGameResponse();
            }
        }
Пример #12
0
        private void ProcessStartGameRequestMessage(CommonInformation.Message message)
        {
            ProcessFormFilling FormAddGameRequest = delegate
            {
                richTextBoxGameStatus.Text = message.gameStartDetails;
                buttonAcceptGame.Visible   = true;
                buttonRejectGame.Visible   = true;
                messageSenderID            = message.messageSenderID;
                messageReceiverID          = message.messageReceiverID;
                messageSenderName          = message.messageName;
                gametopic = message.gameTopic;
            };

            if (InvokeRequired)
            {
                Invoke(FormAddGameRequest);
            }
            else
            {
                FormAddGameRequest();
            }
        }
Пример #13
0
        public void UpdateView()
        {
            ProcessFormFilling FormUpdate = delegate
            {
                richTextBoxChatContent.Clear();
                if (chatDialogsInfo != null)
                {
                    string[] messages = new string[chatDialogsInfo[CurrentDialog].Messages.Count];
                    chatDialogsInfo[CurrentDialog].Messages.CopyTo(messages);
                    foreach (string messageContent in messages)
                    {
                        richTextBoxChatContent.Text += messageContent + "\r\n";
                    }
                }
                comboBoxParticipants.Items.Clear();
                foreach (ClientsInfo clientInfo in clientsInfo)
                {
                    comboBoxParticipants.Items.Add(clientInfo.clientName);
                }

                comboBoxAcceptedToSaveFiles.Items.Clear();
                foreach (KeyValuePair <int, string> filesToSave in chatDialogsInfo[CurrentDialog].FilesToSave)
                {
                    comboBoxAcceptedToSaveFiles.Items.Add(filesToSave.Value);
                }

                labelCurrentClientDialog.Text = chatDialogsInfo[CurrentDialog].Name;
            };

            if (InvokeRequired)
            {
                Invoke(FormUpdate);
            }
            else
            {
                FormUpdate();
            }
        }
Пример #14
0
        public void ProcessReceivedMessages(ChatCommonInfo.Message message)
        {
            int i = CommonInfo.RetrieveMessageType(message.messageType);

            switch (i)
            {
            case 1:
                if (message.IPAdress == "")
                {
                    chatDialogsInfo[CHATDIALOG].AddMessage(DateTime.Now.ToShortTimeString()
                                                           + " - " + message.messageName + " : " + message.messageContent);
                }
                else
                {
                    chatDialogsInfo[CHATDIALOG].AddMessage(message.messageTime.ToString() + " - " + message.IPAdress
                                                           + " - " + message.messageName + " : " + message.messageContent);
                }

                if (message.areFilesSended)
                {
                    foreach (ChatCommonInfo.FileInformaton fileInformaton in message.sendedFilesList)
                    {
                        chatDialogsInfo[CHATDIALOG].FilesToSave.Add(fileInformaton.fileID, fileInformaton.fileName);
                    }
                }
                break;

            case 2:
                chatDialogsInfo[message.messageSenderID].AddMessage(message.messageTime.ToString() + " : " + message.messageContent);
                labelNewMessage.Text = "Новое сообщение от " + message.messageName;

                if (message.areFilesSended)
                {
                    foreach (ChatCommonInfo.FileInformaton fileInformaton in message.sendedFilesList)
                    {
                        chatDialogsInfo[message.messageSenderID].FilesToSave.Add(fileInformaton.fileID, fileInformaton.fileName);
                    }
                }
                break;

            case 3:
                chatDialogsInfo[CurrentDialog].Messages = message.messageHistory;
                break;

            case 5:
            {
                ProcessFormFilling FormFillingNewClient = delegate
                {
                    clientsInfo.Clear();
                    clientsInfo.Add(new ClientsInfo()
                        {
                            clientID = CHATDIALOG, clientName = "Чат"
                        });
                    foreach (ClientsInfo nameClient in message.clientsInfo)
                    {
                        clientsInfo.Add(nameClient);
                        if (!chatDialogsInfo.ContainsKey(nameClient.clientID))
                        {
                            chatDialogsInfo.Add(nameClient.clientID, new AllDialogsMessages(nameClient.clientName));
                        }
                    }
                };
                if (InvokeRequired)
                {
                    Invoke(FormFillingNewClient);
                }
                else
                {
                    FormFillingNewClient();
                }
            }
            break;

            case 7:
            {
                ProcessFormFilling FormFillingServerResponse = delegate
                {
                    textBoxServerIPAdress.Text    = message.IPAdress;
                    textBoxServerPort.Text        = message.serverPort.ToString();
                    textBoxServerIPAdress.Enabled = false;
                    textBoxServerPort.Enabled     = false;
                };
                if (InvokeRequired)
                {
                    Invoke(FormFillingServerResponse);
                }
                else
                {
                    FormFillingServerResponse();
                }
            }
            break;

            default:
                return;
            }
            if (i != 7)
            {
                UpdateView();
            }
        }