Compare commits

..

No commits in common. "2da88f92f68cb0e8cd9d0b3b13ed5c56cc563eb4" and "ed759d8945ae65723872926f7655aa0bf7673472" have entirely different histories.

5 changed files with 59 additions and 279 deletions

1
.gitignore vendored
View file

@ -7,4 +7,3 @@ out/
yahoo.html
.vs/
/buypeeb.sln
\#*.glade#

View file

@ -108,11 +108,6 @@ namespace Buypeeb {
this.builder = builder;
builder.Autoconnect(this);
var menuButtonFilter = (MenuButton)builder.GetObject("MenuButtonFilter");
var menuButtonSort = (MenuButton)builder.GetObject("MenuButtonSort");
menuButtonFilter.Child = (Image)builder.GetObject("ImageFilter");
menuButtonSort.Child = (Image)builder.GetObject("ImageSort");
this.selectionViewBox = (Box)builder.GetObject("SelectionViewBox");
this.endingLabel = (Label)builder.GetObject("LabelSelectedEnding");
this.searchEntry = (SearchEntry)builder.GetObject("FilterSearchEntry");
@ -340,13 +335,6 @@ namespace Buypeeb {
var l = (Label)this.builder.GetObject($"LabelSelected{row.Key}");
l.Text = row.Value;
}
this.UpdateSelectionEndTime();
var noteBuffer = (TextBuffer)this.builder.GetObject("TextBufferSelectedNotes");
noteBuffer.Clear();
if (!String.IsNullOrWhiteSpace(item.notes)) {
noteBuffer.Text = item.notes;
}
var f = (ToggleButton)this.builder.GetObject("ButtonSelectedFavourite");
f.Active = item.favourite;
@ -419,56 +407,11 @@ namespace Buypeeb {
return (accepted == ResponseType.Ok, response);
}
private string GetSortType() {
foreach (var name in new List<string> { "NameDescending", "NameAscending", "PriceDescending", "PriceAscending", "EndingDescending", "EndingAscending" }) {
var radio = (RadioMenuItem)this.builder.GetObject($"Sort{name}");
if (radio.Active) {
return name;
}
}
return "NameAscending";
}
private void RenderList() {
this.items.Clear();
var values = this.settings.watchlist.Values;
IOrderedEnumerable<YahooAuctionsItem> sorted;
var type = this.GetSortType();
if (type == "NameDescending") {
sorted = values.OrderByDescending(item => item.name);
}
else if (type == "NameAscending") {
sorted = values.OrderBy(item => item.name);
}
else if (type == "PriceDescending") {
sorted = values.OrderByDescending(item => item.price);
}
else if (type == "PriceAscending") {
sorted = values.OrderBy(item => item.price);
}
else if (type == "EndingDescending") {
sorted = values.OrderByDescending(item => item.endDate);
}
else {
sorted = values.OrderBy(item => item.endDate);
}
if (settings.displayFavouritesAtTopOfList) {
foreach (var item in sorted.Where(item => item.favourite)) {
foreach (var item in this.settings.watchlist.Values) {
items.AppendValues(item);
}
foreach (var item in sorted.Where(item => !item.favourite)) {
items.AppendValues(item);
}
}
else {
foreach (var item in sorted) {
items.AppendValues(item);
}
}
var m = (TreeModelFilter)this.itemTreeView.Model;
m.Refilter();
}
@ -630,7 +573,6 @@ namespace Buypeeb {
try {
using (var writer = new StreamWriter(sd.Filename))
using (var csv = new CsvWriter(writer, System.Globalization.CultureInfo.InvariantCulture)) {
csv.WriteRecords(this.settings.watchlist);
}
}
@ -701,15 +643,6 @@ namespace Buypeeb {
ToggleButton s = (ToggleButton)sender;
this.selectedItem.favourite = s.Active;
if (this.settings.displayFavouritesAtTopOfList) {
var id = this.selectedItem.id;
// re-render the list, to ensure the favourites get pushed to the top
this.RenderList();
// attempt to reselect the item we were just looking at
var pathAndIter = this.GetRow(id);
this.itemTreeView.Selection.SelectPath(pathAndIter.path);
}
else {
// i don't know why this is necessary
var pathAndIter = this.GetRow(this.selectedItem.id);
if (pathAndIter.path != null) {
@ -717,32 +650,6 @@ namespace Buypeeb {
}
}
}
private void ButtonSelectedNotesClearClicked(object sender, EventArgs args) {
var item = this.selectedItem;
var md = this.MsgBox($"Are you sure you want to clear the notes for \"{item.name}\"?");
if (md.Run() == (int)ResponseType.Ok) {
var noteBuffer = (TextBuffer)this.builder.GetObject("TextBufferSelectedNotes");
noteBuffer.Clear();
this.selectedItem.notes = null;
}
md.Dispose();
}
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!
// how very sneaky
var noteBuffer = (TextBuffer)this.builder.GetObject("TextBufferSelectedNotes");
if (this.selectedItem != null) {
this.selectedItem.notes = String.IsNullOrWhiteSpace(noteBuffer.Text) ? null : noteBuffer.Text;
}
}
private void SortMenuClosed(object sender, EventArgs args) {
this.RenderList();
}
// timers
private bool UpdateSelectionEndTime() {

View file

@ -9,7 +9,6 @@ namespace Buypeeb {
public int updateIntervalCritical { get; set; } = 60;
public int favouriteUpdateIntervalCritical { get; set; } = 30;
public bool displaySecondsInList { get; set; } = true;
public bool displayFavouritesAtTopOfList { get; set; } = true;
public Dictionary<string, YahooAuctionsItem> watchlist {
get; set;

View file

@ -3,19 +3,15 @@ using System.Globalization;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using CsvHelper.Configuration.Attributes;
namespace Buypeeb {
class YahooAuctionsItem {
[JsonIgnore]
public string url {
get {
return $"https://page.auctions.yahoo.co.jp/jp/auction/{this.id}";
}
}
[JsonIgnore]
public string buyeeUrl {
get {
return $"https://buyee.jp/item/yahoo/auction/{this.id}";
@ -27,24 +23,21 @@ namespace Buypeeb {
// the id *must* be saved!
// 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
// anything with the attribute [Ignore] won't be put in the CSV, and things with [JsonIgnore] won't be put in userdata.json
[Ignore]
public string id { get; set; }
public string name { get; set; }
public int price = 0;
private int price = 0;
public int winPrice;
public string originalName { get; set; }
public string notes { get; set; }
public bool favourite { get; set; } = false;
public DateTime startDate;
public DateTime endDate { get; set; }
public DateTime endDate;
public DateTime lastUpdated;
public int bids;
public bool autoExtension;
public bool ready;
public bool available;
[Ignore, JsonIgnore]
public bool updatedRecently {
get {
var later = this.lastUpdated.AddSeconds(15);
@ -52,21 +45,15 @@ namespace Buypeeb {
}
}
[JsonIgnore]
// TODO: don't serialise this stuff
public string priceJPY { get { return $"¥{this.price}"; } }
[JsonIgnore]
public string winPriceJPY { get { return $"¥{this.winPrice}"; } }
[Ignore, JsonIgnore]
public string priceAUD { get { return $"${(this.price / 75.0):f2}"; } }
[Ignore, JsonIgnore]
public string winPriceAUD { get { return $"${(this.winPrice / 75.0):f2}"; } }
[Ignore, JsonIgnore]
public bool endingToday { get { return this.endDate.DayOfYear == DateTime.UtcNow.DayOfYear; } }
[Ignore, JsonIgnore]
public bool hasWinPrice { get { return this.winPrice != 0; } }
[Ignore, JsonIgnore]
public bool endingSoon { get { return DateTime.Compare(DateTime.UtcNow.AddMinutes(10), this.endDate) > 0; } }
private bool success { get; set; } // TODO: custom setter that throws an exception if set to false or something idk
public bool endingSoon { get { return DateTime.Compare(DateTime.UtcNow.AddMinutes(10), this.endDate) > 0; } }
public YahooAuctionsItem(string id, string name) {
this.id = id;

View file

@ -2,87 +2,6 @@
<!-- Generated with glade 3.36.0 -->
<interface>
<requires lib="gtk+" version="3.22"/>
<object class="GtkImage" id="ImageFilter">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">edit-find</property>
</object>
<object class="GtkImage" id="ImageSort">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">view-sort-ascending</property>
</object>
<object class="GtkRadioMenuItem" id="SortMenu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="draw_as_radio">True</property>
</object>
<object class="GtkMenu" id="menu1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<signal name="selection-done" handler="SortMenuClosed" swapped="no"/>
<child>
<object class="GtkRadioMenuItem" id="SortNameAscending">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Name, Ascending</property>
<property name="use_underline">True</property>
<property name="active">True</property>
<property name="draw_as_radio">True</property>
<property name="group">SortMenu</property>
</object>
</child>
<child>
<object class="GtkRadioMenuItem" id="SortNameDescending">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Name, Descending</property>
<property name="use_underline">True</property>
<property name="draw_as_radio">True</property>
<property name="group">SortMenu</property>
</object>
</child>
<child>
<object class="GtkRadioMenuItem" id="SortPriceAscending">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Price, low to high</property>
<property name="use_underline">True</property>
<property name="draw_as_radio">True</property>
<property name="group">SortMenu</property>
</object>
</child>
<child>
<object class="GtkRadioMenuItem" id="SortPriceDescending">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Price, high to low</property>
<property name="use_underline">True</property>
<property name="draw_as_radio">True</property>
<property name="group">SortMenu</property>
</object>
</child>
<child>
<object class="GtkRadioMenuItem" id="SortEndingAscending">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Ending soonest</property>
<property name="use_underline">True</property>
<property name="draw_as_radio">True</property>
<property name="group">SortMenu</property>
</object>
</child>
<child>
<object class="GtkRadioMenuItem" id="SortEndingDescending">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Ending latest</property>
<property name="use_underline">True</property>
<property name="draw_as_radio">True</property>
<property name="group">SortMenu</property>
</object>
</child>
</object>
<object class="GtkTextBuffer" id="TextBufferSelectedNotes"/>
<object class="GtkPopover" id="popover1">
<property name="can_focus">False</property>
@ -313,6 +232,48 @@
<property name="homogeneous">False</property>
</packing>
</child>
<child>
<object class="GtkToolButton">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Undo</property>
<property name="label" translatable="yes">Undo</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-undo</property>
<accelerator key="z" signal="clicked" modifiers="GDK_CONTROL_MASK"/>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Redo</property>
<property name="label" translatable="yes">Redo</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-redo</property>
<accelerator key="z" signal="clicked" modifiers="GDK_SHIFT_MASK | GDK_CONTROL_MASK"/>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkSeparatorToolItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="ButtonClearEnded">
<property name="visible">True</property>
@ -513,7 +474,7 @@
</packing>
</child>
<child>
<object class="GtkMenuButton" id="MenuButtonFilter">
<object class="GtkMenuButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="focus_on_click">False</property>
@ -529,24 +490,6 @@
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="MenuButtonSort">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="focus_on_click">False</property>
<property name="receives_default">True</property>
<property name="popup">menu1</property>
<property name="use_popover">False</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
@ -590,6 +533,7 @@
<property name="fixed_width">100</property>
<property name="title" translatable="yes">Name</property>
<property name="expand">True</property>
<property name="clickable">True</property>
<child>
<object class="GtkCellRendererText"/>
</child>
@ -1035,18 +979,9 @@
</child>
<child>
<object class="GtkExpander">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_start">3</property>
<property name="margin_end">3</property>
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkTextView">
<property name="height_request">100</property>
@ -1054,53 +989,6 @@
<property name="can_focus">True</property>
<property name="wrap_mode">word</property>
<property name="buffer">TextBufferSelectedNotes</property>
<signal name="focus-out-event" handler="TextViewSelectedNotesFocusOut" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Clear</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="ButtonSelectedNotesClearClicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Save</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child type="label">