From 9ad7e4f2887281fde96b070ab76bb871b7098bd5 Mon Sep 17 00:00:00 2001 From: Lynnesbian Date: Fri, 4 Sep 2020 19:13:16 +1000 Subject: [PATCH] it makes more sense to call them "YahooAuctionsItem"s rather than "Listing"s because i always use variable names like "item" or "SelectedItem" for them --- Listing.cs | 6 +++--- MainWindow.cs | 16 ++++++++-------- Settings.cs | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Listing.cs b/Listing.cs index 02635b2..8c6d83a 100644 --- a/Listing.cs +++ b/Listing.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.Text.Json; namespace Buypeeb { - class Listing { + class YahooAuctionsItem { public string url { get { return $"https://page.auctions.yahoo.co.jp/jp/auction/{this.id}"; @@ -31,13 +31,13 @@ namespace Buypeeb { private bool success { get; set; } // TODO: custom setter that throws an exception if set to false or something idk - public Listing(string id, string name) { + public YahooAuctionsItem(string id, string name) { this.id = id; this.name = name; this.ready = false; } - public Listing() { + public YahooAuctionsItem() { // parameterless constructor for deserialisation } diff --git a/MainWindow.cs b/MainWindow.cs index 1b09475..f33e582 100755 --- a/MainWindow.cs +++ b/MainWindow.cs @@ -52,10 +52,10 @@ namespace Buypeeb { static SemaphoreSlim tasklimit = new SemaphoreSlim(4); - private Listing SelectedItem { + private YahooAuctionsItem SelectedItem { get { this.itemTreeView.Selection.GetSelected(out TreeIter iter); - return (Listing)this.itemTreeView.Model.GetValue(iter, 0); + return (YahooAuctionsItem)this.itemTreeView.Model.GetValue(iter, 0); } } @@ -97,7 +97,7 @@ namespace Buypeeb { // bind treeview columns to watchlist instead of needing to manually sync its liststore this.itemTreeView = (TreeView)builder.GetObject("TreeViewItems"); - this.items = new ListStore(typeof(Listing)); + this.items = new ListStore(typeof(YahooAuctionsItem)); this.RenderList(); this.itemTreeView.Model = this.items; @@ -136,7 +136,7 @@ namespace Buypeeb { this.itemTreeView.Model.GetIterFirst(out iter); for (int i = 0; i < this.itemTreeView.Model.IterNChildren(); i++) { - var x = (Listing)this.itemTreeView.Model.GetValue(iter, 0); + var x = (YahooAuctionsItem)this.itemTreeView.Model.GetValue(iter, 0); if (x.id == id) { return (this.itemTreeView.Model.GetPath(iter), iter); } @@ -413,22 +413,22 @@ namespace Buypeeb { // column renderers private void RenderColumnName(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.ITreeModel model, Gtk.TreeIter iter) { - Listing item = (Listing)model.GetValue(iter, 0); + YahooAuctionsItem item = (YahooAuctionsItem)model.GetValue(iter, 0); (cell as Gtk.CellRendererText).Text = item.name ?? "Loading..."; } private void RenderColumnPriceYen(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.ITreeModel model, Gtk.TreeIter iter) { - Listing item = (Listing)model.GetValue(iter, 0); + YahooAuctionsItem item = (YahooAuctionsItem)model.GetValue(iter, 0); (cell as Gtk.CellRendererText).Text = item.ready ? item.PriceJPY() : "..."; } private void RenderColumnPriceAUD(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.ITreeModel model, Gtk.TreeIter iter) { - Listing item = (Listing)model.GetValue(iter, 0); + YahooAuctionsItem item = (YahooAuctionsItem)model.GetValue(iter, 0); (cell as Gtk.CellRendererText).Text = item.ready ? item.PriceAUD() : "..."; } private void RenderColumnEnding(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.ITreeModel model, Gtk.TreeIter iter) { - Listing item = (Listing)model.GetValue(iter, 0); + YahooAuctionsItem item = (YahooAuctionsItem)model.GetValue(iter, 0); (cell as Gtk.CellRendererText).Text = item.ready ? "whatever" : "..."; } diff --git a/Settings.cs b/Settings.cs index 56cdeb7..5bb0b50 100644 --- a/Settings.cs +++ b/Settings.cs @@ -9,14 +9,14 @@ namespace Buypeeb { public int updateIntervalCritical { get; set; } = 60; public int favouriteUpdateIntervalCritical { get; set; } = 30; - public Dictionary watchlist { + public Dictionary watchlist { get; set; } public Settings() { if (this.watchlist == null) { // either this is the first time the program has been run, or there's something wrong with userdata.json - this.watchlist = new Dictionary(); + this.watchlist = new Dictionary(); // this.Watch("https://buypeeb.biz/whatever/k12345", "my thingy"); // this.Watch("https://buypeeb.biz/whatever/z09876", "your thingy"); // this.Watch("https://buypeeb.biz/whatever/h55555", "our thingy"); @@ -28,10 +28,10 @@ namespace Buypeeb { } - public Listing Watch(string url, string name) { + public YahooAuctionsItem Watch(string url, string name) { string id = BuypeebApp.IDFromURL(url); Console.WriteLine(id); - this.watchlist[id] = new Listing(id, name); + this.watchlist[id] = new YahooAuctionsItem(id, name); return this.watchlist[id]; } }