namespace TACO.Widgets { using Gtk; using GtkSharp; using System; public class PartsPanel : Gtk.Table { private const uint COLUMNS = 2; private PartManager mManager = null; public PartsPanel(PartManager mgr) : base(COLUMNS, 1, false) { mManager = mgr; BorderWidth = 6; RowSpacing = 6; ColumnSpacing = 6; if (Manager.Parts.Count > 0) AddParts(); } private void AddParts() { uint count = (uint)Manager.Parts.Count; uint cols = Math.Min(COLUMNS, count); Console.WriteLine("Cols = {0}", cols); Resize(cols, (uint)Math.Ceiling((double)count / cols)); uint row = 0, col = 0; foreach (string key in Manager.Parts.Keys) { Part part = Manager.CreatePart(key, ""); Gtk.Button button = new Gtk.Button(part.Name); button.Show(); Attach(button, col, col + 1, row, row + 1, Gtk.AttachOptions.Fill | Gtk.AttachOptions.Expand, Gtk.AttachOptions.Fill, 0, 0); if (col == COLUMNS - 1) { row++; col = 0; } else { col++; } } } private PartManager Manager { get { return mManager; } } } }