formatting that makes it look slightly less icky

This commit is contained in:
Lynne Megido 2021-06-15 10:34:11 +10:00
parent b26326baf5
commit 34657b9b78
Signed by: lynnesbian
GPG Key ID: F0A184B5213D9F90
5 changed files with 192 additions and 200 deletions

View File

@ -5,13 +5,14 @@ namespace Buypeeb {
private readonly Entry entryURL; private readonly Entry entryURL;
private readonly Entry entryName; private readonly Entry entryName;
public AddItemDialogue() : this(new Builder("add.glade")) { } public AddItemDialogue() : this(new Builder("add.glade")) {
}
private AddItemDialogue(Builder builder) : base(builder.GetObject("DialogueAdd").Handle) { private AddItemDialogue(Builder builder) : base(builder.GetObject("DialogueAdd").Handle) {
Title = "Add item"; Title = "Add item";
builder.Autoconnect(this); builder.Autoconnect(this);
entryURL = (Entry)builder.GetObject("EntryAddURL"); entryURL = (Entry) builder.GetObject("EntryAddURL");
entryName = (Entry)builder.GetObject("EntryAddName"); entryName = (Entry) builder.GetObject("EntryAddName");
DeleteEvent += Window_Shutdown; DeleteEvent += Window_Shutdown;
} }

View File

@ -39,7 +39,6 @@ using Timeout = GLib.Timeout;
namespace Buypeeb { namespace Buypeeb {
[SuppressMessage("ReSharper", "UnusedMember.Local")] [SuppressMessage("ReSharper", "UnusedMember.Local")]
internal class MainWindow : Window { internal class MainWindow : Window {
private string location; private string location;
private JsonSerializerOptions jsonOptions; private JsonSerializerOptions jsonOptions;
@ -52,46 +51,40 @@ namespace Buypeeb {
// that way we don't need to constantly do "builder.GetObject"s // that way we don't need to constantly do "builder.GetObject"s
// when that is done, you can use the cache array to replace everything from here... // when that is done, you can use the cache array to replace everything from here...
private Box selectionViewBox; private readonly Box selectionViewBox;
private Label endingLabel; private readonly Label endingLabel;
private bool queueActive; private bool queueActive;
private SearchEntry searchEntry; private readonly SearchEntry searchEntry;
private Dictionary<string, CheckButton> filterChecks = new Dictionary<string, CheckButton>(); private readonly Dictionary<string, CheckButton> filterChecks = new Dictionary<string, CheckButton>();
// ...to here. // ...to here.
private static SemaphoreSlim taskLimit = new SemaphoreSlim(6); private static SemaphoreSlim taskLimit = new SemaphoreSlim(6);
private Queue<string> updateQueue = new Queue<string>(); private readonly Queue<string> updateQueue = new Queue<string>();
private IEnumerable<YahooAuctionsItem> filterQuery {
get { private IEnumerable<YahooAuctionsItem> filterQuery =>
// father forgive me for i have lynned // father forgive me for i have lynned
return from item in settings.watchlist.Values.ToList()
from item in settings.watchlist.Values.ToList() where (item.favourite != filterChecks["Favourites"].Active ||
where (item.favourite != filterChecks["Favourites"].Active || item.favourite == filterChecks["NonFavourites"].Active) &&
item.favourite == filterChecks["NonFavourites"].Active) && (item.Available != filterChecks["Active"].Active ||
(item.Available != filterChecks["Active"].Active || item.Available == filterChecks["Ended"].Active) &&
item.Available == filterChecks["Ended"].Active) && (item.endingToday != filterChecks["EndingToday"].Active ||
(item.endingToday != filterChecks["EndingToday"].Active || item.endingToday == filterChecks["EndingAfterToday"].Active) &&
item.endingToday == filterChecks["EndingAfterToday"].Active) && (item.hasWinPrice != filterChecks["WithWinPrice"].Active ||
(item.hasWinPrice != filterChecks["WithWinPrice"].Active || item.hasWinPrice == filterChecks["WithNoWinPrice"].Active) &&
item.hasWinPrice == filterChecks["WithNoWinPrice"].Active) && (string.IsNullOrWhiteSpace(searchEntry.Text) ||
(String.IsNullOrWhiteSpace(searchEntry.Text) || item.name.ToLower().Contains(searchEntry.Text.ToLower()) ||
item.name.ToLower().Contains(searchEntry.Text.ToLower()) || item.originalName.ToLower().Contains(searchEntry.Text.ToLower()))
item.originalName.ToLower().Contains(searchEntry.Text.ToLower())) select item;
select item;
} private IEnumerable<YahooAuctionsItem> outdatedItemQuery =>
} // only returns items that meet all of the following:
private IEnumerable<YahooAuctionsItem> outdatedItemQuery { // - marked as "ready", as in, they aren't in the process of updating
get { // - not updated since the interval
// only returns items that meet all of the following: from item in settings.watchlist.Values.ToList()
// - marked as "ready", as in, they aren't in the process of updating where item.Ready && settings.ItemNotUpdatedSinceInterval(item)
// - not updated since the interval select item;
return
from item in settings.watchlist.Values.ToList()
where item.Ready && settings.ItemNotUpdatedSinceInterval(item)
select item;
}
}
private YahooAuctionsItem selectedItem { private YahooAuctionsItem selectedItem {
get { get {
@ -101,11 +94,12 @@ namespace Buypeeb {
} }
itemTreeView.Selection.GetSelected(out var iter); itemTreeView.Selection.GetSelected(out var iter);
return (YahooAuctionsItem)itemTreeView.Model.GetValue(iter, 0); return (YahooAuctionsItem) itemTreeView.Model.GetValue(iter, 0);
} }
} }
public MainWindow() : this(new Builder("main.glade")) { } public MainWindow() : this(new Builder("main.glade")) {
}
private MainWindow(Builder builder) : base(builder.GetObject("wndMain").Handle) { private MainWindow(Builder builder) : base(builder.GetObject("wndMain").Handle) {
jsonOptions = new JsonSerializerOptions { jsonOptions = new JsonSerializerOptions {
@ -114,11 +108,12 @@ namespace Buypeeb {
if (Environment.OSVersion.Platform == PlatformID.Win32NT) { if (Environment.OSVersion.Platform == PlatformID.Win32NT) {
// C:\Users\Beebus\AppData\Roaming\Lynnear Software\buypeeb // C:\Users\Beebus\AppData\Roaming\Lynnear Software\buypeeb
location = System.IO.Path.Combine(Environment.ExpandEnvironmentVariables("%APPDATA%"), "Lynnear Software", "buypeeb"); location = System.IO.Path.Combine(Environment.ExpandEnvironmentVariables("%APPDATA%"), "Lynnear Software",
} "buypeeb");
else { } else {
// ~/.config/Lynnear Software/buypeeb // ~/.config/Lynnear Software/buypeeb
location = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config", "Lynnear Software", "buypeeb"); location = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config",
"Lynnear Software", "buypeeb");
} }
var userdata = System.IO.Path.Combine(location, "userdata.json"); var userdata = System.IO.Path.Combine(location, "userdata.json");
@ -126,38 +121,39 @@ namespace Buypeeb {
try { try {
var j = File.ReadAllText(userdata); var j = File.ReadAllText(userdata);
settings = JsonSerializer.Deserialize<Settings>(j); settings = JsonSerializer.Deserialize<Settings>(j);
} } catch {
catch {
// ??? // ???
Console.WriteLine("oops"); Console.WriteLine("oops");
Application.Quit(); Application.Quit();
} }
} else {
}
else {
settings = new Settings(); settings = new Settings();
} }
SaveSettings(); SaveSettings();
Title = "Buypeeb"; Title = "Buypeeb";
this.builder = builder; this.builder = builder;
builder.Autoconnect(this); builder.Autoconnect(this);
var menuButtonFilter = (MenuButton)builder.GetObject("MenuButtonFilter"); var menuButtonFilter = (MenuButton) builder.GetObject("MenuButtonFilter");
var menuButtonSort = (MenuButton)builder.GetObject("MenuButtonSort"); var menuButtonSort = (MenuButton) builder.GetObject("MenuButtonSort");
menuButtonFilter.Child = (Image)builder.GetObject("ImageFilter"); menuButtonFilter.Child = (Image) builder.GetObject("ImageFilter");
menuButtonSort.Child = (Image)builder.GetObject("ImageSort"); menuButtonSort.Child = (Image) builder.GetObject("ImageSort");
selectionViewBox = (Box)builder.GetObject("SelectionViewBox"); selectionViewBox = (Box) builder.GetObject("SelectionViewBox");
endingLabel = (Label)builder.GetObject("LabelSelectedEnding"); endingLabel = (Label) builder.GetObject("LabelSelectedEnding");
searchEntry = (SearchEntry)builder.GetObject("FilterSearchEntry"); searchEntry = (SearchEntry) builder.GetObject("FilterSearchEntry");
foreach (var name in new List<string> { "Favourites", "NonFavourites", "Active", "Ended", "EndingToday", "EndingAfterToday", "WithWinPrice", "WithNoWinPrice" }) { foreach (var name in new List<string> {
filterChecks.Add(name, (CheckButton)builder.GetObject($"CheckButtonFilter{name}")); "Favourites", "NonFavourites", "Active", "Ended", "EndingToday", "EndingAfterToday", "WithWinPrice",
"WithNoWinPrice"
}) {
filterChecks.Add(name, (CheckButton) builder.GetObject($"CheckButtonFilter{name}"));
filterChecks[name].Active = false; filterChecks[name].Active = false;
} }
// bind treeview columns to watchlist instead of needing to manually sync its liststore // bind treeview columns to watchlist instead of needing to manually sync its liststore
itemTreeView = (TreeView)builder.GetObject("TreeViewItems"); itemTreeView = (TreeView) builder.GetObject("TreeViewItems");
items = new ListStore(typeof(YahooAuctionsItem)); items = new ListStore(typeof(YahooAuctionsItem));
var filteredItems = new TreeModelFilter(items, null) {VisibleFunc = ItemFilter}; var filteredItems = new TreeModelFilter(items, null) {VisibleFunc = ItemFilter};
@ -199,10 +195,10 @@ namespace Buypeeb {
// TODO: surely there's a better way to do this // TODO: surely there's a better way to do this
TreeIter iter; TreeIter iter;
itemTreeView.Model.GetIterFirst(out iter); itemTreeView.Model.GetIterFirst(out iter);
var m = (TreeModelFilter)itemTreeView.Model; var m = (TreeModelFilter) itemTreeView.Model;
for (var i = 0; i < itemTreeView.Model.IterNChildren(); i++) { for (var i = 0; i < itemTreeView.Model.IterNChildren(); i++) {
var x = (YahooAuctionsItem)itemTreeView.Model.GetValue(iter, 0); var x = (YahooAuctionsItem) itemTreeView.Model.GetValue(iter, 0);
if (x.id == id) { if (x.id == id) {
return (m.ConvertPathToChildPath(m.GetPath(iter)), m.ConvertIterToChildIter(iter)); return (m.ConvertPathToChildPath(m.GetPath(iter)), m.ConvertIterToChildIter(iter));
} }
@ -228,7 +224,6 @@ namespace Buypeeb {
using (var fs = File.CreateText(p)) { using (var fs = File.CreateText(p)) {
fs.Write(j); fs.Write(j);
} }
} }
/// <summary> /// <summary>
@ -262,6 +257,7 @@ namespace Buypeeb {
if (pathAndIter.path != null) { if (pathAndIter.path != null) {
items.EmitRowChanged(pathAndIter.path, pathAndIter.iter); items.EmitRowChanged(pathAndIter.path, pathAndIter.iter);
} }
if (item == selectedItem) { if (item == selectedItem) {
// if the user has this item selected and it just became ready, enable the selection box and redraw the info // if the user has this item selected and it just became ready, enable the selection box and redraw the info
selectionViewBox.Sensitive = true; selectionViewBox.Sensitive = true;
@ -281,8 +277,7 @@ namespace Buypeeb {
UpdateItem(updateQueue.Dequeue()); UpdateItem(updateQueue.Dequeue());
if (updateQueue.TryPeek(out var _)) { if (updateQueue.TryPeek(out var _)) {
ProcessUpdateQueue(); ProcessUpdateQueue();
} } else {
else {
queueActive = false; queueActive = false;
} }
} }
@ -302,14 +297,10 @@ namespace Buypeeb {
// don't start a new task if there are more than `tasklimit` tasks currently running // don't start a new task if there are more than `tasklimit` tasks currently running
// this makes sure we don't make 1000 simultaneous requests to yahoo auctions if there are 1000 items on the watchlist // this makes sure we don't make 1000 simultaneous requests to yahoo auctions if there are 1000 items on the watchlist
taskLimit.Wait(); taskLimit.Wait();
Task.Factory.StartNew(() => { Task.Factory.StartNew(() => { UpdateThread(id); }).ContinueWith(task => {
UpdateThread(id);
}).ContinueWith(task => {
taskLimit.Release(); taskLimit.Release();
if (renderListWhenDone) { if (renderListWhenDone) {
Application.Invoke(delegate { Application.Invoke(delegate { RenderList(); });
RenderList();
});
} }
}); });
} }
@ -338,10 +329,7 @@ namespace Buypeeb {
} }
itemTreeView.QueueDraw(); itemTreeView.QueueDraw();
Task.Factory.StartNew(() => { Task.Factory.StartNew(() => { ProcessUpdateQueue(); });
ProcessUpdateQueue();
});
} }
/// <summary> /// <summary>
@ -350,7 +338,7 @@ namespace Buypeeb {
private void UpdateSelectionView() { private void UpdateSelectionView() {
// get the currently selected item // get the currently selected item
var item = selectedItem; var item = selectedItem;
var infobox = (Box)builder.GetObject("SelectionInfoBox"); var infobox = (Box) builder.GetObject("SelectionInfoBox");
if (item == null) { if (item == null) {
selectionViewBox.Sensitive = false; selectionViewBox.Sensitive = false;
@ -363,30 +351,30 @@ namespace Buypeeb {
infobox.Visible = true; infobox.Visible = true;
var info = new Dictionary<string, string> { var info = new Dictionary<string, string> {
{ "Name", item.name }, {"Name", item.name},
{ "YahooName", item.originalName }, {"YahooName", item.originalName},
{ "Price", item.priceJpy }, {"Price", item.priceJpy},
{ "PriceAUD", item.priceAud }, {"PriceAUD", item.priceAud},
{ "Ending", "Please wait..." }, {"Ending", "Please wait..."},
{ "Bids", $"{item.Bids}" }, {"Bids", $"{item.Bids}"},
{ "BuyItNow", item.WinPrice == 0 ? "No" : $"{item.winPriceJpy} ({item.winPriceAud})" }, {"BuyItNow", item.WinPrice == 0 ? "No" : $"{item.winPriceJpy} ({item.winPriceAud})"},
{ "AutoExtension", item.AutoExtension ? "Yes" : "No" }, {"AutoExtension", item.AutoExtension ? "Yes" : "No"},
{ "LastUpdated", $"Last updated: {(item.Ready ? item.LastUpdated.ToString("MMM dd, HH:mm:ss") : "Right now!")}" }, {"LastUpdated", $"Last updated: {(item.Ready ? item.LastUpdated.ToString("MMM dd, HH:mm:ss") : "Right now!")}"},
}; };
foreach (var row in info) { foreach (var row in info) {
((Label) builder.GetObject($"LabelSelected{row.Key}")).Text = row.Value; ((Label) builder.GetObject($"LabelSelected{row.Key}")).Text = row.Value;
} }
UpdateSelectionEndTime(); UpdateSelectionEndTime();
var noteBuffer = (TextBuffer)builder.GetObject("TextBufferSelectedNotes"); var noteBuffer = (TextBuffer) builder.GetObject("TextBufferSelectedNotes");
noteBuffer.Clear(); noteBuffer.Clear();
if (!String.IsNullOrWhiteSpace(item.notes)) { if (!string.IsNullOrWhiteSpace(item.notes)) {
noteBuffer.Text = item.notes; noteBuffer.Text = item.notes;
} }
((ToggleButton) builder.GetObject("ButtonSelectedFavourite")).Active = item.favourite; ((ToggleButton) builder.GetObject("ButtonSelectedFavourite")).Active = item.favourite;
} }
/// <summary> /// <summary>
@ -401,8 +389,7 @@ namespace Buypeeb {
UseShellExecute = true, UseShellExecute = true,
}; };
Process.Start(psi); Process.Start(psi);
} } else {
else {
// let's hope you have xdg-open installed // let's hope you have xdg-open installed
Process.Start("xdg-open", url); Process.Start("xdg-open", url);
} }
@ -421,11 +408,7 @@ namespace Buypeeb {
type: MessageType.Question, type: MessageType.Question,
bt: buttonsType, bt: buttonsType,
format: message format: message
); ) {KeepAbove = true, Resizable = false, FocusOnMap = true, Title = "Buypeeb"};
md.KeepAbove = true;
md.Resizable = false;
md.FocusOnMap = true;
md.Title = "Buypeeb";
return md; return md;
} }
@ -437,22 +420,23 @@ namespace Buypeeb {
/// <param name="message">the prompt that should be presented to the user</param> /// <param name="message">the prompt that should be presented to the user</param>
/// <param name="prefill">a string to prefill the input box with</param> /// <param name="prefill">a string to prefill the input box with</param>
/// <returns></returns> /// <returns></returns>
private (Boolean accepted, string response) EntryDialogue(string title = "Buypeeb", string message = "Hi there!", string prefill = null) { private (bool accepted, string response) EntryDialogue(
string title = "Buypeeb", string message = "Hi there!", string prefill = null
) {
var ed = new Dialog( var ed = new Dialog(
title: title, title: title,
parent: this, parent: this,
flags: DialogFlags.DestroyWithParent | DialogFlags.Modal, flags: DialogFlags.DestroyWithParent | DialogFlags.Modal,
/* button_data: */ "Cancel", ResponseType.Cancel, "OK", ResponseType.Ok /* button_data: */ "Cancel", ResponseType.Cancel, "OK", ResponseType.Ok
); ) {DefaultResponse = ResponseType.Ok, KeepAbove = true};
ed.DefaultResponse = ResponseType.Ok;
ed.KeepAbove = true;
var edLabel = new Label(message); var edLabel = new Label(message);
var edEntry = new Entry(); var edEntry = new Entry();
if (!String.IsNullOrWhiteSpace(prefill)) { if (!string.IsNullOrWhiteSpace(prefill)) {
edEntry.Text = prefill; edEntry.Text = prefill;
} }
edEntry.ActivatesDefault = true; edEntry.ActivatesDefault = true;
ed.ContentArea.PackStart(edLabel, true, true, 2); ed.ContentArea.PackStart(edLabel, true, true, 2);
@ -466,7 +450,7 @@ namespace Buypeeb {
ed.ContentArea.MarginEnd = 5; ed.ContentArea.MarginEnd = 5;
ed.MarginBottom = 5; ed.MarginBottom = 5;
var accepted = (ResponseType)ed.Run(); var accepted = (ResponseType) ed.Run();
var response = edEntry.Text; var response = edEntry.Text;
ed.Dispose(); ed.Dispose();
return (accepted == ResponseType.Ok, response); return (accepted == ResponseType.Ok, response);
@ -477,8 +461,10 @@ namespace Buypeeb {
/// </summary> /// </summary>
/// <returns>the id of the radiobutton without the "Sort" prefix</returns> /// <returns>the id of the radiobutton without the "Sort" prefix</returns>
private string GetSortType() { private string GetSortType() {
foreach (var name in new List<string> { "NameDescending", "NameAscending", "PriceDescending", "PriceAscending", "EndingDescending", "EndingAscending" }) { foreach (var name in new List<string> {
var radio = (RadioMenuItem)builder.GetObject($"Sort{name}"); "NameDescending", "NameAscending", "PriceDescending", "PriceAscending", "EndingDescending", "EndingAscending"
}) {
var radio = (RadioMenuItem) builder.GetObject($"Sort{name}");
if (radio.Active) { if (radio.Active) {
return name; return name;
} }
@ -502,20 +488,15 @@ namespace Buypeeb {
var type = GetSortType(); var type = GetSortType();
if (type == "NameDescending") { if (type == "NameDescending") {
sorted = values.OrderByDescending(item => item.name); sorted = values.OrderByDescending(item => item.name);
} } else if (type == "NameAscending") {
else if (type == "NameAscending") {
sorted = values.OrderBy(item => item.name); sorted = values.OrderBy(item => item.name);
} } else if (type == "PriceDescending") {
else if (type == "PriceDescending") {
sorted = values.OrderByDescending(item => item.Price); sorted = values.OrderByDescending(item => item.Price);
} } else if (type == "PriceAscending") {
else if (type == "PriceAscending") {
sorted = values.OrderBy(item => item.Price); sorted = values.OrderBy(item => item.Price);
} } else if (type == "EndingDescending") {
else if (type == "EndingDescending") {
sorted = values.OrderByDescending(item => item.endDate); sorted = values.OrderByDescending(item => item.endDate);
} } else {
else {
sorted = values.OrderBy(item => item.endDate); sorted = values.OrderBy(item => item.endDate);
} }
@ -527,8 +508,7 @@ namespace Buypeeb {
foreach (var item in sorted.Where(item => !item.favourite)) { foreach (var item in sorted.Where(item => !item.favourite)) {
items.AppendValues(item); items.AppendValues(item);
} }
} } else {
else {
foreach (var item in sorted) { foreach (var item in sorted) {
items.AppendValues(item); items.AppendValues(item);
} }
@ -536,7 +516,9 @@ namespace Buypeeb {
((TreeModelFilter) itemTreeView.Model).Refilter(); ((TreeModelFilter) itemTreeView.Model).Refilter();
if (id == null) { return; } if (id == null) {
return;
}
// attempt to reselect the item we were just looking at // attempt to reselect the item we were just looking at
// ReSharper disable once UseDeconstruction // ReSharper disable once UseDeconstruction
@ -562,8 +544,7 @@ namespace Buypeeb {
if (rx.IsMatch(url)) { if (rx.IsMatch(url)) {
UpdateItem(settings.Watch(url, name).id, true); UpdateItem(settings.Watch(url, name).id, true);
RenderList(); RenderList();
} } else {
else {
var md = MsgBox($"\"{url}\" is not a valid Buyee or Yahoo! Auctions Japan URL.", ButtonsType.Ok); var md = MsgBox($"\"{url}\" is not a valid Buyee or Yahoo! Auctions Japan URL.", ButtonsType.Ok);
md.Run(); md.Run();
md.Dispose(); md.Dispose();
@ -576,7 +557,7 @@ namespace Buypeeb {
private void ButtonClearEndedClicked(object sender, EventArgs a) { private void ButtonClearEndedClicked(object sender, EventArgs a) {
var md = MsgBox("Are you sure you want to remove all ended auctions from the list?"); var md = MsgBox("Are you sure you want to remove all ended auctions from the list?");
var r = (ResponseType)md.Run(); var r = (ResponseType) md.Run();
md.Dispose(); md.Dispose();
if (r != ResponseType.Ok) { if (r != ResponseType.Ok) {
return; return;
@ -598,10 +579,11 @@ namespace Buypeeb {
private void ButtonClearAllClicked(object sender, EventArgs a) { private void ButtonClearAllClicked(object sender, EventArgs a) {
var md = MsgBox("Are you sure you want to clear ALL items?"); var md = MsgBox("Are you sure you want to clear ALL items?");
if (md.Run() == (int)ResponseType.Ok) { if (md.Run() == (int) ResponseType.Ok) {
settings.watchlist.Clear(); settings.watchlist.Clear();
RenderList(); RenderList();
} }
md.Dispose(); md.Dispose();
} }
@ -619,20 +601,20 @@ namespace Buypeeb {
odf.AddPattern("*.json"); odf.AddPattern("*.json");
od.AddFilter(odf); od.AddFilter(odf);
if (od.Run() == (int)ResponseType.Accept) { if (od.Run() == (int) ResponseType.Accept) {
try { try {
var j = File.ReadAllText(od.Filename); var j = File.ReadAllText(od.Filename);
settings = JsonSerializer.Deserialize<Settings>(j); settings = JsonSerializer.Deserialize<Settings>(j);
RenderList(); RenderList();
UpdateItems(); UpdateItems();
} } catch (Exception e) {
catch (Exception e) {
Console.WriteLine(e); Console.WriteLine(e);
var md = MsgBox($"Failed to load {od.Filename}!\n{e.Message}", ButtonsType.Ok); var md = MsgBox($"Failed to load {od.Filename}!\n{e.Message}", ButtonsType.Ok);
md.Run(); md.Run();
md.Dispose(); md.Dispose();
} }
} }
od.Dispose(); od.Dispose();
} }
@ -649,21 +631,19 @@ namespace Buypeeb {
); );
sd.CurrentName = "userdata.json"; sd.CurrentName = "userdata.json";
var sdf = new FileFilter(); var sdf = new FileFilter {Name = "JSON files"};
sdf.Name = "JSON files";
sdf.AddMimeType("application/json"); sdf.AddMimeType("application/json");
sdf.AddPattern("*.json"); sdf.AddPattern("*.json");
sd.AddFilter(sdf); sd.AddFilter(sdf);
if (sd.Run() == (int)ResponseType.Accept) { if (sd.Run() == (int) ResponseType.Accept) {
try { try {
if (!File.Exists(sd.Filename)) { if (!File.Exists(sd.Filename)) {
using (var fs = File.CreateText(sd.Filename)) { using (var fs = File.CreateText(sd.Filename)) {
fs.Write(JsonSerializer.Serialize(settings, jsonOptions)); fs.Write(JsonSerializer.Serialize(settings, jsonOptions));
} }
} }
} } catch (Exception e) {
catch (Exception e) {
Console.WriteLine(e); Console.WriteLine(e);
var md = MsgBox($"Failed to write {sd.Filename}!\n{e.Message}.", ButtonsType.Ok); var md = MsgBox($"Failed to write {sd.Filename}!\n{e.Message}.", ButtonsType.Ok);
md.Run(); md.Run();
@ -698,15 +678,13 @@ namespace Buypeeb {
sdf.AddPattern("*.csv"); sdf.AddPattern("*.csv");
sd.AddFilter(sdf); sd.AddFilter(sdf);
if (sd.Run() == (int)ResponseType.Accept) { if (sd.Run() == (int) ResponseType.Accept) {
try { try {
using (var writer = new StreamWriter(sd.Filename)) using (var writer = new StreamWriter(sd.Filename))
using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture)) { using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture)) {
csv.WriteRecords(settings.watchlist); csv.WriteRecords(settings.watchlist);
} }
} } catch (Exception e) {
catch (Exception e) {
Console.WriteLine(e); Console.WriteLine(e);
var md = MsgBox($"Failed to write {sd.Filename}!\n{e.Message}.", ButtonsType.Ok); var md = MsgBox($"Failed to write {sd.Filename}!\n{e.Message}.", ButtonsType.Ok);
md.Run(); md.Run();
@ -722,10 +700,12 @@ namespace Buypeeb {
foreach (var item in settings.watchlist) { foreach (var item in settings.watchlist) {
Console.WriteLine(item); Console.WriteLine(item);
} }
Console.WriteLine("---\nFilter results:"); Console.WriteLine("---\nFilter results:");
foreach (var item in filterQuery) { foreach (var item in filterQuery) {
Console.WriteLine(item); Console.WriteLine(item);
} }
Console.WriteLine("---\nListstore contents:"); Console.WriteLine("---\nListstore contents:");
foreach (object[] item in items) { foreach (object[] item in items) {
Console.WriteLine(item[0]); Console.WriteLine(item[0]);
@ -735,7 +715,7 @@ namespace Buypeeb {
private void ButtonQuitClicked(object sender, EventArgs a) { private void ButtonQuitClicked(object sender, EventArgs a) {
var md = MsgBox("Are you sure you want to quit?"); var md = MsgBox("Are you sure you want to quit?");
var response = (ResponseType)md.Run(); var response = (ResponseType) md.Run();
md.Dispose(); md.Dispose();
if (response == ResponseType.Ok) { if (response == ResponseType.Ok) {
SaveSettings(); SaveSettings();
@ -765,9 +745,11 @@ namespace Buypeeb {
private void ButtonSelectedRemoveClicked(object sender, EventArgs a) { private void ButtonSelectedRemoveClicked(object sender, EventArgs a) {
var item = selectedItem; var item = selectedItem;
var md = MsgBox($"Are you sure you want to remove the item \"{item.name}\"?"); // TODO: this looks bad being all on one line var md = MsgBox(
$"Are you sure you want to remove the item \"{item.name}\"?"
);
var response = (ResponseType)md.Run(); var response = (ResponseType) md.Run();
md.Dispose(); md.Dispose();
if (response == ResponseType.Ok) { if (response == ResponseType.Ok) {
settings.watchlist.Remove(item.id); settings.watchlist.Remove(item.id);
@ -777,7 +759,10 @@ namespace Buypeeb {
private void ButtonSelectedRenameClicked(object sender, EventArgs a) { private void ButtonSelectedRenameClicked(object sender, EventArgs a) {
var item = selectedItem; var item = selectedItem;
(var accepted, var response) = EntryDialogue("Rename item", $"Enter a new name for the item \"{item.name}\".", item.name); var (accepted, response) = EntryDialogue(
"Rename item", $"Enter a new name for the item \"{item.name}\".", item.name
);
if (accepted) { if (accepted) {
item.name = response; item.name = response;
UpdateSelectionView(); UpdateSelectionView();
@ -790,17 +775,17 @@ namespace Buypeeb {
// the item is already waiting to be updated // the item is already waiting to be updated
return; return;
} }
UpdateItem(selectedItem.id); UpdateItem(selectedItem.id);
} }
private void ButtonSelectedFavouriteToggled(object sender, EventArgs args) { private void ButtonSelectedFavouriteToggled(object sender, EventArgs args) {
var s = (ToggleButton)sender; var s = (ToggleButton) sender;
selectedItem.favourite = s.Active; selectedItem.favourite = s.Active;
if (settings.showFavouritesAtTopOfList) { if (settings.showFavouritesAtTopOfList) {
RenderList(); RenderList();
} } else {
else {
// i don't know why this is necessary // i don't know why this is necessary
var pathAndIter = GetRow(selectedItem.id); var pathAndIter = GetRow(selectedItem.id);
if (pathAndIter.path != null) { if (pathAndIter.path != null) {
@ -812,20 +797,21 @@ namespace Buypeeb {
private void ButtonSelectedNotesClearClicked(object sender, EventArgs args) { private void ButtonSelectedNotesClearClicked(object sender, EventArgs args) {
var item = selectedItem; var item = selectedItem;
var md = MsgBox($"Are you sure you want to clear the notes for \"{item.name}\"?"); var md = MsgBox($"Are you sure you want to clear the notes for \"{item.name}\"?");
if (md.Run() == (int)ResponseType.Ok) { if (md.Run() == (int) ResponseType.Ok) {
var noteBuffer = (TextBuffer)builder.GetObject("TextBufferSelectedNotes"); var noteBuffer = (TextBuffer) builder.GetObject("TextBufferSelectedNotes");
noteBuffer.Clear(); noteBuffer.Clear();
selectedItem.notes = null; selectedItem.notes = null;
} }
md.Dispose(); md.Dispose();
} }
private void TextViewSelectedNotesFocusOut(object sender, FocusOutEventArgs args) { private void TextViewSelectedNotesFocusOut(object sender, FocusOutEventArgs args) {
// the "save" button does nothing, however, when you click the save button, you transfer focus to it, firing this event! // the "save" button does nothing, however, when you click the save button, you transfer focus to it, firing this event!
// how very sneaky // how very sneaky
var noteBuffer = (TextBuffer)builder.GetObject("TextBufferSelectedNotes"); var noteBuffer = (TextBuffer) builder.GetObject("TextBufferSelectedNotes");
if (selectedItem != null) { if (selectedItem != null) {
selectedItem.notes = String.IsNullOrWhiteSpace(noteBuffer.Text) ? null : noteBuffer.Text; selectedItem.notes = string.IsNullOrWhiteSpace(noteBuffer.Text) ? null : noteBuffer.Text;
} }
} }
@ -862,12 +848,12 @@ namespace Buypeeb {
if (span.Days > 0) { if (span.Days > 0) {
ending += span.ToString("dd' days, '"); // will format twelve days as "12 days, " 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 // 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 // `HH` doesn't exist, but `hh` behaves identically
// see https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-timespan-format-strings // see https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-timespan-format-strings
ending += span.ToString(@"hh\:mm\:ss"); ending += span.ToString(@"hh\:mm\:ss");
} } else {
else {
ending = "Auction has ended"; ending = "Auction has ended";
} }
@ -899,34 +885,39 @@ namespace Buypeeb {
// column renderers // column renderers
private void RenderColumnFavourite(TreeViewColumn column, CellRenderer cell, ITreeModel model, TreeIter iter) { private static void RenderColumnFavourite(
var item = (YahooAuctionsItem)model.GetValue(iter, 0); TreeViewColumn column, CellRenderer cell, ITreeModel model, TreeIter iter
) {
var item = (YahooAuctionsItem) model.GetValue(iter, 0);
((CellRendererText) cell).Text = item.favourite ? "♥" : ""; ((CellRendererText) cell).Text = item.favourite ? "♥" : "";
} }
private void RenderColumnName(TreeViewColumn column, CellRenderer cell, ITreeModel model, TreeIter iter) { private static void RenderColumnName(TreeViewColumn column, CellRenderer cell, ITreeModel model, TreeIter iter) {
var item = (YahooAuctionsItem)model.GetValue(iter, 0); var item = (YahooAuctionsItem) model.GetValue(iter, 0);
((CellRendererText) cell).Text = item.name ?? "Loading..."; ((CellRendererText) cell).Text = item.name ?? "Loading...";
} }
private void RenderColumnPriceYen(TreeViewColumn column, CellRenderer cell, ITreeModel model, TreeIter iter) { private static void RenderColumnPriceYen(
var item = (YahooAuctionsItem)model.GetValue(iter, 0); TreeViewColumn column, CellRenderer cell, ITreeModel model, TreeIter iter
) {
var item = (YahooAuctionsItem) model.GetValue(iter, 0);
((CellRendererText) cell).Text = item.Ready ? item.priceJpy : "..."; ((CellRendererText) cell).Text = item.Ready ? item.priceJpy : "...";
} }
private void RenderColumnPriceAUD(TreeViewColumn column, CellRenderer cell, ITreeModel model, TreeIter iter) { private static void RenderColumnPriceAUD(
var item = (YahooAuctionsItem)model.GetValue(iter, 0); TreeViewColumn column, CellRenderer cell, ITreeModel model, TreeIter iter
) {
var item = (YahooAuctionsItem) model.GetValue(iter, 0);
((CellRendererText) cell).Text = item.Ready ? item.priceAud : "..."; ((CellRendererText) cell).Text = item.Ready ? item.priceAud : "...";
} }
private void RenderColumnEnding(TreeViewColumn column, CellRenderer cell, ITreeModel model, TreeIter iter) { private void RenderColumnEnding(TreeViewColumn column, CellRenderer cell, ITreeModel model, TreeIter iter) {
var item = (YahooAuctionsItem)model.GetValue(iter, 0); var item = (YahooAuctionsItem) model.GetValue(iter, 0);
var ending = ""; var ending = "";
if (item.Ready) { if (item.Ready) {
if (!item.Available) { if (!item.Available) {
ending = "Ended"; ending = "Ended";
} } else {
else {
var now = DateTime.Now; var now = DateTime.Now;
var end = item.endDate.ToLocalTime(); var end = item.endDate.ToLocalTime();
// TODO: should we show the year if the auction ends next year? 0uo // TODO: should we show the year if the auction ends next year? 0uo
@ -934,6 +925,7 @@ namespace Buypeeb {
// the auction isn't ending today, so we should show the day it's ending on for clarity // the auction isn't ending today, so we should show the day it's ending on for clarity
ending += end.ToString("MMM d "); ending += end.ToString("MMM d ");
} }
ending += end.ToString("HH:mm"); ending += end.ToString("HH:mm");
if (settings.showSecondsInListView) { if (settings.showSecondsInListView) {
// add the seconds on to the end // add the seconds on to the end
@ -941,16 +933,18 @@ namespace Buypeeb {
} }
} }
} }
((CellRendererText) cell).Text = item.Ready ? ending : "..."; ((CellRendererText) cell).Text = item.Ready ? ending : "...";
} }
// tree filter // tree filter
private bool ItemFilter(ITreeModel model, TreeIter iter) { private bool ItemFilter(ITreeModel model, TreeIter iter) {
var item = (YahooAuctionsItem)model.GetValue(iter, 0); var item = (YahooAuctionsItem) model.GetValue(iter, 0);
if (item == null) { if (item == null) {
return true; return true;
} }
if (item.Price == 0) { if (item.Price == 0) {
// the item has only just been added, so we can't compare it against the filters, since it's missing most of its data // the item has only just been added, so we can't compare it against the filters, since it's missing most of its data
return true; return true;

View File

@ -11,9 +11,7 @@ namespace Buypeeb {
public bool autosave { get; set; } = true; public bool autosave { get; set; } = true;
public bool showFavouritesAtTopOfList { get; set; } = true; public bool showFavouritesAtTopOfList { get; set; } = true;
public Dictionary<string, YahooAuctionsItem> watchlist { public Dictionary<string, YahooAuctionsItem> watchlist { get; set; }
get; set;
}
public Settings() { public Settings() {
// create a new watchlist from an empty dictionary if it's null, which should only happen if either this is the // create a new watchlist from an empty dictionary if it's null, which should only happen if either this is the
@ -34,10 +32,10 @@ namespace Buypeeb {
int seconds; int seconds;
if (item.favourite) { if (item.favourite) {
seconds = item.endingSoon ? favouriteUpdateIntervalCritical : favouriteUpdateInterval; seconds = item.endingSoon ? favouriteUpdateIntervalCritical : favouriteUpdateInterval;
} } else {
else {
seconds = item.endingSoon ? updateIntervalCritical : updateInterval; seconds = item.endingSoon ? updateIntervalCritical : updateInterval;
} }
var later = item.LastUpdated.AddSeconds(seconds); var later = item.LastUpdated.AddSeconds(seconds);
return DateTime.Compare(later, DateTime.UtcNow) < 0; return DateTime.Compare(later, DateTime.UtcNow) < 0;
} }

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Gtk; using Gtk;
// ReSharper disable UnusedMember.Local // ReSharper disable UnusedMember.Local
// ReSharper disable UnusedParameter.Local // ReSharper disable UnusedParameter.Local
@ -11,10 +12,14 @@ namespace Buypeeb {
private readonly Settings settings; private readonly Settings settings;
private readonly Builder builder; private readonly Builder builder;
private readonly List<string> generalSwitchNames = new List<string> { "ShowSecondsInListView", "Autosave", "ShowFavouritesAtTopOfList" }; private readonly List<string> generalSwitchNames = new List<string>
private readonly List<string> updateIntervalEntryNames = new List<string> { "UpdateInterval", "UpdateIntervalCritical", "FavouriteUpdateInterval", "FavouriteUpdateIntervalCritical" }; {"ShowSecondsInListView", "Autosave", "ShowFavouritesAtTopOfList"};
public SettingsWindow(Settings settings) : this(new Builder("settings.glade"), settings) { } private readonly List<string> updateIntervalEntryNames = new List<string>
{"UpdateInterval", "UpdateIntervalCritical", "FavouriteUpdateInterval", "FavouriteUpdateIntervalCritical"};
public SettingsWindow(Settings settings) : this(new Builder("settings.glade"), settings) {
}
private SettingsWindow(Builder builder, Settings settings) : base(builder.GetObject("WindowSettings").Handle) { private SettingsWindow(Builder builder, Settings settings) : base(builder.GetObject("WindowSettings").Handle) {
Title = "Buypeeb - Settings"; Title = "Buypeeb - Settings";
@ -23,20 +28,20 @@ namespace Buypeeb {
builder.Autoconnect(this); builder.Autoconnect(this);
foreach (var name in generalSwitchNames) { foreach (var name in generalSwitchNames) {
var s = (Switch)builder.GetObject($"Switch{name}"); var s = (Switch) builder.GetObject($"Switch{name}");
generalSwitches.Add(s); generalSwitches.Add(s);
s.Active = GetSetting<bool>(PropertyName(name)); s.Active = GetSetting<bool>(PropertyName(name));
} }
foreach (var name in updateIntervalEntryNames) { foreach (var name in updateIntervalEntryNames) {
var e = (Entry)builder.GetObject($"Entry{name}"); var e = (Entry) builder.GetObject($"Entry{name}");
updateIntervalEntries.Add(e); updateIntervalEntries.Add(e);
e.Text = GetSetting<int>(PropertyName(name)).ToString(); e.Text = GetSetting<int>(PropertyName(name)).ToString();
} }
} }
private T GetSetting<T>(string property) { private T GetSetting<T>(string property) {
return (T)settings.GetType().GetProperty(property).GetValue(settings, null); return (T) settings.GetType().GetProperty(property).GetValue(settings, null);
} }
private void SetSetting<T>(string property, T value) { private void SetSetting<T>(string property, T value) {
@ -52,11 +57,10 @@ namespace Buypeeb {
// first, validate all the intervals // first, validate all the intervals
var failed = false; var failed = false;
foreach (var name in updateIntervalEntryNames) { foreach (var name in updateIntervalEntryNames) {
var e = (Entry)builder.GetObject($"Entry{name}"); var e = (Entry) builder.GetObject($"Entry{name}");
if (!int.TryParse(e.Text, out var result)) { if (!int.TryParse(e.Text, out var result)) {
failed = true; failed = true;
} } else {
else {
if (result < 30 || result > 6000) { if (result < 30 || result > 6000) {
failed = true; failed = true;
} }
@ -66,7 +70,8 @@ namespace Buypeeb {
continue; continue;
} }
var md = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, "Update intervals must be a whole number between 30 and 6000."); var md = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok,
"Update intervals must be a whole number between 30 and 6000.");
md.Run(); md.Run();
md.Dispose(); md.Dispose();
return; return;
@ -81,6 +86,7 @@ namespace Buypeeb {
foreach (var name in generalSwitchNames) { foreach (var name in generalSwitchNames) {
SetSetting(PropertyName(name), ((Switch) builder.GetObject($"Switch{name}")).Active); SetSetting(PropertyName(name), ((Switch) builder.GetObject($"Switch{name}")).Active);
} }
Dispose(); Dispose();
} }
@ -88,4 +94,4 @@ namespace Buypeeb {
Dispose(); Dispose();
} }
} }
} }

View File

@ -8,11 +8,9 @@ using CsvHelper.Configuration.Attributes;
namespace Buypeeb { namespace Buypeeb {
internal class YahooAuctionsItem { internal class YahooAuctionsItem {
[JsonIgnore] [JsonIgnore] public string url => $"https://page.auctions.yahoo.co.jp/jp/auction/{id}";
public string url => $"https://page.auctions.yahoo.co.jp/jp/auction/{id}";
[JsonIgnore] [JsonIgnore] public string buyeeUrl => $"https://buyee.jp/item/yahoo/auction/{id}";
public string buyeeUrl => $"https://buyee.jp/item/yahoo/auction/{id}";
// any items with a getter will be saved to userdata.json // any items with a getter will be saved to userdata.json
// anything that's configurable by the user, such as the custom name, should be saved // anything that's configurable by the user, such as the custom name, should be saved
@ -20,8 +18,7 @@ namespace Buypeeb {
// i'm also saving the original name to make it easier to tell what the items are in the userdata.json // i'm also saving the original name to make it easier to tell what the items are in the userdata.json
// there's not really a need for it i guess but it's my program and i can do what i want // there's not really a need for it i guess but it's my program and i can do what i want
// anything with the attribute [Ignore] won't be put in the CSV, and things with [JsonIgnore] won't be put in userdata.json // anything with the attribute [Ignore] won't be put in the CSV, and things with [JsonIgnore] won't be put in userdata.json
[Ignore] [Ignore] public string id { get; }
public string id { get; }
public string name { get; set; } public string name { get; set; }
public int Price; public int Price;
public int WinPrice; public int WinPrice;
@ -44,26 +41,19 @@ namespace Buypeeb {
} }
} }
[JsonIgnore] [JsonIgnore] public string priceJpy => $"¥{Price}";
public string priceJpy => $"¥{Price}";
[JsonIgnore] [JsonIgnore] public string winPriceJpy => $"¥{WinPrice}";
public string winPriceJpy => $"¥{WinPrice}";
[Ignore, JsonIgnore] [Ignore, JsonIgnore] public string priceAud => $"${(Price / 75.0):f2}";
public string priceAud => $"${(Price / 75.0):f2}";
[Ignore, JsonIgnore] [Ignore, JsonIgnore] public string winPriceAud => $"${(WinPrice / 75.0):f2}";
public string winPriceAud => $"${(WinPrice / 75.0):f2}";
[Ignore, JsonIgnore] [Ignore, JsonIgnore] public bool endingToday => endDate.DayOfYear == DateTime.UtcNow.DayOfYear;
public bool endingToday => endDate.DayOfYear == DateTime.UtcNow.DayOfYear;
[Ignore, JsonIgnore] [Ignore, JsonIgnore] public bool hasWinPrice => WinPrice != 0;
public bool hasWinPrice => WinPrice != 0;
[Ignore, JsonIgnore] [Ignore, JsonIgnore] public bool endingSoon => DateTime.Compare(DateTime.UtcNow.AddMinutes(10), endDate) > 0;
public bool endingSoon => DateTime.Compare(DateTime.UtcNow.AddMinutes(10), endDate) > 0;
private bool success { get; set; } // TODO: custom setter that throws an exception if set to false or something idk private bool success { get; set; } // TODO: custom setter that throws an exception if set to false or something idk
@ -78,26 +68,29 @@ namespace Buypeeb {
public void Update(string html) { public void Update(string html) {
// TODO: handle all the parsing errors and weird interpretation that could possibly happen here // TODO: handle all the parsing errors and weird interpretation that could possibly happen here
var rx = new Regex(@"var pageData ?= ?(\{.+?\});", RegexOptions.Singleline); // TODO: maybe compile and match the regex in another thread var rx = new Regex(@"var pageData ?= ?(\{.+?\});",
RegexOptions.Singleline); // TODO: maybe compile and match the regex in another thread
var m = rx.Match(html); var m = rx.Match(html);
Dictionary<string, Dictionary<string, string>> jFull; Dictionary<string, Dictionary<string, string>> jFull;
try { try {
// master forgive me, but i must go all out, just this once... // master forgive me, but i must go all out, just this once...
jFull = JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, string>>>(m.Groups[1].Value); jFull = JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, string>>>(m.Groups[1].Value);
} } catch {
catch {
Console.WriteLine("oh jeez oh man oh jeez oh man oh jeez oh man"); Console.WriteLine("oh jeez oh man oh jeez oh man oh jeez oh man");
Console.WriteLine(m.Groups[1].Value); Console.WriteLine(m.Groups[1].Value);
throw; throw;
} }
var jst = TimeZoneInfo.CreateCustomTimeZone("JST", new TimeSpan(9, 0, 0), "Japan Standard Time", "Japen Standard Time"); var jst = TimeZoneInfo.CreateCustomTimeZone("JST", new TimeSpan(9, 0, 0), "Japan Standard Time",
"Japen Standard Time");
var j = jFull["items"]; var j = jFull["items"];
originalName = j["productName"]; originalName = j["productName"];
StartDate = TimeZoneInfo.ConvertTimeToUtc(DateTime.ParseExact(j["starttime"], "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture), jst); StartDate = TimeZoneInfo.ConvertTimeToUtc(
endDate = TimeZoneInfo.ConvertTimeToUtc(DateTime.ParseExact(j["endtime"], "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture), jst); DateTime.ParseExact(j["starttime"], "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture), jst);
endDate = TimeZoneInfo.ConvertTimeToUtc(
DateTime.ParseExact(j["endtime"], "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture), jst);
LastUpdated = DateTime.UtcNow; LastUpdated = DateTime.UtcNow;
Available = j["isClosed"] == "0"; Available = j["isClosed"] == "0";
@ -105,7 +98,7 @@ namespace Buypeeb {
success = int.TryParse(j["winPrice"], out WinPrice); success = int.TryParse(j["winPrice"], out WinPrice);
success = int.TryParse(j["bids"], out Bids); success = int.TryParse(j["bids"], out Bids);
if (String.IsNullOrWhiteSpace(name)) { if (string.IsNullOrWhiteSpace(name)) {
name = originalName; name = originalName;
} }