Mercurial > repos > IBBoard.WarFoundry.GUI.GTK
view FrmChangeGameSystem.cs @ 22:40485c6e5cb0
Re #86: Initial GTK# GUI
* Add GTK# icons to menus where a sensible one exists
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 17 Aug 2009 19:17:35 +0000 |
parents | a191d0655f55 |
children |
line wrap: on
line source
// This file (FrmChangeGameSystem.cs) is a part of the IBBoard.WarFoundry.GTK project and is copyright 2008, 2009 IBBoard. // // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING 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; } } } }