Mercurial > repos > IBBoard.WarFoundry.GUI.GTK
view FrmChangeGameSystem.cs @ 5:65279b85446f
Re #1 - LGPL license all code
* Add LGPL header to all files
* Add COPYING.LGPL and COPYING.GPL with content of license
Also
* Moved all classes from IBBoard.WarFoundry to IBBoard.WarFoundry.GTK
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 25 Jan 2009 14:52:18 +0000 |
parents | 1bb28f84d567 |
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; } } } }