Mercurial > repos > IBBoard.WarFoundry.GUI.GTK
view FrmChangeGameSystem.cs @ 6:cfc7683e73f9
Fix breakage from r33 by completing update of move to IBBoard.WarFoundry.GTK sub-packages
no-open-ticket
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 26 Jan 2009 20:16:07 +0000 |
parents | 65279b85446f |
children | a191d0655f55 |
line wrap: on
line source
// This file (FrmChangeGameSystem.cs) is a part of the IBBoard.WarFoundry.GTK project and is copyright 2009 IBBoard. // // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license. using System; using IBBoard.WarFoundry.API; using IBBoard.WarFoundry.API.Objects; using Gtk; using log4net; namespace IBBoard.WarFoundry.GTK { public partial class FrmChangeGameSystem : Dialog { private ILog logger = LogManager.GetLogger(typeof(FrmChangeGameSystem)); //private AbstractNativeWarFoundryFactory factory; private GameSystem selectedSystem; public FrmChangeGameSystem(Window parent) : base("Change Game System", parent, DialogFlags.Modal) { this.Build(); lstGameSystems.Selection.Changed+= new EventHandler(OnSelectionChanged); TreeViewColumn gameSystemColumn = new TreeViewColumn (); gameSystemColumn.Title = "Game System"; CellRendererText gameSystemCell = new CellRendererText (); gameSystemColumn.PackStart (gameSystemCell, true); lstGameSystems.AppendColumn(gameSystemColumn); gameSystemColumn.SetCellDataFunc (gameSystemCell, new TreeCellDataFunc (RenderSystemName)); ListStore store = new ListStore(typeof(GameSystem)); foreach (GameSystem system in WarFoundryLoader.GetDefault().GetGameSystems()) { store.AppendValues(system); } lstGameSystems.Model = store; } private void RenderSystemName(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter) { GameSystem system = (GameSystem) model.GetValue(iter, 0); (cell as CellRendererText).Text = system.Name; } protected virtual void OnGameSystemOkayClicked(object sender, EventArgs e) { logger.Debug("Okay clicked"); SetReturnValue(); Respond(ResponseType.Ok); } private void SetReturnValue() { TreeModel model; TreeIter iter; lstGameSystems.Selection.GetSelected (out model, out iter); selectedSystem = (GameSystem) model.GetValue(iter, 0); } protected virtual void OnSelectionChanged(object o, EventArgs e) { logger.Debug("Selection changed"); buttonOk.Sensitive = (lstGameSystems.Selection.CountSelectedRows() > 0); } protected virtual void OnCancel (object sender, System.EventArgs e) { logger.Debug("Cancel clicked"); Respond(ResponseType.Cancel); } protected virtual void lstGameSystemsRowActivated (object o, Gtk.RowActivatedArgs args) { logger.Debug("List row double-clicked"); SetReturnValue(); Respond(ResponseType.Ok); } public GameSystem SelectedSystem { get { return selectedSystem; } } } }