<Fix>: Fit Previous Results columns to content, increase revision to 3.9.3147.104
Cause: - Fixed column widths left unnecessary empty space and did not adapt to displayed values. - Action buttons required sizing that accounts for captions, icons and padding. Solution: 1. Added content-based column sizing - Fit Batch, Start time, End time, SW version, OK and NOK to headers and formatted values on the current page. - Recalculate widths when the grid is created or the displayed page changes. - Preserve manual resizing between page changes. 2. Adjusted action button widths - Fit OK/NOK diag, Write, the mode-dependent action and Show to their captions. - Include icon width and button padding. - Keep Procedure and Purchase order filling the remaining space. 3. Increased revision - Updated AssemblyVersion and AssemblyFileVersion from 3.9.3147.103 to 3.9.3147.104.
This commit is contained in:
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("3.9.3147.103")]
|
||||
[assembly: AssemblyFileVersion("3.9.3147.103")]
|
||||
[assembly: AssemblyVersion("3.9.3147.104")]
|
||||
[assembly: AssemblyFileVersion("3.9.3147.104")]
|
||||
|
||||
@@ -562,14 +562,14 @@ namespace TBF.UI.ResultsMI
|
||||
resultsGrid.ColumnHeadersDefaultCellStyle.SelectionBackColor = Color.FromArgb(232, 238, 246);
|
||||
resultsGrid.ColumnHeadersDefaultCellStyle.SelectionForeColor = Color.FromArgb(51, 65, 85);
|
||||
|
||||
AddResultColumn("BatchNr", "Batch", 65, 45, Color.FromArgb(248, 250, 252), Color.FromArgb(51, 65, 85), true);
|
||||
AddResultColumn("StartTime", "Start time", 135, 95, Color.FromArgb(245, 248, 252), Color.FromArgb(71, 85, 105), false);
|
||||
AddResultColumn("EndTime", "End time", 135, 95, Color.FromArgb(245, 248, 252), Color.FromArgb(71, 85, 105), false);
|
||||
AddResultColumn("Version", "SW version", 95, 60, Color.FromArgb(247, 247, 251), Color.FromArgb(88, 80, 125), false);
|
||||
AddResultColumn("BatchNr", "Batch", 58, 50, Color.FromArgb(248, 250, 252), Color.FromArgb(51, 65, 85), true);
|
||||
AddResultColumn("StartTime", "Start time", 120, 115, Color.FromArgb(245, 248, 252), Color.FromArgb(71, 85, 105), false);
|
||||
AddResultColumn("EndTime", "End time", 120, 115, Color.FromArgb(245, 248, 252), Color.FromArgb(71, 85, 105), false);
|
||||
AddResultColumn("Version", "SW version", 90, 85, Color.FromArgb(247, 247, 251), Color.FromArgb(88, 80, 125), false);
|
||||
AddResultColumn("Procedure", Strings.Procedure, 320, 120, Color.FromArgb(239, 246, 255), Color.FromArgb(29, 78, 216), true);
|
||||
AddResultColumn("PurchaseOrder", "Purchase order", 160, 90, Color.FromArgb(247, 245, 255), Color.FromArgb(109, 40, 217), true);
|
||||
AddResultColumn("Passed", Strings.Passed, 70, 65, Color.FromArgb(248, 250, 252), Color.FromArgb(51, 65, 85), true);
|
||||
AddResultColumn("Failed", Strings.Failed, 70, 65, Color.FromArgb(248, 250, 252), Color.FromArgb(51, 65, 85), true);
|
||||
AddResultColumn("Passed", Strings.Passed, 64, 64, Color.FromArgb(248, 250, 252), Color.FromArgb(51, 65, 85), true);
|
||||
AddResultColumn("Failed", Strings.Failed, 64, 64, Color.FromArgb(248, 250, 252), Color.FromArgb(51, 65, 85), true);
|
||||
resultsGrid.Columns["StartTime"].DefaultCellStyle.Format = Constants.DateTimeFormat;
|
||||
resultsGrid.Columns["EndTime"].DefaultCellStyle.Format = Constants.DateTimeFormat;
|
||||
|
||||
@@ -592,8 +592,6 @@ namespace TBF.UI.ResultsMI
|
||||
});
|
||||
#endif
|
||||
AddActionColumn("OkNokDiag", "OK/NOK diag");
|
||||
resultsGrid.Columns["OkNokDiag"].Width = 135;
|
||||
resultsGrid.Columns["OkNokDiag"].MinimumWidth = 120;
|
||||
AddActionColumn("Write", "Write");
|
||||
string actionText;
|
||||
if (mode == PreviousResultsMode.Reload)
|
||||
@@ -629,7 +627,7 @@ namespace TBF.UI.ResultsMI
|
||||
resultsGrid.CellMouseEnter += InvalidateResultActionCell;
|
||||
resultsGrid.CellMouseLeave += InvalidateResultActionCell;
|
||||
resultsGrid.CellMouseMove += resultsGrid_CellMouseMove;
|
||||
resultsGrid.HandleCreated += delegate { QueueResultRowHeightUpdate(); };
|
||||
resultsGrid.HandleCreated += delegate { FitResultColumnsToContent(); QueueResultRowHeightUpdate(); };
|
||||
resultsGrid.SizeChanged += delegate { QueueResultRowHeightUpdate(); };
|
||||
resultsGrid.ColumnWidthChanged += delegate { QueueResultRowHeightUpdate(); };
|
||||
foreach (Control control in resultsGrid.Controls)
|
||||
@@ -639,6 +637,40 @@ namespace TBF.UI.ResultsMI
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fits compact columns to the current page, including headers and formatted values.
|
||||
/// Runs when data changes, leaving manual resizing available between page changes.
|
||||
/// </summary>
|
||||
void FitResultColumnsToContent()
|
||||
{
|
||||
if (!resultsGrid.IsHandleCreated || resultsGrid.IsDisposed) return;
|
||||
|
||||
foreach (string name in new[] { "BatchNr", "StartTime", "EndTime", "Version", "Passed", "Failed" })
|
||||
{
|
||||
var column = resultsGrid.Columns[name];
|
||||
column.MinimumWidth = 2;
|
||||
resultsGrid.AutoResizeColumn(column.Index, DataGridViewAutoSizeColumnMode.AllCells);
|
||||
}
|
||||
|
||||
using (var graphics = resultsGrid.CreateGraphics())
|
||||
{
|
||||
foreach (string name in new[] { "OkNokDiag", "Write", "Action", "Show" })
|
||||
{
|
||||
var column = (DataGridViewButtonColumn)resultsGrid.Columns[name];
|
||||
column.MinimumWidth = 2;
|
||||
resultsGrid.AutoResizeColumn(column.Index, DataGridViewAutoSizeColumnMode.AllCells);
|
||||
var flags = TextFormatFlags.SingleLine;
|
||||
if (name != "OkNokDiag") flags |= TextFormatFlags.NoPadding | TextFormatFlags.NoPrefix;
|
||||
int textWidth = TextRenderer.MeasureText(graphics, column.Text, resultsBoldFont,
|
||||
new Size(int.MaxValue, int.MaxValue), flags).Width;
|
||||
int iconWidth = name == "OkNokDiag" ? 0 :
|
||||
(int)Math.Round(14 * graphics.DpiX / 96f) + Math.Max(4, (int)Math.Round(5 * graphics.DpiX / 96f));
|
||||
// Match the painted button: 5px outer and 6px inner margins on each side.
|
||||
column.Width = Math.Max(column.Width, textWidth + iconWidth + 24);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Posts one row-height update after the current native grid layout finishes.
|
||||
/// </summary>
|
||||
@@ -751,7 +783,7 @@ namespace TBF.UI.ResultsMI
|
||||
Text = caption,
|
||||
UseColumnTextForButtonValue = true,
|
||||
FlatStyle = FlatStyle.Flat,
|
||||
Width = 105,
|
||||
Width = 95,
|
||||
MinimumWidth = 75,
|
||||
SortMode = DataGridViewColumnSortMode.NotSortable,
|
||||
};
|
||||
@@ -1179,6 +1211,7 @@ namespace TBF.UI.ResultsMI
|
||||
rows.Add(row);
|
||||
}
|
||||
if (rows.Count > 0) resultsGrid.Rows.AddRange(rows.ToArray());
|
||||
FitResultColumnsToContent();
|
||||
resultsGrid.ClearSelection();
|
||||
}
|
||||
finally
|
||||
|
||||
Reference in New Issue
Block a user