diff --git a/Listing.cs b/Listing.cs index 921cc2b..0e4dfd1 100644 --- a/Listing.cs +++ b/Listing.cs @@ -3,13 +3,13 @@ using System.Globalization; namespace Buypeeb { class Listing { - public string url; - public string id; - public string name; + public string url { get; set; } + public string id { get; set; } + public string name { get; set; } public int price; public int win_price; public string original_name; - public bool favourite; + public bool favourite { get; set; } = false; // start_date, end_date public int bids; public bool auto_extension; diff --git a/MainWindow.cs b/MainWindow.cs index 7a03379..954669b 100755 --- a/MainWindow.cs +++ b/MainWindow.cs @@ -39,6 +39,7 @@ namespace Buypeeb { private MainWindow(Builder builder) : base(builder.GetObject("wndMain").Handle) { this.settings = new Settings(); + this.settings.Save(); this.Title = "Buypeeb"; builder.Autoconnect(this); this.items = (ListStore)builder.GetObject("ListItems"); diff --git a/Settings.cs b/Settings.cs index 8f3b7f3..5ef5235 100644 --- a/Settings.cs +++ b/Settings.cs @@ -1,11 +1,31 @@ using System; using System.Collections.Generic; +using System.IO; +using System.Text.Json; namespace Buypeeb { + class Settings { - public Dictionary watchlist; + private string location; + + public int updateInterval { get; set; } = 10 * 60; + public int favouriteUpdateInterval { get; set; } = 5 * 60; + public int updateIntervalCritical { get; set; } = 60; + public int favouriteUpdateIntervalCritical { get; set; } = 30; + + public Dictionary watchlist { + get; set; + } public Settings() { + if (Environment.OSVersion.Platform == PlatformID.Win32NT) { + // C:\Users\Beebus\AppData\Roaming\Lynnear Software\buypeeb + this.location = Path.Combine(Environment.ExpandEnvironmentVariables("%APPDATA%"), "Lynnear Software", "buypeeb"); + } + else { + // ~/.config/Lynnear Software/buypeeb + this.location = Path.Combine(Environment.GetEnvironmentVariable("HOME"), ".config", "Lynnear Software", "buypeeb"); + } this.watchlist = new Dictionary(); this.Watch("https://buypeeb.biz/whatever/k12345", "my thingy"); this.watchlist["k12345"].Update(); @@ -20,5 +40,14 @@ namespace Buypeeb { Console.WriteLine("{0} - {1}", entry.Value.name, entry.Value.price); } } + + public void Save() { + string j = JsonSerializer.Serialize(this); + Console.WriteLine(j); + } + + // public void Load() { + + // } } }