namespace MfGames.Eclectic.Gui { using Gtk; using MfGames.Eclectic; using System.Collections; /// /// Implements a basic selector (ComboBox) that automatically /// contains the list of all sources. /// public class SourceSelector : ComboBox { /// /// Constructs the selector with a metric which is used to prevent /// any loops. /// public SourceSelector() { // Create the model Model = (TreeModel) new ListStore(typeof(Source), typeof(string)); CellRendererText crt = new CellRendererText(); PackStart(crt, true); SetAttributes(crt, "text", 1); RebuildList(); } #region List /// /// Builds up the list of Balance metrics and populates it with /// the given value. /// private void RebuildList() { // Clear out the model ListStore store = (ListStore) Model; store.Clear(); // Go through the list ArrayList list = new ArrayList(Source.Find()); list.Sort(); foreach (Source bm in list) { // Add the values store.AppendValues(bm, bm.FullName); } // Show it ShowAll(); } #endregion } }