public static EcgValues FromCsv(string csvLine) { string[] values = csvLine.Split(' '); EcgValues ecg = new EcgValues(); ecg.SampleNumber = int.Parse(values[0]); ecg.Signal = (float.Parse(values[1], CultureInfo.InvariantCulture)); return(ecg); }
private void ViewEkgButton_Click(object sender, RoutedEventArgs e) { DBHandler conn = new DBHandler(); conn.InitializeConnection(); List <string> ecgFilenames = conn.GetPatientEcgFilenames(Patient); string filename = ecgFilenames.First(); conn.CloseConnection(); if (filename != null) { EcgValues[] values = File.ReadAllLines("./ecg/" + filename) .Skip(1) .Select(v => EcgValues.FromCsv(v)) .ToArray(); this.EProvider.Signal = values.Select(x => x.Signal).ToArray(); this.bitmapWidth = 500; this.EProvider.offset = this.bitmapWidth; var bitmap = this.DrawEcg(this.EProvider.GetSignal(0)); BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions() ); this.EcgImage.Source = bitmapSource; } }