Guest User

Untitled

a guest
Dec 10th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. public void Open()
  2. {
  3. ObservableCollection<DataItem> d = new ObservableCollection<DataItem>();
  4. ReadWriteDialog rwd = new ReadWriteDialog();
  5. List <string[]> content = rwd.ReadCSVFile(Window, out fileName);
  6. if (fileName != null)
  7. {
  8. Window.Title = fileName;
  9. }
  10.  
  11. if (content != null)
  12. {
  13. foreach (var c in content)
  14. {
  15. try
  16. {
  17. uint date = Convert.ToUInt32(c[0]);
  18. double temperature = Convert.ToDouble(c[1]);
  19. int place = Convert.ToInt32(c[2]);
  20. d.Add(new DataItem(date, temperature, place % 3 == 0 ? METERS.NAMES.AIRPORT : (place % 3 == 1 ? METERS.NAMES.CENTER : METERS.NAMES.RUISSALO)));
  21. }
  22. catch (Exception)
  23. {
  24. MessageBox.Show("Error reading data in file, check its contents.");
  25. Window.Close();
  26. }
  27. }
  28.  
  29. }
  30.  
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment