Skip to content

Commit

Permalink
ConfigRawParams: Various bugfixes (#3246)
Browse files Browse the repository at this point in the history
* MyDataGridView: enable double-buffering

Fixes serious graphical corruption that can happen sometimes when scrolling

* ConfigRawParams: fix off-by-one error

Additional options like the dropdown box or bitmask button would not show
up for the first row

* ConfigRawParams: prevent favorites from changing the tree
  • Loading branch information
robertlong13 authored Sep 17, 2024
1 parent 40570ee commit c3c8475
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
4 changes: 4 additions & 0 deletions Controls/MyDataGridView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ namespace MissionPlanner.Controls
{
public class MyDataGridView : DataGridView
{
public MyDataGridView() : base()
{
this.DoubleBuffered = true;
}
protected override void OnPaint(PaintEventArgs e)
{
// mono bug - when deleting all rows, the sharedrow no longer exists and throws System.ArgumentOutOfRangeException
Expand Down
26 changes: 20 additions & 6 deletions GCSViews/ConfigurationView/ConfigRawParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -644,10 +644,24 @@ private void BuildTree()
treeView1.Nodes.Clear();
var currentNode = treeView1.Nodes.Add("All");
string currentPrefix = "";
DataGridViewRowCollection rows = Params.Rows;
for (int i = 0; i < rows.Count; i++)

// Get command names from the gridview
List<string> commands = new List<string>();
foreach (DataGridViewRow row in Params.Rows)
{
string command = row.Cells[Command.Index].Value.ToString();
if (!commands.Contains(command))
{
commands.Add(command);
}
}

// Sort them again (because of the favorites, they may be out of order)
commands.Sort();

for (int i = 0; i < commands.Count; i++)
{
string param = rows[i].Cells[Command.Index].Value.ToString();
string param = commands[i];

// While param does not start with currentPrefix, step up a layer in the tree
while (!param.StartsWith(currentPrefix))
Expand All @@ -657,13 +671,13 @@ private void BuildTree()
}

// If this is the last parameter, add it
if (i == rows.Count - 1)
if (i == commands.Count - 1)
{
currentNode.Nodes.Add(param);
break;
}

string next_param = rows[i + 1].Cells[Command.Index].Value.ToString();
string next_param = commands[i + 1];
// While the next parameter has a common prefix with this, add branch nodes
string nodeToAdd = param.Substring(currentPrefix.Length).Split('_')[0] + "_";
while (nodeToAdd.Length > 1 // While the currentPrefix is smaller than param
Expand Down Expand Up @@ -1002,7 +1016,7 @@ private void but_collapse_Click(object sender, EventArgs e)
// Create and place the relevant control in the options column when a row is entered
private void Params_RowEnter(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex < 1)
if (e.RowIndex < 0)
return;

if (optionsControl != null)
Expand Down

0 comments on commit c3c8475

Please sign in to comment.