Skip to content

Commit

Permalink
fix unit sorting by class, will now sort units by type secondarily an…
Browse files Browse the repository at this point in the history
…d by range tertiarily.
  • Loading branch information
FalcoGer committed Nov 23, 2023
1 parent 7700fca commit ffcd8c9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
21 changes: 11 additions & 10 deletions CoordinateConverter/DCS/Tools/FormUnitImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ private enum EDGVColumnHeaders
{
ID,
Coalition,
Type,
TypeName,
TypeL1,
TypeL2,
TypeL3,
Expand All @@ -252,7 +252,7 @@ private void InitCurrentView()

currentView.Columns.Add(EDGVColumnHeaders.ID.ToString(), typeof(int));
currentView.Columns.Add(EDGVColumnHeaders.Coalition.ToString(), typeof(string));
currentView.Columns.Add(EDGVColumnHeaders.Type.ToString(), typeof(string));
currentView.Columns.Add(EDGVColumnHeaders.TypeName.ToString(), typeof(string));
currentView.Columns.Add(EDGVColumnHeaders.Class.ToString(), typeof(string));
currentView.Columns.Add(EDGVColumnHeaders.TypeL1.ToString(), typeof(int));
currentView.Columns.Add(EDGVColumnHeaders.TypeL2.ToString(), typeof(int));
Expand Down Expand Up @@ -325,7 +325,7 @@ public FormUnitImporter(List<CoordinateDataEntry> referencePoints)
// This binds the existing columns to the data properties in the data view
dgv_Units.Columns["dgvColId"].DataPropertyName = EDGVColumnHeaders.ID.ToString();
dgv_Units.Columns["dgvColCoalition"].DataPropertyName = EDGVColumnHeaders.Coalition.ToString();
dgv_Units.Columns["dgvColTypeName"].DataPropertyName = EDGVColumnHeaders.Type.ToString();
dgv_Units.Columns["dgvColTypeName"].DataPropertyName = EDGVColumnHeaders.TypeName.ToString();
dgv_Units.Columns["dgvColClass"].DataPropertyName = EDGVColumnHeaders.Class.ToString();
dgv_Units.Columns["dgvColUnitName"].DataPropertyName = EDGVColumnHeaders.Name.ToString();
dgv_Units.Columns["dgvColPosition"].DataPropertyName = EDGVColumnHeaders.Position.ToString();
Expand Down Expand Up @@ -444,25 +444,26 @@ private void Dgv_Units_ColumnHeaderMouseClick(object sender, DataGridViewCellMou
System.ComponentModel.ListSortDirection direction;
if (dgv_Units.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection == SortOrder.Ascending)
{
direction = System.ComponentModel.ListSortDirection.Descending;
dgv_Units.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection = SortOrder.Descending;
(dgv_Units.DataSource as DataView).Sort =
$"{EDGVColumnHeaders.TypeL1} DESC," +
$"{EDGVColumnHeaders.TypeL2} DESC," +
$"{EDGVColumnHeaders.TypeL3} DESC," +
$"{EDGVColumnHeaders.TypeL4} DESC";
$"{EDGVColumnHeaders.TypeL4} DESC," +
$"{EDGVColumnHeaders.TypeName} DESC," +
$"{EDGVColumnHeaders.RNG} ASC";
dgv_Units.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection = SortOrder.Descending;
}
else
{
direction = System.ComponentModel.ListSortDirection.Ascending;
dgv_Units.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection = SortOrder.Ascending;
(dgv_Units.DataSource as DataView).Sort =
$"{EDGVColumnHeaders.TypeL1} ASC," +
$"{EDGVColumnHeaders.TypeL2} ASC," +
$"{EDGVColumnHeaders.TypeL3} ASC," +
$"{EDGVColumnHeaders.TypeL4} ASC";
$"{EDGVColumnHeaders.TypeL4} ASC," +
$"{EDGVColumnHeaders.TypeName} ASC," +
$"{EDGVColumnHeaders.RNG} ASC";
dgv_Units.Columns[e.ColumnIndex].HeaderCell.SortGlyphDirection = SortOrder.Ascending;
}
dgv_Units.Sort(dgv_Units.Columns[e.ColumnIndex], direction);
break;
default:
break;
Expand Down
1 change: 0 additions & 1 deletion CoordinateConverter/todo.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Unit list:
- Fix unit sorting
- Filter by unit type/name

FIXME:
Expand Down

0 comments on commit ffcd8c9

Please sign in to comment.