private void Sound_btn_Click(object sender, RoutedEventArgs e) { if (measuredTime.IsRunning) { measuredTime.Stop(); if (!Trialtest_cb.IsChecked == true) { int reactionTime = (int)measuredTime.ElapsedMilliseconds; measureNumber++; test_timer.Interval = TimeSpan.FromMilliseconds(rand.Next(Max_Interval - Min_Interval) + Max_Interval); Results_tb.Text += (reactionTime.ToString() + " ms.\r\n"); soundTestResults.Add(reactionTime); simpleSound.Stop(); Average_lb.Content = "Średnia:" + Math.Round(Calculations.Average(soundTestResults), 2).ToString() + "ms"; Variance_lb.Content = "Wariancja: " + Math.Round(Calculations.Variance(soundTestResults), 2).ToString(); Standarddeviation_lb.Content = "Odchylenie standardowe: " + Math.Round(Calculations.Standard_deviation(soundTestResults), 2).ToString(); if (_50hz_rb.IsChecked == true) { ResultsList.Add(new TestResults(reactionTime, "Wykonywany rodzaj testu: Dzwiękowy 50 Hz")); } else if (_1000Hz_rb.IsChecked == true) { ResultsList.Add(new TestResults(reactionTime, "Wykonywany rodzaj testu: Dzwiękowy 1000 Hz")); } else if (_2000Hz_rb.IsChecked == true) { ResultsList.Add(new TestResults(reactionTime, "Wykonywany rodzaj testu: Dzwiękowy 2000 Hz")); } else if (_5000Hz_rb.IsChecked == true) { ResultsList.Add(new TestResults(reactionTime, "Wykonywany rodzaj testu: Dzwiękowy 5000 Hz")); } else if (_12500Hz_rb.IsChecked == true) { ResultsList.Add(new TestResults(reactionTime, "Wykonywany rodzaj testu: Dzwiękowy 12500 Hz")); } else if (_15000Hz_rb.IsChecked == true) { ResultsList.Add(new TestResults(reactionTime, "Wykonywany rodzaj testu: Dzwiękowy 15000 Hz")); } } } else { MessageBox.Show("Kliknąłeś zbyt szybko!", "Informacja", MessageBoxButton.OK, MessageBoxImage.Warning); test_timer.Tick += test_timer_Tick; SoundTestGoOn = !SoundTestGoOn; string rootLocation = System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName); string FullPathStart = rootLocation + @"\sound\\Start.png"; if (!SoundTestGoOn) { ImageBrush imgBrush_2 = new ImageBrush(); imgBrush_2.ImageSource = new BitmapImage(new Uri(FullPathStart, UriKind.Relative)); Start_btn.Background = imgBrush_2; Sound_btn.IsEnabled = false; test_timer.IsEnabled = false; Clear_btn.IsEnabled = true; Save_btn.IsEnabled = true; Trialtest_cb.IsEnabled = true; _50hz_rb.IsEnabled = _1000Hz_rb.IsEnabled = _2000Hz_rb.IsEnabled = _5000Hz_rb.IsEnabled = _12500Hz_rb.IsEnabled = _15000Hz_rb.IsEnabled = true; } } }
private void Save_btn_Click(object sender, RoutedEventArgs e) { string name = Name_tb.Text; string rootLocation = System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName); string FullPath = rootLocation + @"\Pomiary\" + Name_tb.Text + ".txt"; DateTime dt = DateTime.Now; string date = dt.ToString(); if (name.Length == 0) { MessageBox.Show("Muszisz uzupelnić indetyfikator!", "Informacja", MessageBoxButton.OK, MessageBoxImage.Warning); } else { if ((!Male_cb.IsChecked == true) && (!Female_cb.IsChecked == true)) { MessageBox.Show("Muszisz wybrać płeć!", "Informacja", MessageBoxButton.OK, MessageBoxImage.Warning); } else { using (StreamWriter sw = new StreamWriter((FullPath), true)) { sw.WriteLine(""); sw.WriteLine("Nazwa osoby badanej: " + Name_tb.Text); if (Male_cb.IsChecked == true) { sw.WriteLine("Płeć osoby badanej: Mężczyzna"); } else if (Female_cb.IsChecked == true) { sw.WriteLine("Płeć osoby badanej: Kobieta"); } sw.WriteLine("Data i czas wykonania testu: " + date); sw.WriteLine("Uzyskane czasy:"); foreach (TestResults oTest in ResultsList) { sw.WriteLine("Wynik testu: " + oTest.Results + " ms." + " " + oTest.Type); } sw.WriteLine(""); sw.WriteLine("Średnia z wszystkich uzyskanych czasów: " + Math.Round(Calculations.Average(soundTestResults), 2).ToString() + " ms."); sw.WriteLine("Wariancja z wszystkich uzyskanych czasów: " + Math.Round(Calculations.Variance(soundTestResults), 2).ToString()); sw.WriteLine("Odchylenie standardowe z wszystkich uzyskanych czasów: " + Math.Round(Calculations.Standard_deviation(soundTestResults), 2).ToString()); sw.WriteLine(""); sw.WriteLine("POSZCZEGÓLNE WYNKI"); sw.WriteLine(""); bool _50hzExist = ResultsList.Exists(oElement => oElement.Type.Equals("Wykonywany rodzaj testu: Dzwiękowy 50 Hz")); bool _1000hzExist = ResultsList.Exists(oElement => oElement.Type.Equals("Wykonywany rodzaj testu: Dzwiękowy 1000 Hz")); bool _2000hzExist = ResultsList.Exists(oElement => oElement.Type.Equals("Wykonywany rodzaj testu: Dzwiękowy 2000 Hz")); bool _5000hzExist = ResultsList.Exists(oElement => oElement.Type.Equals("Wykonywany rodzaj testu: Dzwiękowy 5000 Hz")); bool _12500hzExist = ResultsList.Exists(oElement => oElement.Type.Equals("Wykonywany rodzaj testu: Dzwiękowy 12500 Hz")); bool _15000hzExist = ResultsList.Exists(oElement => oElement.Type.Equals("Wykonywany rodzaj testu: Dzwiękowy 15000 Hz")); if (_50hzExist == true) { List <TestResults> oFoundGrenBlueList = ResultsList.FindAll(oElement => oElement.Type.Equals("Wykonywany rodzaj testu: Dzwiękowy 50 Hz")); sw.WriteLine("Średnia z uzyskanych czasów dla testu 50 Hz: " + Math.Round(Calculations.AverageFound(oFoundGrenBlueList), 2).ToString() + " ms."); sw.WriteLine("Wariancja z uzyskanych czasów dla testu 50 Hz: " + Math.Round(Calculations.VarianceFound(oFoundGrenBlueList), 2).ToString()); sw.WriteLine("Odchylenie standardowe z uzyskanych czasów dla testu 50 Hz: " + Math.Round(Calculations.Standard_deviationFound(oFoundGrenBlueList), 2).ToString()); sw.WriteLine(""); } if (_1000hzExist == true) { List <TestResults> oFoundWhiteBlackeList = ResultsList.FindAll(oElement => oElement.Type.Equals("Wykonywany rodzaj testu: Dzwiękowy 1000 Hz")); sw.WriteLine("Średnia z uzyskanych czasów dla testu 1000 Hz: " + Math.Round(Calculations.AverageFound(oFoundWhiteBlackeList), 2).ToString() + " ms."); sw.WriteLine("Wariancja z uzyskanych czasów dla testu 1000 Hz: " + Math.Round(Calculations.VarianceFound(oFoundWhiteBlackeList), 2).ToString()); sw.WriteLine("Odchylenie standardowe z uzyskanych czasów dla testu 1000 Hz: " + Math.Round(Calculations.Standard_deviationFound(oFoundWhiteBlackeList), 2).ToString()); sw.WriteLine(""); } if (_2000hzExist == true) { List <TestResults> oFoundRedYellowList = ResultsList.FindAll(oElement => oElement.Type.Equals("Wykonywany rodzaj testu: Dzwiękowy 2000 Hz")); sw.WriteLine("Średnia z uzyskanych czasów dla testu 2000 Hz: " + Math.Round(Calculations.AverageFound(oFoundRedYellowList), 2).ToString() + " ms."); sw.WriteLine("Wariancja z uzyskanych czasów dla testu 2000 Hz: " + Math.Round(Calculations.VarianceFound(oFoundRedYellowList), 2).ToString()); sw.WriteLine("Odchylenie standardowe z uzyskanych czasów dla testu 2000 Hz: " + Math.Round(Calculations.Standard_deviationFound(oFoundRedYellowList), 2).ToString()); sw.WriteLine(""); } if (_5000hzExist == true) { List <TestResults> oFoundRedBlackList = ResultsList.FindAll(oElement => oElement.Type.Equals("Wykonywany rodzaj testu: Dzwiękowy 5000 Hz")); sw.WriteLine("Średnia z uzyskanych czasów dla testu 5000 Hz: " + Math.Round(Calculations.AverageFound(oFoundRedBlackList), 2).ToString() + " ms."); sw.WriteLine("Wariancja z uzyskanych czasów dla testu 5000 Hz: " + Math.Round(Calculations.VarianceFound(oFoundRedBlackList), 2).ToString()); sw.WriteLine("Odchylenie standardowe z uzyskanych czasów dla testu 5000 Hz: " + Math.Round(Calculations.Standard_deviationFound(oFoundRedBlackList), 2).ToString()); sw.WriteLine(""); } if (_12500hzExist == true) { List <TestResults> oFoundRedGreenList = ResultsList.FindAll(oElement => oElement.Type.Equals("Wykonywany rodzaj testu: Dzwiękowy 12500 Hz")); sw.WriteLine("Średnia z uzyskanych czasów dla testu 12500 Hz: " + Math.Round(Calculations.AverageFound(oFoundRedGreenList), 2).ToString() + " ms."); sw.WriteLine("Wariancja z uzyskanych czasów dla testu 12500 Hz: " + Math.Round(Calculations.VarianceFound(oFoundRedGreenList), 2).ToString()); sw.WriteLine("Odchylenie standardowe z uzyskanych czasów dla testu 12500 Hz: " + Math.Round(Calculations.Standard_deviationFound(oFoundRedGreenList), 2).ToString()); sw.WriteLine(""); } if (_15000hzExist == true) { List <TestResults> oFoundRedGreenList = ResultsList.FindAll(oElement => oElement.Type.Equals("Wykonywany rodzaj testu: Dzwiękowy 15000 Hz")); sw.WriteLine("Średnia z uzyskanych czasów dla testu 15000 Hz: " + Math.Round(Calculations.AverageFound(oFoundRedGreenList), 2).ToString() + " ms."); sw.WriteLine("Wariancja z uzyskanych czasów dla testu 15000 Hz: " + Math.Round(Calculations.VarianceFound(oFoundRedGreenList), 2).ToString()); sw.WriteLine("Odchylenie standardowe z uzyskanych czasów dla testu 15000 Hz: " + Math.Round(Calculations.Standard_deviationFound(oFoundRedGreenList), 2).ToString()); } } MessageBox.Show("Zapisano!", "Informacja", MessageBoxButton.OK, MessageBoxImage.Information); } } }
private void Visual_btn_Click(object sender, RoutedEventArgs e) { if (measuredTime.IsRunning) { measuredTime.Stop(); VisualFirstColor(); if (!TrialTest_cb.IsChecked == true) { int reactionTime = (int)measuredTime.ElapsedMilliseconds; test_timer.Interval = TimeSpan.FromMilliseconds(rand.Next(Max_Interval - Min_Interval) + Min_Interval); measureNumber++; Results_tb.Text += (reactionTime.ToString() + " ms.\r\n"); visualTestResults.Add(reactionTime); Averange_lb.Content = "Średnia: " + Math.Round(Calculations.Average(visualTestResults), 2).ToString() + " ms."; Varianc_lb.Content = "Wariancja: " + Math.Round(Calculations.Variance(visualTestResults), 2).ToString(); Standarddeviation_lb.Content = "Odchylenie standardowe: " + Math.Round(Calculations.Standard_deviation(visualTestResults), 2).ToString(); if (GreenBlue_rb.IsChecked == true) { ResultsList.Add(new TestResults(reactionTime, "Wykonywany rodzaj testu: Wizualny zielono niebieski")); } else if (WhiteBlack_rb.IsChecked == true) { ResultsList.Add(new TestResults(reactionTime, "Wykonywany rodzaj testu: Wizualny czarno biały")); } else if (RedYellow_rb.IsChecked == true) { ResultsList.Add(new TestResults(reactionTime, "Wykonywany rodzaj testu: Wizualny czerwono żółty")); } else if (RedBlack_rb.IsChecked == true) { ResultsList.Add(new TestResults(reactionTime, "Wykonywany rodzaj testu: Wizualny czerwono czarny")); } else if (RedGreen_rb.IsChecked == true) { ResultsList.Add(new TestResults(reactionTime, "Wykonywany rodzaj testu: Wizualny czerwono zielony")); } } } else { MessageBox.Show("Kliknąłeś zbyt szybko!", "Informacja", MessageBoxButton.OK, MessageBoxImage.Warning); test_timer.Tick += test_timer_Tick; VisualTestGoOn = !VisualTestGoOn; string rootLocation = System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName); string FullPathStart = rootLocation + @"\sound\\Start.png"; if (!VisualTestGoOn) { TrialTest_cb.IsEnabled = true; ImageBrush imgBrush_2 = new ImageBrush(); imgBrush_2.ImageSource = new BitmapImage(new Uri(FullPathStart, UriKind.Relative)); Start_btn.Background = imgBrush_2; Visual_btn.IsEnabled = false; test_timer.IsEnabled = false; Clear_btn.IsEnabled = true; Save_btn.IsEnabled = true; GreenBlue_rb.IsEnabled = WhiteBlack_rb.IsEnabled = RedYellow_rb.IsEnabled = RedBlack_rb.IsEnabled = RedGreen_rb.IsEnabled = true; } if (measuredTime.IsRunning) { measuredTime.Stop(); VisualFirstColor(); } } }