From 1020745e82c247305c1acb622502ce5911a43b02 Mon Sep 17 00:00:00 2001 From: Lynnesbian Date: Fri, 4 Sep 2020 21:13:40 +1000 Subject: [PATCH] put the timers above the column renderers --- MainWindow.cs | 68 +++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/MainWindow.cs b/MainWindow.cs index e84e8e1..911a79b 100755 --- a/MainWindow.cs +++ b/MainWindow.cs @@ -423,6 +423,40 @@ namespace Buypeeb { this.UpdateItem(this.selectedItem.id); } + // timers + + private bool UpdateSelectionEndTime() { + if (!this.selectionViewBox.IsSensitive) { + return true; + } + + var item = this.selectedItem; + if (!item.ready) { + return true; + } + + string ending = ""; + if (item.available) { + var now = DateTime.Now; + var end = item.endDate.ToLocalTime(); + var span = end.Subtract(now); + + if (span.Days > 0) { + ending += span.ToString("dd' days, '"); // will format twelve days as "12 days, " + } + // timespan objects don't contain definitions for the time or date separators, so the colons need to be escaped + // `HH` doesn't exist, but `hh` behaves identically + // see https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-timespan-format-strings + ending += span.ToString(@"hh\:mm\:ss"); + } + else { + ending = "Auction has ended"; + } + + this.endingLabel.Text = ending; + return true; + } + // column renderers private void RenderColumnName(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.ITreeModel model, Gtk.TreeIter iter) { @@ -459,39 +493,5 @@ namespace Buypeeb { } (cell as Gtk.CellRendererText).Text = item.ready ? ending : "..."; } - - // timers - - private bool UpdateSelectionEndTime() { - if (!this.selectionViewBox.IsSensitive) { - return true; - } - - var item = this.selectedItem; - if (!item.ready) { - return true; - } - - string ending = ""; - if (item.available) { - var now = DateTime.Now; - var end = item.endDate.ToLocalTime(); - var span = end.Subtract(now); - - if (span.Days > 0) { - ending += span.ToString("dd' days, '"); // will format twelve days as "12 days, " - } - // timespan objects don't contain definitions for the time or date separators, so the colons need to be escaped - // `HH` doesn't exist, but `hh` behaves identically - // see https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-timespan-format-strings - ending += span.ToString(@"hh\:mm\:ss"); - } - else { - ending = "Auction has ended"; - } - - this.endingLabel.Text = ending; - return true; - } } }