Mercurial > repos > IBBoard.WarFoundry.GUI.GTK
view FrmChangeGameSystem.cs @ 0:1bb28f84d567
Initial commit of WarFoundry code
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Fri, 19 Dec 2008 15:57:51 +0000 |
parents | |
children | 65279b85446f |
line wrap: on
line source
// FrmChangeGameSystem.cs // // Copyright (C) 2007 IBBoard // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License version 2.1 of the License as published by the Free // Software Foundation. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // using System; using IBBoard.WarFoundry.API; using IBBoard.WarFoundry.API.Objects; using Gtk; using log4net; namespace IBBoard.WarFoundry { 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; } } } }