Skip to content

Commit 1ca667a

Browse files
author
scelts
committed
Corrected the table sorting
1 parent 7f50029 commit 1ca667a

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

GeesWPF/LandingLogger.cs

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,39 @@ public DataTable LandingLog
7575
{
7676
get
7777
{
78-
var dt = new DataTable();
78+
List<LogEntry> records;
7979
string path = MakeLogIfEmpty();
80+
// Read the CSV file into a list of LogEntry objects
8081
using (var reader = new StreamReader(path))
8182
using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
8283
{
83-
// Do any configuration to `CsvReader` before creating CsvDataReader.
84-
using (var dr = new CsvDataReader(csv))
85-
{
86-
dt.Load(dr);
87-
}
84+
records = csv.GetRecords<LogEntry>().ToList();
85+
}
86+
87+
// Convert the list of LogEntry objects to a DataTable
88+
var dt = new DataTable();
89+
90+
// Add columns to DataTable based on LogEntry properties
91+
dt.Columns.Add("Time", typeof(DateTime));
92+
dt.Columns.Add("Plane", typeof(string));
93+
dt.Columns.Add("FPM", typeof(int));
94+
dt.Columns.Add("Impact (G)", typeof(double));
95+
dt.Columns.Add("Air Speed (kt)", typeof(double));
96+
dt.Columns.Add("Ground Speed (kt)", typeof(double));
97+
dt.Columns.Add("Headwind (kt)", typeof(double));
98+
dt.Columns.Add("Crosswind (kt)", typeof(double));
99+
dt.Columns.Add("Sideslip (deg)", typeof(double));
100+
dt.Columns.Add("Bounces", typeof(double));
101+
102+
// Populate the DataTable with values from the list
103+
foreach (var record in records)
104+
{
105+
dt.Rows.Add(record.Time, record.Plane, record.Fpm, record.G, record.AirV, record.GroundV, record.HeadV, record.CrossV, record.Sideslip, record.Bounces);
88106
}
89-
dt.DefaultView.Sort = "Time desc";
90-
dt = dt.DefaultView.ToTable();
91-
return dt;
107+
108+
// Sort the DataTable by Time in descending order
109+
dt.DefaultView.Sort = "Time DESC";
110+
return dt.DefaultView.ToTable();
92111
}
93112
}
94113
}

GeesWPF/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("1.1.0")]
55-
[assembly: AssemblyFileVersion("1.1.0")]
54+
[assembly: AssemblyVersion("1.1.1")]
55+
[assembly: AssemblyFileVersion("1.1.1")]

0 commit comments

Comments
 (0)