i am not good at c#

This commit is contained in:
Lynne Megido 2020-09-03 16:34:42 +10:00
parent e52cc5d7d8
commit b9b4253a5d
Signed by: lynnesbian
GPG key ID: F0A184B5213D9F90

View file

@ -26,11 +26,11 @@ using Gtk;
namespace Buypeeb { namespace Buypeeb {
public struct ItemColumns { public struct ItemColumns {
public static int Name = 0; public const int Name = 0;
public static int PriceYen = 1; public const int PriceYen = 1;
public static int PriceAUD = 2; public const int PriceAUD = 2;
public static int Ending = 3; public const int Ending = 3;
public static int Id = 4; public const int Id = 4;
} }
class MainWindow : Window { class MainWindow : Window {
@ -56,11 +56,28 @@ namespace Buypeeb {
this.RenderList(); this.RenderList();
this.itemTreeView.Model = this.items; this.itemTreeView.Model = this.items;
//TODO: make this less verbose for (int i = 0; i < this.itemTreeView.Columns.Length; i++) {
this.itemTreeView.Columns[ItemColumns.Name].SetCellDataFunc(this.itemTreeView.Columns[ItemColumns.Name].Cells[0], new Gtk.TreeCellDataFunc(this.RenderColumnName)); var c = this.itemTreeView.Columns[i];
this.itemTreeView.Columns[ItemColumns.PriceYen].SetCellDataFunc(this.itemTreeView.Columns[ItemColumns.PriceYen].Cells[0], new Gtk.TreeCellDataFunc(this.RenderColumnPriceYen)); var func = new Gtk.TreeCellDataFunc(this.RenderColumnName);
this.itemTreeView.Columns[ItemColumns.PriceAUD].SetCellDataFunc(this.itemTreeView.Columns[ItemColumns.PriceAUD].Cells[0], new Gtk.TreeCellDataFunc(this.RenderColumnPriceAUD));
this.itemTreeView.Columns[ItemColumns.Ending].SetCellDataFunc(this.itemTreeView.Columns[ItemColumns.Ending].Cells[0], new Gtk.TreeCellDataFunc(this.RenderColumnEnding)); //TODO: get rid of this awful if statement
if (i == ItemColumns.PriceYen) {
func = new Gtk.TreeCellDataFunc(this.RenderColumnPriceYen);
}
else if (i == ItemColumns.PriceAUD) {
func = new Gtk.TreeCellDataFunc(this.RenderColumnPriceAUD);
}
else if (i == ItemColumns.Ending) {
func = new Gtk.TreeCellDataFunc(this.RenderColumnEnding);
}
else {
throw new IndexOutOfRangeException();
}
c.SetCellDataFunc(c.Cells[0], func);
}
foreach (object[] row in this.items) { foreach (object[] row in this.items) {
Console.WriteLine(row[0]); Console.WriteLine(row[0]);