Skip to content

Commit

Permalink
Insert, for Loco
Browse files Browse the repository at this point in the history
  • Loading branch information
ags313 committed Feb 23, 2024
1 parent 4f22922 commit 5971101
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
31 changes: 31 additions & 0 deletions dcs-dtc/New/UI/Base/Systems/WaypointsPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public WaypointsPage(AircraftPage parent, WaypointSystem<T> waypoints, IWaypoint
this.RefreshList();
}

protected override void InsertButtonClick(object sender, EventArgs e)
{
this.InsertAtSelection();
}

protected override void AddButtonClick(object sender, EventArgs e)
{
this.ShowEditDialog();
Expand Down Expand Up @@ -104,6 +109,32 @@ protected override void ShiftDown(int[] rows)
this.SavePreset();
}

private void InsertAtSelection()
{
int? selectedRow = null;
foreach (DataGridViewRow row in this.dgWaypoints.SelectedRows)
{
selectedRow = row.Index;
break;
}

if (selectedRow.HasValue)
{
var newWp = new T();
var atSelection = this.waypoints.Waypoints[selectedRow.Value].Sequence;
foreach (var w in this.waypoints.Waypoints)
{
if(w.Sequence >= atSelection)
{
w.Sequence++;
}
}
newWp.Sequence = atSelection;
this.waypoints.Waypoints.Insert(selectedRow.Value, newWp);
}
this.RefreshList();
}

private void DeleteSelection()
{
if (!DTCMessageBox.ShowQuestion("Are you sure you want to delete the selected(s) waypoint(s)?"))
Expand Down
19 changes: 19 additions & 0 deletions dcs-dtc/New/UI/Base/Systems/WaypointsPageControl.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions dcs-dtc/New/UI/Base/Systems/WaypointsPageControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ protected void SelectRows(int[] rows)
this.dgWaypoints.Select(rows);
}

protected virtual void InsertButtonClick(object sender, EventArgs e)
{
throw new NotImplementedException();
}

protected virtual void AddButtonClick(object sender, EventArgs e)
{
throw new NotImplementedException();
Expand Down

0 comments on commit 5971101

Please sign in to comment.