Skip to content

Commit

Permalink
ConfigRawParams: manual absolute column sizing
Browse files Browse the repository at this point in the history
This commit does 2 things:
1. Makes all columns but Desc and Fav manually sizeable (no more autosizing)
2. Stores and retrieves column widths from config.xml in absolute widths instead
   of percentages.
  • Loading branch information
robertlong13 authored and meee1 committed Oct 2, 2023
1 parent 3d44e1a commit 578eddc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 30 deletions.
6 changes: 1 addition & 5 deletions GCSViews/ConfigurationView/ConfigRawParams.Designer.cs

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

36 changes: 17 additions & 19 deletions GCSViews/ConfigurationView/ConfigRawParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,15 @@ public void Activate()

foreach (DataGridViewColumn col in Params.Columns)
{
if (!String.IsNullOrEmpty(Settings.Instance["rawparam_" + col.Name + "_widthpercent"]))
// Don't need to size a fill column
if (col.AutoSizeMode == DataGridViewAutoSizeColumnMode.Fill) continue;

// Don't need to size a column that can't be resized
if (col.Resizable == DataGridViewTriState.False) continue;

if (!String.IsNullOrEmpty(Settings.Instance["rawparam_" + col.Name + "_width"]))
{
col.Width = (int)((Math.Max(5, Settings.Instance.GetInt32("rawparam_" + col.Name + "_widthpercent")) / 100.0) * Params.Width);
col.Width = (int)Math.Max(5, Settings.Instance.GetInt32("rawparam_" + col.Name + "_width"));
log.InfoFormat("{0} to {1}", col.Name, col.Width);
}
}
Expand All @@ -91,7 +97,13 @@ public void Deactivate()
{
foreach (DataGridViewColumn col in Params.Columns)
{
Settings.Instance["rawparam_" + col.Name + "_widthpercent"] = ((col.Width / (double)Params.Width) * 100.0).ToString("0", CultureInfo.InvariantCulture);
// Don't need to save the width of a fill column
if (col.AutoSizeMode == DataGridViewAutoSizeColumnMode.Fill) continue;

// Don't need to save the width of a column that can't be resized
if (col.Resizable == DataGridViewTriState.False) continue;

Settings.Instance["rawparam_" + col.Name + "_width"] = col.Width.ToString("0", CultureInfo.InvariantCulture);
}

Settings.Instance["rawparam_splitterdistance"] = splitContainer1.SplitterDistance.ToString();
Expand Down Expand Up @@ -588,7 +600,6 @@ internal void processToScreen()

log.Info("about to add all");

SuspendParamGridView();
Params.Visible = false;

Params.Rows.AddRange(rowlist.ToArray());
Expand All @@ -600,7 +611,6 @@ internal void processToScreen()
Params.Sort(Params.Columns[Command.Index], ListSortDirection.Ascending);

Params.Visible = true;
ResumeParamGridView();

if (splitContainer1.Panel1Collapsed == false)
{
Expand Down Expand Up @@ -710,7 +720,7 @@ private void updatedefaultlist(object crap)
void filterList(string searchfor)
{
DateTime start = DateTime.Now;
SuspendParamGridView();
Params.Visible = false;
if (searchfor.Length >= 2 || searchfor.Length == 0)
{
Regex filter = new Regex(searchfor.Replace("*", ".*").Replace("..*", ".*"), RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline);
Expand Down Expand Up @@ -759,7 +769,7 @@ void filterList(string searchfor)
}
}

ResumeParamGridView();
Params.Visible = true;

log.InfoFormat("Filter: {0}ms", (DateTime.Now - start).TotalMilliseconds);
}
Expand Down Expand Up @@ -1167,18 +1177,6 @@ private void Params_ColumnWidthChanged(object sender, DataGridViewColumnEventArg
optionsControlUpateBounds();
}
}

void SuspendParamGridView()
{
Params.Visible = false;
Params.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
}

void ResumeParamGridView()
{
Params.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
Params.Visible = true;
}
}

}
12 changes: 6 additions & 6 deletions GCSViews/ConfigurationView/ConfigRawParams.resx
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ format with no scaling</value>
<value>50</value>
</data>
<data name="Command.Width" type="System.Int32, mscorlib">
<value>126</value>
<value>130</value>
</data>
<metadata name="Value.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
Expand All @@ -650,7 +650,7 @@ format with no scaling</value>
<value>50</value>
</data>
<data name="Value.Width" type="System.Int32, mscorlib">
<value>69</value>
<value>70</value>
</data>
<metadata name="Default_value.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
Expand All @@ -665,7 +665,7 @@ format with no scaling</value>
<value>False</value>
</data>
<data name="Default_value.Width" type="System.Int32, mscorlib">
<value>69</value>
<value>70</value>
</data>
<metadata name="Units.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
Expand All @@ -677,7 +677,7 @@ format with no scaling</value>
<value>50</value>
</data>
<data name="Units.Width" type="System.Int32, mscorlib">
<value>56</value>
<value>60</value>
</data>
<metadata name="Options.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
Expand All @@ -689,7 +689,7 @@ format with no scaling</value>
<value>50</value>
</data>
<data name="Options.Width" type="System.Int32, mscorlib">
<value>175</value>
<value>150</value>
</data>
<metadata name="Desc.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
Expand Down Expand Up @@ -728,7 +728,7 @@ format with no scaling</value>
<value>Params</value>
</data>
<data name="&gt;&gt;Params.Type" xml:space="preserve">
<value>MissionPlanner.Controls.MyDataGridView, MissionPlanner, Version=1.3.8474.23142, Culture=neutral, PublicKeyToken=null</value>
<value>MissionPlanner.Controls.MyDataGridView, MissionPlanner, Version=1.3.8674.15835, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;Params.Parent" xml:space="preserve">
<value>splitContainer1.Panel2</value>
Expand Down

0 comments on commit 578eddc

Please sign in to comment.