Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConfigRawParams: Various bugfixes #3246

Merged
merged 3 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading