public async Task ConnectAsync() { connection = new HubConnection(url); hubProxy = connection.CreateHubProxy("ChatHub"); hubProxy.On <User>("ParticipantLogin", (u) => ParticipantLoggedIn?.Invoke(u)); hubProxy.On <string>("ParticipantLogout", (n) => ParticipantLoggedOut?.Invoke(n)); hubProxy.On <string>("ParticipantDisconnection", (n) => ParticipantDisconnected?.Invoke(n)); hubProxy.On <string>("ParticipantReconnection", (n) => ParticipantReconnected?.Invoke(n)); hubProxy.On <string>("BroadcastGameStart", (n) => GameStart?.Invoke(n, MessageType.Broadcast)); hubProxy.On <string>("BroadcastGameEnd", (n) => GameEnd?.Invoke(n, MessageType.Broadcast)); hubProxy.On <string, string>("BroadcastSetHost", (n, m) => SetNewHost?.Invoke(n, m, MessageType.Broadcast)); hubProxy.On <string, string>("BroadcastTextMessage", (n, m) => NewTextMessage?.Invoke(n, m, MessageType.Broadcast)); hubProxy.On <string, byte[]>("BroadcastPictureMessage", (n, m) => NewImageMessage?.Invoke(n, m, MessageType.Broadcast)); hubProxy.On <string, byte[]>("BroadcastStrokes", (n, m) => NewStrokesCollected?.Invoke(n, m, MessageType.Broadcast)); hubProxy.On <string, string>("BraodcastAnswerIsRight", (n, m) => Correct?.Invoke(n, m)); hubProxy.On <string, string>("UnicastTextMessage", (n, m) => NewTextMessage?.Invoke(n, m, MessageType.Unicast)); hubProxy.On <string, byte[]>("UnicastPictureMessage", (n, m) => NewImageMessage?.Invoke(n, m, MessageType.Unicast)); hubProxy.On <string>("ParticipantTyping", (p) => ParticipantTyping?.Invoke(p)); connection.Reconnecting += Reconnecting; connection.Reconnected += Reconnected; connection.Closed += Disconnected; ServicePointManager.DefaultConnectionLimit = 10; await connection.Start(); }
public async Task It_will_not_fail_if_Algorithm_name_property_is_also_overriden() { var correct = new Correct(); await correct.Get("TSTDRV1234", new Uri("https://someserver.com"), "TKN", "SEC"); Assert.True(true); }
private void button1_Click(object sender, EventArgs e) { Correct.Clear(); inCorrect.Clear(); userName = textBox1.Text; email = textBox2.Text; if (textBox3.Text == textBox4.Text) { pass = textBox3.Text; Correct.SetError(textBox4, "Correct!!!"); FileStream fs = new FileStream("login.txt", FileMode.OpenOrCreate, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); sw.WriteLine(userName); sw.Close(); fs.Close(); FileStream fsp = new FileStream("password.txt", FileMode.OpenOrCreate, FileAccess.Write); StreamWriter swp = new StreamWriter(fsp); swp.WriteLine(pass); swp.Close(); fsp.Close(); MessageBox.Show("Registration completed successfully"); } else { inCorrect.SetError(textBox4, "Incorrect!!!"); } }
private void Ok_Click(object sender, RoutedEventArgs e) { path = "//TestFinal/Probleme" + CurrentQuestion; r = monFichier.SelectSingleNode(path + "/R"); int res = int.Parse(r.InnerText); Next.IsEnabled = true; if (res == rep) { Correct.Position = TimeSpan.Zero; Correct.Play(); score++; } else { Wrong.Position = TimeSpan.Zero; Wrong.Play(); } if (res == 1) { t1.Visibility = Visibility.Visible; t2.Visibility = Visibility.Hidden; t3.Visibility = Visibility.Hidden; f2.Visibility = Visibility.Visible; f1.Visibility = Visibility.Hidden; f3.Visibility = Visibility.Visible; } if (res == 2) { t2.Visibility = Visibility.Visible; t1.Visibility = Visibility.Hidden; t3.Visibility = Visibility.Hidden; f1.Visibility = Visibility.Visible; f2.Visibility = Visibility.Hidden; f3.Visibility = Visibility.Visible; } if (res == 3) { t3.Visibility = Visibility.Visible; t2.Visibility = Visibility.Hidden; t1.Visibility = Visibility.Hidden; f2.Visibility = Visibility.Visible; f3.Visibility = Visibility.Hidden; f1.Visibility = Visibility.Visible; } }
public int CompareTo(Correct other) { if (other == null) { return(1); } return(Value.CompareTo(other.Value)); }
private void EditSaveChangesButton_Click(object sender, EventArgs e) { string editString = null; for (int i = 0; i < registrationID; i++) { bool result = true; string[] str = new string[7]; for (int j = 1; j < RegistrationDataView.ColumnCount; j++) { /*Каждый иф проверяет одну из 7 ячеек на итерации, если проверки типа CorrectName не выполняется то происходит * вызов бокса сообщений, и так для кажого поля в таблице пока не введешь правильно значения*/ if ((j == 1 || j == 2 || j == 3) && Correct.CorrectName(EditDataView.Rows[i].Cells[j].Value.ToString(), out editString)) { result = false; MessageBox.Show($"Invalid {editString}", "Edit Info"); } if (j == 4 && Correct.CorrectCountry(EditDataView.Rows[i].Cells[j].Value.ToString(), out editString)) { result = false; MessageBox.Show($"Invalid {editString}", "Edit Info"); } if (j == 5 && Correct.CorrectCompetition(EditDataView.Rows[i].Cells[j].Value.ToString(), out editString)) { result = false; MessageBox.Show($"Invalid {editString}", "Edit Info"); } if (j == 6 && Correct.CorrectOlimpicPlace(EditDataView.Rows[i].Cells[j].Value.ToString(), out editString)) { result = false; MessageBox.Show($"Invalid {editString}", "Edit Info"); } str[j] = EditDataView.Rows[i].Cells[j].Value.ToString(); if (result) { for (int k = 1; k < 7; k++) { RegistrationDataView.Rows[i].Cells[k].Value = str[k]; } WinterOlimpic.Sporstmens.ElementAt(i).FirstName = EditDataView.Rows[i].Cells[1].Value.ToString(); WinterOlimpic.Sporstmens.ElementAt(i).LastName = EditDataView.Rows[i].Cells[2].Value.ToString(); WinterOlimpic.Sporstmens.ElementAt(i).Patronymic = EditDataView.Rows[i].Cells[3].Value.ToString(); WinterOlimpic.Sporstmens.ElementAt(i).Country = EditDataView.Rows[i].Cells[4].Value.ToString(); WinterOlimpic.Sporstmens.ElementAt(i).TypeOfCompetition = EditDataView.Rows[i].Cells[5].Value.ToString(); WinterOlimpic.Sporstmens.ElementAt(i).Place = Convert.ToInt32(EditDataView.Rows[i].Cells[6].Value.ToString()); } } } }
public override void Init(Correct onCorrect) { if (!correctAnswer) { Debug.LogWarning("No correct answer provided."); return; } correctAnswer.onClick.AddListener(delegate() { PlayCorrectSound(); if (!panelWhenCorrect) { Debug.LogWarning("No panelWhenCorrect set"); onCorrect(); return; } var button = panelWhenCorrect.GetComponentInChildren <Button>(); if (!button) { Debug.LogWarning("Panel has no button"); onCorrect(); return; } button.onClick.AddListener(delegate() { onCorrect(); }); panelWhenCorrect.SetActive(true); }); correctAnswer2.onClick.AddListener(delegate() { PlayCorrectSound(); if (!panelWhenCorrect) { Debug.LogWarning("No panelWhenCorrect set"); onCorrect(); return; } var button = panelWhenCorrect.GetComponentInChildren <Button>(); if (!button) { Debug.LogWarning("Panel has no button"); onCorrect(); return; } button.onClick.AddListener(delegate() { onCorrect(); }); panelWhenCorrect.SetActive(true); }); }
//Valider la question et changer la question public void validerQuestion(bool boolean) { if (boolean) { questionBonnes++; Correct.SetActive(true); changerQuestion(); } else { Incorrect.SetActive(true); changerQuestion(); } }
private async void GoToScreenSaver() { if (correct) { return; } DisableAllButton(); Correct.Play(); correct = true; await Task.Delay(2000); Frame.Navigate(typeof(ScreenSaver)); }
public string GetExpected() { if (Correct == null || Correct.Count < 1) { throw new ArgumentNullException("Expected"); } if (string.IsNullOrEmpty(Expected)) { return(Correct.First()); } else { return(Expected); } }
public void Check() { Console.WriteLine("Twoja odp: "); Answer = Console.ReadLine(); if (Answer.ToLower() == Correct) { Console.WriteLine("Dobrze"); Points = 1; } else { Console.WriteLine("Zle: poprawna: " + Correct.ToUpper()); Points = 0; } }
public bool Messages(int choix) { bool retour = false; switch (choix) { case 1: Correct co = new Correct(); co.ShowDialog(); break; case 2: Incomplet i = new Incomplet(); i.ShowDialog(); break; case 3: Vide v = new Vide(); v.ShowDialog(); break; case 4: Modifier m = new Modifier(); m.ShowDialog(); break; case 5: Confirmation cf = new Confirmation(); cf.ShowDialog(); break; case 6: Erreur er = new Erreur(); er.ShowDialog(); break; case 7: AutreConf autr = new AutreConf(); autr.ShowDialog(); break; } return(retour); }
public override void Init(Correct onCorrect) { if (!inputField) { Debug.LogWarning("No correct inputField provided."); return; } inputField.onValueChanged.AddListener(delegate(string str) { if (correctAnswer.ToLower() == str.ToLower()) { var button = panelWhenCorrect.GetComponentInChildren <Button>(); button.onClick.AddListener(delegate() { onCorrect(); }); panelWhenCorrect.SetActive(true); } }); }
private void btnTrue_Click(object sender, RoutedEventArgs e) { if (mode == 1) // mode = 1 so correct answer is True { Correct.Source = new Uri("ms-appx:///Assets/Correct.mp3"); Correct.Play(); txtScore.Text = String.Format("Score: {0}".ToUpper(), ++Score); txtState.Text = String.Format("{0}", ++State); dispatcherTimer.Stop(); // timer is stopped dispatcherTimer = null; // timer set to 0 Playing(); } else { dispatcherTimer.Stop(); // timer is stopped dispatcherTimer = null; // timer is set to 0 // Navigate to game over page and pass the score to the OnNavigate constructor arguements to be set to the new highscore Frame.Navigate(typeof(GameOver), Score.ToString()); } }
// Update is called once per frame void Update() { personnageCtrl.deplacer(Input.GetAxis("Horizontal")); if (Input.GetAxis("Vertical") > 0) { personnageCtrl.sauter(); } if (personnageCtrl.getErreursRestantes() < 1) { gameOver(); } //Verifier qu'on a obtenu le trophé et commencer le test if (personnageCtrl.finNiveau && TestActif == false) { TestActif = true; Question1.SetActive(true); Time.timeScale = 0f; } //Mettre a jour le HP restant chancesRestantes.text = personnageCtrl.getErreursRestantes().ToString(); //Rétroaction lorsqu' on répond à une question if (Correct.activeSelf || Incorrect.activeSelf) { if (Input.anyKeyDown) { Correct.SetActive(false); Incorrect.SetActive(false); } } if (FinQuiz.activeSelf) { if (Input.anyKeyDown) { changerQuestion(); } } }
public Correct[] getAnswers(int clickNum) { btCHSTRAS_091_Database db = new btCHSTRAS_091_Database(); String[] selections = new String[] {"Question","QuestionAnswer" }; String where = "QuestionSubject=\'" + QuestionID + "." + clickNum + "\'"; IDataReader reader = db.query("E_SHFQuestions", selections, where, null); reader.Read(); String question = reader.GetString(0); String answer = reader.GetString(1); String[] questions = question.Split(new char[] { ',' }); int right = System.Convert.ToInt32(answer); Correct[] correct = new Correct[questions.Length]; for (int i = 0; i < questions.Length; i++) { correct[i] = new Correct(); correct[i].text = questions[i]; if (i == right) correct[i].right = true; else correct[i].right = false; } return correct; }
private void saveToDBButton_Click(object sender, EventArgs e) { string errorField = null; if (string.IsNullOrEmpty(firstNameTextBox.Text) || string.IsNullOrEmpty(lastNameTextBox.Text) || string.IsNullOrEmpty(patronymicTextBox.Text) || string.IsNullOrEmpty(countryTextBox.Text) || string.IsNullOrEmpty(competitionTextBox.Text) || string.IsNullOrEmpty(placeTextBox.Text)) { MessageBox.Show("Not all text boxes were filled"); } else if (Correct.CorrectName(firstNameTextBox.Text, out errorField) || Correct.CorrectName(lastNameTextBox.Text, out errorField) || Correct.CorrectName(patronymicTextBox.Text, out errorField) || Correct.CorrectCountry(countryTextBox.Text, out errorField) || Correct.CorrectCompetition(competitionTextBox.Text, out errorField) || Correct.CorrectOlimpicPlace(placeTextBox.Text, out errorField)) { MessageBox.Show($"Not correct {errorField}", "Validation Error"); } else { registrationID++; RegistrationDataView.Rows.Add(registrationID, firstNameTextBox.Text, lastNameTextBox.Text, patronymicTextBox.Text, countryTextBox.Text, competitionTextBox.Text, placeTextBox.Text); EditDataView.Rows.Add(registrationID, firstNameTextBox.Text, lastNameTextBox.Text, patronymicTextBox.Text, countryTextBox.Text, competitionTextBox.Text, placeTextBox.Text); WinterOlimpic.Sporstmens.Add(new Sporstman { Registration_ID = registrationID, FirstName = firstNameTextBox.Text, LastName = lastNameTextBox.Text, Patronymic = patronymicTextBox.Text, Country = countryTextBox.Text, TypeOfCompetition = competitionTextBox.Text, Place = int.Parse(placeTextBox.Text) }); } }
public bool CheckAnswer(string answer) { Regex regex; Match match; bool ignore_case, ignore_spaces; int matched_all_in_order = 0; if (String.IsNullOrEmpty(answer)) { return(false); } ignore_case = (CheckAttributes & GameAnswerCheckAttributes.IgnoreCase) == GameAnswerCheckAttributes.IgnoreCase; ignore_spaces = (CheckAttributes & GameAnswerCheckAttributes.IgnoreSpaces) == GameAnswerCheckAttributes.IgnoreSpaces; if (ignore_case == true) // This necessary to make pattern selection (e.g. [a-z]) case insensitive { regex = new Regex(CheckExpression, RegexOptions.IgnoreCase); } else { regex = new Regex(CheckExpression); } string [] right_answers = Correct.Split(Separator); for (int i = 0; i < right_answers.Length; i++) { right_answers [i] = right_answers[i].Trim(); if (ignore_spaces) { right_answers [i] = RemoveWhiteSpace(right_answers [i]); } } if ((CheckAttributes & GameAnswerCheckAttributes.Trim) == GameAnswerCheckAttributes.Trim) { answer = answer.Trim(); } if (ignore_spaces) { answer = RemoveWhiteSpace(answer); } // All strings from the list of expected answers (two numbers: 22 | 44) must present in the answer if ((CheckAttributes & GameAnswerCheckAttributes.MatchAll) == GameAnswerCheckAttributes.MatchAll || (CheckAttributes & GameAnswerCheckAttributes.MatchAllInOrder) == GameAnswerCheckAttributes.MatchAllInOrder) { int pos = 0; match = regex.Match(answer); while (String.IsNullOrEmpty(match.Value) == false) { bool matched = false; if ((CheckAttributes & GameAnswerCheckAttributes.MatchAll) == GameAnswerCheckAttributes.MatchAll) { for (int i = 0; i < right_answers.Length; i++) { if (String.Compare(match.Value, right_answers[i], ignore_case) == 0) { right_answers[i] = null; matched = true; break; } } if (matched == false) { return(false); } } else //MatchAllInOrder { if (String.Compare(match.Value, right_answers[pos++], ignore_case) == 0) { matched_all_in_order++; } } match = match.NextMatch(); } if ((CheckAttributes & GameAnswerCheckAttributes.MatchAllInOrder) == GameAnswerCheckAttributes.MatchAllInOrder && matched_all_in_order == right_answers.Length) { return(true); } // Have all the expected answers been matched? for (int i = 0; i < right_answers.Length; i++) { if (right_answers[i] != null) { return(false); } } return(true); } else // Any string from the list of possible answers (answer1 | answer2) present in the answer will do it { foreach (string s in right_answers) { match = regex.Match(answer); if (String.Compare(match.Value, s, ignore_case) == 0) { return(true); } } } return(false); }
public bool Equals(Correct c) => false;
public void AddCorrectSong(ISong song, double score) { Correct.Add(new KeyValuePair <ISong, double>(song, score)); }
public bool Equals(Correct other) => !ReferenceEquals(other, null) && Value == other.Value;
public bool Equals(Correct other) => !(other is null) && Value == other.Value;
public virtual void Init(Correct onCorrect) { }