diff --git a/MainWindow.cs b/MainWindow.cs index ec8a869..bd96126 100755 --- a/MainWindow.cs +++ b/MainWindow.cs @@ -23,6 +23,7 @@ using System.Text.RegularExpressions; using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using System.Net; using Gtk; namespace Buypeeb { @@ -86,35 +87,20 @@ namespace Buypeeb { this.RenderList(); this.itemTreeView.Model = this.items; + TreeCellDataFunc[] funcs = { + new TreeCellDataFunc(this.RenderColumnName), + new TreeCellDataFunc(this.RenderColumnPriceYen), + new TreeCellDataFunc(this.RenderColumnPriceAUD), + new TreeCellDataFunc(this.RenderColumnEnding) + }; + for (int i = 0; i < this.itemTreeView.Columns.Length; i++) { var c = this.itemTreeView.Columns[i]; - TreeCellDataFunc func; - //TODO: get rid of this awful if statement - - if (i == ItemColumns.Name) { - func = new TreeCellDataFunc(this.RenderColumnName); - } - else if (i == ItemColumns.PriceYen) { - func = new TreeCellDataFunc(this.RenderColumnPriceYen); - } - else if (i == ItemColumns.PriceAUD) { - func = new TreeCellDataFunc(this.RenderColumnPriceAUD); - } - else if (i == ItemColumns.Ending) { - func = new TreeCellDataFunc(this.RenderColumnEnding); - } - else { - Console.WriteLine($"unexpected value {i}!"); - throw new IndexOutOfRangeException(); - } - - c.SetCellDataFunc(c.Cells[0], func); + c.SetCellDataFunc(c.Cells[0], funcs[i]); } - foreach (object[] row in this.items) { - Console.WriteLine(row[0]); - } + this.UpdateItems(); DeleteEvent += Window_Shutdown; }