diff FrmSelectSystem.cs @ 0:7dd160dacb60

Initial commit of WarFoundry code
author IBBoard <dev@ibboard.co.uk>
date Fri, 19 Dec 2008 15:57:51 +0000
parents
children 42cf06b8f897
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FrmSelectSystem.cs	Fri Dec 19 15:57:51 2008 +0000
@@ -0,0 +1,172 @@
+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;
+
+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() : this(null)
+		{
+		}
+
+        public FrmSelectSystem(WarFoundryFactory currFactory)
+		{
+			//
+			// Required for Windows Form Designer support
+			//
+			InitializeComponent();
+
+			Translation.TranslateControl(this);
+
+			lstSystems.Items.Clear();
+			GameSystem[] systems = currFactory.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)
+		{
+//            selectedSystem = lstSystems.
+            //TODO: Set game system
+
+			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; }
+		}
+	}
+}