private void RR_N(object sender, RoutedEventArgs e) { if (theCombo.SelectedValue != null) { DilemmaRespondent resp = (DilemmaRespondent)theCombo.SelectedValue; Random rnd = new Random(); GraphPane pane = zedGraph.GraphPane; PointPairList list = new PointPairList(); pane.CurveList.Clear(); for (int i = 0; i < resp.RR.Count; i++) { list.Add(i, resp.RR[i]); } LineItem myCurve = pane.AddCurve("RR " + resp.Date.ToString(), list, System.Drawing.Color.FromName(colorNames[rnd.Next(0, colorNames.Length)]), SymbolType.None); pane.Title.Text = "RR rhythmogram "; pane.XAxis.Title.Text = "N, heartbeat number"; pane.YAxis.Title.Text = "RR, ms"; pane.XAxis.Scale.Max = resp.RR.Count; zedGraph.AxisChange(); zedGraph.Invalidate(); } }
private void newtest_Click(object sender, RoutedEventArgs e) { respondent = new DilemmaRespondent(); Testing test = new Testing(respondent, Properties.Resources.DillemFolder); test.Show(); }
private string ConvertAnswers(DilemmaRespondent resp) { string res = ""; for (int i = 0; i < resp.DilemmaAnswers.Count - 1; i++) { resp.DilemmaAnswers[i]._elapsed = (resp.DilemmaAnswers[i + 1].TimeStart - resp.DilemmaAnswers[i].TimeStart).TotalMilliseconds; } resp.DilemmaAnswers[resp.DilemmaAnswers.Count - 1]._elapsed = resp.RR.Skip(resp.DilemmaAnswers[resp.DilemmaAnswers.Count - 1].HeartBeatStart).Take(resp.DilemmaAnswers[resp.DilemmaAnswers.Count - 1].HeartBeatEnd - resp.DilemmaAnswers[resp.DilemmaAnswers.Count - 1].HeartBeatStart).Sum(); var orderansw = resp.DilemmaAnswers.OrderBy(z => z.Dilemma); int index = 0; foreach (DilemmaAnswer answ in orderansw) { var arr = resp.RR.Skip(answ.HeartBeatStart).Take(answ.HeartBeatEnd - answ.HeartBeatStart); res += answ.Answer + "," + ( resp.RR.Count == 0 || arr.Count() == 0 ? "0" : (60.0 / (arr.Average() / 1000.0)).ToString(System.Globalization.CultureInfo.InvariantCulture)) + "," + answ.TimeStart.ToString() + "," + answ._elapsed.ToString(System.Globalization.CultureInfo.InvariantCulture) + ","; } res = res.Remove(res.Length - 1); return(res); }
private void RPlot(object sender, RoutedEventArgs e) { if (theCombo.SelectedValue != null) { DilemmaRespondent resp = (DilemmaRespondent)theCombo.SelectedValue; if (resp.RR.Count != 0) { HxMSymbolicHeart.OfflineRplot rplot = new HxMSymbolicHeart.OfflineRplot(resp.RR.ToArray()); rplot.ShowDialog(); } else { MessageBox.Show("No RR data."); } } }
private void HR_D(object sender, RoutedEventArgs e) { if (theCombo.SelectedValue != null) { DilemmaRespondent resp = (DilemmaRespondent)theCombo.SelectedValue; Random rnd = new Random(); GraphPane pane = zedGraph.GraphPane; PointPairList list = new PointPairList(); pane.CurveList.Clear(); var answers = resp.DilemmaAnswers.OrderBy(z => z.Dilemma).ToArray(); var collection = resp.RR.Take(answers.First().HeartBeatStart); if (collection.Count() != 0) { list.Add(0, collection.Average()); } else { list.Add(0, 0); } for (int i = 0; i < answers.Length; i++) { try { list.Add(answers[i].Dilemma, resp.RR.Skip(answers[i].HeartBeatStart).Take(answers[i].HeartBeatEnd - answers[i].HeartBeatStart).Average()); } catch { } } try { list.Add(answers.Length, resp.RR.Skip(answers.Last().HeartBeatEnd).Average()); } catch { } LineItem myCurve = pane.AddCurve("HR " + resp.Date.ToString(), list, System.Drawing.Color.FromName(colorNames[rnd.Next(0, colorNames.Length)]), SymbolType.Circle); pane.Title.Text = "HR on dilemmas"; pane.XAxis.Title.Text = "Dlm, dilemma"; pane.YAxis.Title.Text = "HR, ms"; pane.XAxis.Scale.Max = answers.Length + 2; zedGraph.AxisChange(); zedGraph.Invalidate(); } }
public Testing(DilemmaRespondent respondent, string workfolder) { InitializeComponent(); Questions = new List <DilemmaFromResource>(); Respondent = respondent; wfolder = workfolder; LoadForm(wfolder + "\\b-0-Hello.xml"); Stage = "b"; Position = 0; SlidesForStage = Directory.GetFiles(wfolder, "b-*.xml"); Answer = null; th = new Thread(() => { while (true) { CheckStatus(); Thread.Sleep(1000); } }); th.Start(); }
private void Button_Click_2(object sender, RoutedEventArgs e) { if (dataGrid1.SelectedValue != null) { StringBuilder csv = new StringBuilder(); csv.AppendLine("N, RR, Dilemma"); DilemmaRespondent resp = (DilemmaRespondent)dataGrid1.SelectedValue; for (int n = 0; n < resp.RR.Count; n++) { DilemmaAnswer answ = resp.DilemmaAnswers.Find(z => z.HeartBeatStart <= n && z.HeartBeatEnd >= n); if (answ != null) { csv.AppendFormat("{0}, {1}, {2}\r\n", n, resp.RR[n], answ.Dilemma); } else { csv.AppendFormat("{0}, {1}, {2}\r\n", n, resp.RR[n], "0"); } } Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = resp.fileName; //resp.ID + "_" + resp.Education + "_" + resp.Age + "_" + resp.CountryLive; dlg.DefaultExt = ".csv"; // Default file extension dlg.Filter = "Comma-separated values (.csv)|*.csv"; // Filter files by extension // Show save file dialog box Nullable <bool> result = dlg.ShowDialog(); // Process save file dialog box results if (result == true) { // Save document string filename = dlg.FileName; File.WriteAllText(filename, csv.ToString()); } } }