put the timers above the column renderers

This commit is contained in:
Lynne Megido 2020-09-04 21:13:40 +10:00
parent d3daf1f6eb
commit 1020745e82
Signed by: lynnesbian
GPG key ID: F0A184B5213D9F90

View file

@ -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;
}
}
}