mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-10-26 22:01:06 -04:00
style(desktop): give every data grid the nest browser's look
Grids across the desktop app each set their own borders, header styles and selection colours, so tables looked different from form to form. The database nest browser's grid style moves into a shared GridStyle helper that the AutoNest, BOM import, options, nest history, cutting inspection and post settings grids now apply too. The helper also fixes row heights so users cannot resize rows; editing, selection and column sizing stay with each grid. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
697b6492c7
commit
658c1c9ee3
11 files changed
+64
-50
No files matched your search
@@ -0,0 +1,47 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace OpenNest.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// The shared look of every <see cref="DataGridView"/> in the desktop app, taken from the
|
||||
/// database nest browser: flat light headers, faint grid lines, a soft blue selection and
|
||||
/// fixed row heights. Behaviour (editing, selection mode, column sizing) stays with each grid.
|
||||
/// </summary>
|
||||
public static class GridStyle
|
||||
{
|
||||
public const int RowHeight = 22;
|
||||
|
||||
private static readonly Color HeaderBackColor = Color.FromArgb(245, 245, 245);
|
||||
private static readonly Color HeaderForeColor = Color.FromArgb(90, 90, 90);
|
||||
private static readonly Color SelectionBackColor = Color.FromArgb(204, 228, 247);
|
||||
private static readonly Color LineColor = Color.FromArgb(230, 230, 230);
|
||||
|
||||
public static T Apply<T>(T grid) where T : DataGridView
|
||||
{
|
||||
grid.AllowUserToResizeRows = false;
|
||||
grid.BackgroundColor = SystemColors.Window;
|
||||
grid.BorderStyle = BorderStyle.None;
|
||||
grid.GridColor = LineColor;
|
||||
grid.EnableHeadersVisualStyles = false;
|
||||
grid.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
|
||||
grid.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
|
||||
grid.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
grid.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing;
|
||||
grid.RowTemplate.Height = RowHeight;
|
||||
grid.RowTemplate.Resizable = DataGridViewTriState.False;
|
||||
|
||||
grid.DefaultCellStyle.SelectionBackColor = SelectionBackColor;
|
||||
grid.DefaultCellStyle.SelectionForeColor = Color.Black;
|
||||
grid.ColumnHeadersDefaultCellStyle.BackColor = HeaderBackColor;
|
||||
grid.ColumnHeadersDefaultCellStyle.ForeColor = HeaderForeColor;
|
||||
grid.ColumnHeadersDefaultCellStyle.SelectionBackColor = HeaderBackColor;
|
||||
grid.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
||||
grid.RowHeadersDefaultCellStyle.BackColor = HeaderBackColor;
|
||||
grid.RowHeadersDefaultCellStyle.ForeColor = HeaderForeColor;
|
||||
grid.RowHeadersDefaultCellStyle.SelectionBackColor = SelectionBackColor;
|
||||
grid.RowHeadersDefaultCellStyle.SelectionForeColor = Color.Black;
|
||||
grid.RowHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
|
||||
return grid;
|
||||
}
|
||||
}
|
||||
@@ -252,22 +252,18 @@ namespace OpenNest.Controls
|
||||
AddSpanning(grid, label);
|
||||
AddHelp(grid, field.Description, spanning: true);
|
||||
|
||||
var table = new DataGridView
|
||||
var table = GridStyle.Apply(new DataGridView
|
||||
{
|
||||
Dock = DockStyle.Fill,
|
||||
Height = 200,
|
||||
AllowUserToAddRows = true,
|
||||
AllowUserToDeleteRows = true,
|
||||
AllowUserToResizeRows = false,
|
||||
AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill,
|
||||
BackgroundColor = SystemColors.Window,
|
||||
BorderStyle = BorderStyle.FixedSingle,
|
||||
ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize,
|
||||
RowHeadersWidth = 28,
|
||||
SelectionMode = DataGridViewSelectionMode.FullRowSelect,
|
||||
MultiSelect = true,
|
||||
Margin = new Padding(0, 4, 0, 0),
|
||||
};
|
||||
});
|
||||
table.Columns.Add(new DataGridViewTextBoxColumn { HeaderText = field.KeyHeader, FillWeight = 65 });
|
||||
table.Columns.Add(new DataGridViewTextBoxColumn { HeaderText = field.ValueHeader, FillWeight = 35 });
|
||||
|
||||
|
||||
Generated
-6
@@ -84,10 +84,7 @@ namespace OpenNest.Forms
|
||||
//
|
||||
this.partsGrid.AllowUserToAddRows = false;
|
||||
this.partsGrid.AllowUserToDeleteRows = false;
|
||||
this.partsGrid.AllowUserToResizeRows = false;
|
||||
this.partsGrid.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.partsGrid.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.partsGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.partsGrid.Location = new System.Drawing.Point(10, 10);
|
||||
this.partsGrid.Name = "partsGrid";
|
||||
this.partsGrid.RowHeadersVisible = false;
|
||||
@@ -167,10 +164,7 @@ namespace OpenNest.Forms
|
||||
//
|
||||
// plateGrid
|
||||
//
|
||||
this.plateGrid.AllowUserToResizeRows = false;
|
||||
this.plateGrid.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.plateGrid.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.plateGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.plateGrid.Location = new System.Drawing.Point(10, 22);
|
||||
this.plateGrid.Name = "plateGrid";
|
||||
this.plateGrid.RowHeadersVisible = true;
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using OpenNest.Controls;
|
||||
using OpenNest.Engine;
|
||||
|
||||
namespace OpenNest.Forms
|
||||
@@ -19,6 +20,8 @@ namespace OpenNest.Forms
|
||||
public AutoNestForm(Nest nest)
|
||||
{
|
||||
InitializeComponent();
|
||||
GridStyle.Apply(partsGrid);
|
||||
GridStyle.Apply(plateGrid);
|
||||
cancelButton.CausesValidation = false;
|
||||
SetupPartsGrid();
|
||||
SetupPlateGrid();
|
||||
|
||||
Generated
-6
@@ -271,9 +271,6 @@ namespace OpenNest.Forms
|
||||
dgvParts.AllowUserToAddRows = false;
|
||||
dgvParts.AllowUserToDeleteRows = false;
|
||||
dgvParts.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dgvParts.BackgroundColor = System.Drawing.SystemColors.Window;
|
||||
dgvParts.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
dgvParts.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dgvParts.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { colItemNum, colFileName, colDescription, colMaterial, colThickness, colQty, colStatus });
|
||||
dgvParts.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
dgvParts.Name = "dgvParts";
|
||||
@@ -367,9 +364,6 @@ namespace OpenNest.Forms
|
||||
dgvGroups.AllowUserToAddRows = false;
|
||||
dgvGroups.AllowUserToDeleteRows = false;
|
||||
dgvGroups.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dgvGroups.BackgroundColor = System.Drawing.SystemColors.Window;
|
||||
dgvGroups.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
dgvGroups.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dgvGroups.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
dgvGroups.Name = "dgvGroups";
|
||||
dgvGroups.RowHeadersVisible = false;
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using OpenNest.Controls;
|
||||
using OpenNest.Data;
|
||||
using OpenNest.IO;
|
||||
using OpenNest.IO.Bom;
|
||||
@@ -24,6 +25,8 @@ namespace OpenNest.Forms
|
||||
public BomImportForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
GridStyle.Apply(dgvParts);
|
||||
GridStyle.Apply(dgvGroups);
|
||||
_parts = new BindingList<BomPartRow>();
|
||||
_parts.ListChanged += Parts_ListChanged;
|
||||
dgvParts.AutoGenerateColumns = false;
|
||||
|
||||
@@ -101,7 +101,7 @@ internal sealed class CuttingInspectionPanel : UserControl
|
||||
Visible = false,
|
||||
Text = "LIVE NEST only — reviews overlaps, lead-ins and rapid crossings. Confirm minimum spacing, plate boundaries and final post output separately, before posting."
|
||||
};
|
||||
private readonly DataGridView warningGrid = new()
|
||||
private readonly DataGridView warningGrid = GridStyle.Apply(new DataGridView
|
||||
{
|
||||
Dock = DockStyle.Fill,
|
||||
ReadOnly = true,
|
||||
@@ -111,7 +111,7 @@ internal sealed class CuttingInspectionPanel : UserControl
|
||||
SelectionMode = DataGridViewSelectionMode.FullRowSelect,
|
||||
RowHeadersVisible = false,
|
||||
AutoGenerateColumns = false
|
||||
};
|
||||
});
|
||||
private ValidationInspectionScope scope;
|
||||
private bool closed;
|
||||
private int generation;
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using OpenNest.Controls;
|
||||
using OpenNest.Data;
|
||||
using OpenNest.IO;
|
||||
|
||||
@@ -118,7 +119,7 @@ public sealed class NestHistoryForm : Form
|
||||
UpdateButtons();
|
||||
}
|
||||
|
||||
private static DataGridView Grid() => new()
|
||||
private static DataGridView Grid() => GridStyle.Apply(new DataGridView
|
||||
{
|
||||
Dock = DockStyle.Fill,
|
||||
ReadOnly = true,
|
||||
@@ -128,7 +129,7 @@ public sealed class NestHistoryForm : Form
|
||||
SelectionMode = DataGridViewSelectionMode.FullRowSelect,
|
||||
AutoGenerateColumns = false,
|
||||
RowHeadersVisible = false,
|
||||
};
|
||||
});
|
||||
|
||||
private NestRecord SelectedRevision => revisions.SelectedRows.Count > 0 ? revisions.SelectedRows[0].Tag as NestRecord : null;
|
||||
|
||||
|
||||
Generated
-4
@@ -152,10 +152,6 @@
|
||||
//
|
||||
this.strategyGrid.AllowUserToAddRows = false;
|
||||
this.strategyGrid.AllowUserToDeleteRows = false;
|
||||
this.strategyGrid.AllowUserToResizeRows = false;
|
||||
this.strategyGrid.BackgroundColor = System.Drawing.SystemColors.Window;
|
||||
this.strategyGrid.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.strategyGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.strategyGrid.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.strategyGrid.Location = new System.Drawing.Point(3, 18);
|
||||
this.strategyGrid.Name = "strategyGrid";
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using OpenNest.Controls;
|
||||
using OpenNest.Data;
|
||||
using OpenNest.Engine.Strategies;
|
||||
using OpenNest.Properties;
|
||||
@@ -13,6 +14,7 @@ namespace OpenNest.Forms
|
||||
public OptionsForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
GridStyle.Apply(strategyGrid);
|
||||
BuildStrategyGrid();
|
||||
}
|
||||
|
||||
|
||||
@@ -377,39 +377,17 @@ public sealed class SavedNestsForm : Form
|
||||
|
||||
private static DataGridView CreateGrid()
|
||||
{
|
||||
var grid = new DataGridView
|
||||
return GridStyle.Apply(new DataGridView
|
||||
{
|
||||
Dock = DockStyle.Fill,
|
||||
ReadOnly = true,
|
||||
AllowUserToAddRows = false,
|
||||
AllowUserToDeleteRows = false,
|
||||
AllowUserToResizeRows = false,
|
||||
SelectionMode = DataGridViewSelectionMode.FullRowSelect,
|
||||
MultiSelect = false,
|
||||
AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None,
|
||||
BackgroundColor = SystemColors.Window,
|
||||
BorderStyle = BorderStyle.None,
|
||||
GridColor = Color.FromArgb(230, 230, 230),
|
||||
EnableHeadersVisualStyles = false,
|
||||
ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single,
|
||||
RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single,
|
||||
ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize,
|
||||
RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing,
|
||||
StandardTab = true,
|
||||
};
|
||||
grid.RowTemplate.Height = 22;
|
||||
grid.DefaultCellStyle.SelectionBackColor = Color.FromArgb(204, 228, 247);
|
||||
grid.DefaultCellStyle.SelectionForeColor = Color.Black;
|
||||
grid.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(245, 245, 245);
|
||||
grid.ColumnHeadersDefaultCellStyle.ForeColor = Color.FromArgb(90, 90, 90);
|
||||
grid.ColumnHeadersDefaultCellStyle.SelectionBackColor = Color.FromArgb(245, 245, 245);
|
||||
grid.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
||||
grid.RowHeadersDefaultCellStyle.BackColor = Color.FromArgb(245, 245, 245);
|
||||
grid.RowHeadersDefaultCellStyle.ForeColor = Color.FromArgb(90, 90, 90);
|
||||
grid.RowHeadersDefaultCellStyle.SelectionBackColor = Color.FromArgb(204, 228, 247);
|
||||
grid.RowHeadersDefaultCellStyle.SelectionForeColor = Color.Black;
|
||||
grid.RowHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
|
||||
return grid;
|
||||
});
|
||||
}
|
||||
|
||||
private static DataGridViewTextBoxColumn AddColumn(
|
||||
|
||||
Reference in new issue
Block a user