i am not good at c#
This commit is contained in:
parent
e52cc5d7d8
commit
b9b4253a5d
1 changed files with 27 additions and 10 deletions
|
@ -26,11 +26,11 @@ using Gtk;
|
|||
|
||||
namespace Buypeeb {
|
||||
public struct ItemColumns {
|
||||
public static int Name = 0;
|
||||
public static int PriceYen = 1;
|
||||
public static int PriceAUD = 2;
|
||||
public static int Ending = 3;
|
||||
public static int Id = 4;
|
||||
public const int Name = 0;
|
||||
public const int PriceYen = 1;
|
||||
public const int PriceAUD = 2;
|
||||
public const int Ending = 3;
|
||||
public const int Id = 4;
|
||||
}
|
||||
|
||||
class MainWindow : Window {
|
||||
|
@ -56,11 +56,28 @@ namespace Buypeeb {
|
|||
this.RenderList();
|
||||
|
||||
this.itemTreeView.Model = this.items;
|
||||
//TODO: make this less verbose
|
||||
this.itemTreeView.Columns[ItemColumns.Name].SetCellDataFunc(this.itemTreeView.Columns[ItemColumns.Name].Cells[0], new Gtk.TreeCellDataFunc(this.RenderColumnName));
|
||||
this.itemTreeView.Columns[ItemColumns.PriceYen].SetCellDataFunc(this.itemTreeView.Columns[ItemColumns.PriceYen].Cells[0], new Gtk.TreeCellDataFunc(this.RenderColumnPriceYen));
|
||||
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));
|
||||
for (int i = 0; i < this.itemTreeView.Columns.Length; i++) {
|
||||
var c = this.itemTreeView.Columns[i];
|
||||
var func = new Gtk.TreeCellDataFunc(this.RenderColumnName);
|
||||
|
||||
//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) {
|
||||
Console.WriteLine(row[0]);
|
||||
|
|
Loading…
Reference in a new issue