initial work on saving settings

This commit is contained in:
Lynne Megido 2020-09-02 14:12:56 +10:00
parent 80488d7c71
commit 562b1330c9
Signed by: lynnesbian
GPG key ID: F0A184B5213D9F90
3 changed files with 35 additions and 5 deletions

View file

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

View file

@ -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");

View file

@ -1,11 +1,31 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
namespace Buypeeb {
class Settings {
public Dictionary<string, Listing> 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<string, Listing> 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<string, Listing>();
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() {
// }
}
}