From 7df6b490ad9fa33dc317585e87e776795623b962 Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Wed, 1 Jul 2020 00:13:20 -0500 Subject: [PATCH] Release date column --- GUI/Controls/ManageMods.Designer.cs | 11 +++++++++++ GUI/Controls/ManageMods.cs | 10 ++++++++-- GUI/Controls/ManageMods.resx | 1 + GUI/Localization/de-DE/ManageMods.de-DE.resx | 1 + GUI/Model/ModList.cs | 3 ++- Tests/GUI/GH1866.cs | 2 +- 6 files changed, 24 insertions(+), 4 deletions(-) diff --git a/GUI/Controls/ManageMods.Designer.cs b/GUI/Controls/ManageMods.Designer.cs index 60d3a5666b..ab3400e937 100644 --- a/GUI/Controls/ManageMods.Designer.cs +++ b/GUI/Controls/ManageMods.Designer.cs @@ -63,6 +63,7 @@ private void InitializeComponent() this.LatestVersion = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.KSPCompatibility = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.SizeCol = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ReleaseDate = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.InstallDate = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.DownloadCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Description = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -295,6 +296,7 @@ private void InitializeComponent() this.LatestVersion, this.KSPCompatibility, this.SizeCol, + this.ReleaseDate, this.InstallDate, this.DownloadCount, this.Description}); @@ -399,6 +401,14 @@ private void InitializeComponent() this.SizeCol.DefaultCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight; resources.ApplyResources(this.SizeCol, "SizeCol"); // + // ReleaseDate + // + this.ReleaseDate.Name = "ReleaseDate"; + this.ReleaseDate.ReadOnly = true; + this.ReleaseDate.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Programmatic; + this.ReleaseDate.Width = 140; + resources.ApplyResources(this.ReleaseDate, "ReleaseDate"); + // // InstallDate // this.InstallDate.Name = "InstallDate"; @@ -549,6 +559,7 @@ private void InitializeComponent() private System.Windows.Forms.DataGridViewTextBoxColumn LatestVersion; private System.Windows.Forms.DataGridViewTextBoxColumn KSPCompatibility; private System.Windows.Forms.DataGridViewTextBoxColumn SizeCol; + private System.Windows.Forms.DataGridViewTextBoxColumn ReleaseDate; private System.Windows.Forms.DataGridViewTextBoxColumn InstallDate; private System.Windows.Forms.DataGridViewTextBoxColumn DownloadCount; private System.Windows.Forms.DataGridViewTextBoxColumn Description; diff --git a/GUI/Controls/ManageMods.cs b/GUI/Controls/ManageMods.cs index 8f06765ba3..6a3d15d3c4 100644 --- a/GUI/Controls/ManageMods.cs +++ b/GUI/Controls/ManageMods.cs @@ -1161,8 +1161,9 @@ private IEnumerable _SortRowsByColumn(IEnumerable (r.Tag as GUIMod)?.DownloadCount ?? 0); + case 10: return Sort(rows, ReleaseDateSorter); + case 11: return Sort(rows, InstallDateSorter); + case 12: return Sort(rows, r => (r.Tag as GUIMod)?.DownloadCount ?? 0); } return Sort(rows, DefaultSorter); } @@ -1225,6 +1226,11 @@ private long DownloadSizeSorter(DataGridViewRow row) return (row.Tag as GUIMod)?.ToCkanModule()?.download_size ?? 0; } + private long ReleaseDateSorter(DataGridViewRow row) + { + return -(row.Tag as GUIMod)?.ToModule().release_date?.Ticks ?? 0; + } + /// /// Transforms a DataGridViewRow into a long representing the install date, /// suitable for sorting. diff --git a/GUI/Controls/ManageMods.resx b/GUI/Controls/ManageMods.resx index 1e07d67ca9..ea50ec1605 100644 --- a/GUI/Controls/ManageMods.resx +++ b/GUI/Controls/ManageMods.resx @@ -179,6 +179,7 @@ Latest version Max KSP version Download + Release date Install date Downloads Description diff --git a/GUI/Localization/de-DE/ManageMods.de-DE.resx b/GUI/Localization/de-DE/ManageMods.de-DE.resx index 64a15cac65..72629caffc 100644 --- a/GUI/Localization/de-DE/ManageMods.de-DE.resx +++ b/GUI/Localization/de-DE/ManageMods.de-DE.resx @@ -175,6 +175,7 @@ Neueste Version Max. KSP Version Downloadgröße + Veröffentlichungsdatum Installationsdatum Downloadanzahl Kurzbeschreibung diff --git a/GUI/Model/ModList.cs b/GUI/Model/ModList.cs index b46471e21c..0882eb933a 100644 --- a/GUI/Model/ModList.cs +++ b/GUI/Model/ModList.cs @@ -339,10 +339,11 @@ private DataGridViewRow MakeRow(GUIMod mod, List changes, string inst var downloadCount = new DataGridViewTextBoxCell() { Value = String.Format("{0:N0}", mod.DownloadCount) }; var compat = new DataGridViewTextBoxCell() { Value = mod.KSPCompatibility }; var size = new DataGridViewTextBoxCell() { Value = mod.DownloadSize }; + var releaseDate = new DataGridViewTextBoxCell() { Value = mod.ToModule().release_date }; var installDate = new DataGridViewTextBoxCell() { Value = mod.InstallDate }; var desc = new DataGridViewTextBoxCell() { Value = mod.Abstract }; - item.Cells.AddRange(selecting, autoInstalled, updating, replacing, name, author, installVersion, latestVersion, compat, size, installDate, downloadCount, desc); + item.Cells.AddRange(selecting, autoInstalled, updating, replacing, name, author, installVersion, latestVersion, compat, size, releaseDate, installDate, downloadCount, desc); selecting.ReadOnly = selecting is DataGridViewTextBoxCell; autoInstalled.ReadOnly = autoInstalled is DataGridViewTextBoxCell; diff --git a/Tests/GUI/GH1866.cs b/Tests/GUI/GH1866.cs index 53fbf88180..f0474c36ad 100644 --- a/Tests/GUI/GH1866.cs +++ b/Tests/GUI/GH1866.cs @@ -87,7 +87,7 @@ public void Up() _listGui.Columns.Add(new DataGridViewCheckBoxColumn()); _listGui.Columns.Add(new DataGridViewCheckBoxColumn()); _listGui.Columns.Add(new DataGridViewCheckBoxColumn()); - for (int i = 0; i < 9; i++) + for (int i = 0; i < 10; i++) { _listGui.Columns.Add(i.ToString(), "Column" + i); }