Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.WinForms
view FrmSelectSystem.cs @ 7:9828ba4f3f36
Closes #43 - Test Ticket for checking into SVN
* First Check-in!
* Did some code changes to allow the app to load default race and system files from the "data" directory.
* Also changed select system dialog so you can actually select a game system.
author | gregmita |
---|---|
date | Sat, 07 Mar 2009 21:08:31 +0000 |
parents | 8935971e307c |
children | 19bdbb80999c |
line wrap: on
line source
// This file (FrmSelectSystem.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms 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 System.IO; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using IBBoard; using IBBoard.Lang; using IBBoard.WarFoundry.API; using IBBoard.Windows.Forms; using IBBoard.WarFoundry.API.Objects; using IBBoard.Windows.Forms.I18N; namespace IBBoard.WarFoundry { /// <summary> /// Summary description for FrmSelectSystem. /// </summary> public class FrmSelectSystem : IBBoard.Windows.Forms.IBBForm { private System.Windows.Forms.ListBox lstSystems; private IBBoard.Windows.Forms.IBBLabel lblSystemList; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null; private IBBoard.Windows.Forms.IBBButton bttnCancel; private IBBoard.Windows.Forms.IBBButton bttnSelectSystem; private GameSystem selectedSystem; public FrmSelectSystem() { // // Required for Windows Form Designer support // InitializeComponent(); ControlTranslator.TranslateControl(this); lstSystems.Items.Clear(); GameSystem[] systems = WarFoundryLoader.GetDefault().GetGameSystems(); lstSystems.DataSource = systems; /*for (int i = 0; i<systems.Length; i++) { lstSystems.Items.Add(systems[i].Name); /*if (systems[i].Matches(defaultSystem)) { lstSystems.SelectedIndex = i; }* / }*/ } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.lstSystems = new System.Windows.Forms.ListBox(); this.bttnSelectSystem = new IBBoard.Windows.Forms.IBBButton(); this.lblSystemList = new IBBoard.Windows.Forms.IBBLabel(); this.bttnCancel = new IBBoard.Windows.Forms.IBBButton(); this.SuspendLayout(); // // lstSystems // this.lstSystems.Location = new System.Drawing.Point(80, 8); this.lstSystems.Name = "lstSystems"; this.lstSystems.Size = new System.Drawing.Size(216, 95); this.lstSystems.TabIndex = 0; this.lstSystems.SelectedIndexChanged += new System.EventHandler(this.lstSystems_SelectedIndexChanged); // // bttnSelectSystem // this.bttnSelectSystem.Enabled = false; this.bttnSelectSystem.FlatStyle = System.Windows.Forms.FlatStyle.System; this.bttnSelectSystem.Location = new System.Drawing.Point(192, 112); this.bttnSelectSystem.Name = "bttnSelectSystem"; this.bttnSelectSystem.Size = new System.Drawing.Size(104, 24); this.bttnSelectSystem.TabIndex = 1; this.bttnSelectSystem.Text = "Select system"; this.bttnSelectSystem.Click += new System.EventHandler(this.bttnSelectSystem_Click); // // lblSystemList // this.lblSystemList.Location = new System.Drawing.Point(0, 8); this.lblSystemList.Name = "lblSystemList"; this.lblSystemList.Size = new System.Drawing.Size(80, 80); this.lblSystemList.TabIndex = 2; this.lblSystemList.Text = "system list"; this.lblSystemList.TextAlign = System.Drawing.ContentAlignment.TopRight; // // bttnCancel // this.bttnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.bttnCancel.FlatStyle = System.Windows.Forms.FlatStyle.System; this.bttnCancel.Location = new System.Drawing.Point(8, 112); this.bttnCancel.Name = "bttnCancel"; this.bttnCancel.Size = new System.Drawing.Size(80, 24); this.bttnCancel.TabIndex = 3; this.bttnCancel.Text = "Cancel"; this.bttnCancel.Click += new System.EventHandler(this.bttnCancel_Click); // // FrmSelectSystem // this.AcceptButton = this.bttnSelectSystem; this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.CancelButton = this.bttnCancel; this.ClientSize = new System.Drawing.Size(306, 142); this.ControlBox = false; this.Controls.Add(this.bttnCancel); this.Controls.Add(this.lblSystemList); this.Controls.Add(this.bttnSelectSystem); this.Controls.Add(this.lstSystems); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.Name = "FrmSelectSystem"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "FrmSelectSystem"; this.ResumeLayout(false); } #endregion private void lstSystems_SelectedIndexChanged(object sender, System.EventArgs e) { bttnSelectSystem.Enabled = (lstSystems.SelectedIndex>-1); } private void bttnSelectSystem_Click(object sender, System.EventArgs e) { // set the selected system selectedSystem = (GameSystem) lstSystems.SelectedItem; this.DialogResult = DialogResult.OK; this.Close(); } private void bttnCancel_Click(object sender, System.EventArgs e) { this.DialogResult = DialogResult.Cancel; this.Close(); } public GameSystem GameSystem { get { return selectedSystem; } } } }