From e7555f563891b899d325e231b53a2898de2440de Mon Sep 17 00:00:00 2001 From: Manuel Date: Sat, 4 Nov 2023 11:14:35 +0100 Subject: [PATCH] Added some styling for better UX --- MiniserverForm.Designer.cs | 3 ++- MiniserverForm.cs | 47 +++++++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/MiniserverForm.Designer.cs b/MiniserverForm.Designer.cs index d6916b0..e2c0113 100644 --- a/MiniserverForm.Designer.cs +++ b/MiniserverForm.Designer.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; using System.Windows.Forms; namespace LoxStatEdit @@ -185,6 +185,7 @@ private void InitializeComponent() this._dataGridView.VirtualMode = true; this._dataGridView.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DataGridView_CellContentClick); this._dataGridView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.DataGridView_CellValueNeeded); + this._dataGridView.CellFormatting += DataGridView_CellFormatting; // // _nameCol // diff --git a/MiniserverForm.cs b/MiniserverForm.cs index cb7d645..55cf6ec 100644 --- a/MiniserverForm.cs +++ b/MiniserverForm.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -297,6 +297,51 @@ private void MiniserverForm_Load(object sender, EventArgs e) RefreshGridView(); } + private void DataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) + { + if (e.ColumnIndex == 1) // The Name column is at index 1 + { + var fileItem = _fileItems[e.RowIndex]; + if (fileItem.Name == "Download to view description") + { + e.CellStyle.Font = new System.Drawing.Font(e.CellStyle.Font, System.Drawing.FontStyle.Italic); + } + else + { + e.CellStyle.Font = new System.Drawing.Font(e.CellStyle.Font, System.Drawing.FontStyle.Regular); + } + } + if (e.ColumnIndex == 3) // The Status column is at index 3 + { + var fileItem = _fileItems[e.RowIndex]; + switch (fileItem.Status) + { + case "Only on MS": + e.CellStyle.BackColor = System.Drawing.Color.LightGray; + break; + case "Only on FS": + e.CellStyle.BackColor = System.Drawing.Color.LightGoldenrodYellow; + break; + case "Newer on MS": + e.CellStyle.BackColor = System.Drawing.Color.LightGreen; + break; + case "Newer on FS": + e.CellStyle.BackColor = System.Drawing.Color.LightSkyBlue; + break; + case "Larger on MS": + e.CellStyle.BackColor = System.Drawing.Color.LightGreen; + break; + case "Larger on FS": + e.CellStyle.BackColor = System.Drawing.Color.LightSkyBlue; + break; + default: + e.CellStyle.BackColor = System.Drawing.Color.White; + break; + } + } + + } + private void DataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { try