changeset 171:0e17097db8e5

Fixes #300: WinForms UI doesn't make it obvious why nothing is listed on first run * Added a warning icon and tooltip message to the New Army dialog * Added initial English translation text Also: * Layered the enabling of widgets so that they are only enabled when they make sense (so empty list won't be enabled)
author IBBoard <dev@ibboard.co.uk>
date Sat, 31 Jul 2010 14:26:21 +0000
parents 1925af42100c
children b1f9b84111ed
files FrmNewArmy.cs FrmNewArmy.resx IBBoard.WarFoundry.GUI.WinForms.csproj Properties/Resources.Designer.cs Properties/Resources.resx translations/en.translation
diffstat 6 files changed, 68 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/FrmNewArmy.cs	Sun Jul 25 17:17:55 2010 +0000
+++ b/FrmNewArmy.cs	Sat Jul 31 14:26:21 2010 +0000
@@ -20,10 +20,7 @@
 	/// </summary>
 	public class FrmNewArmy : IBBForm
 	{
-		/// <summary>
-		/// Required designer variable.
-		/// </summary>
-		private System.ComponentModel.Container components = null;
+		private IContainer components;
 		private IBBoard.Windows.Forms.IBBButton bttnCancel;
 		private IBBoard.Windows.Forms.IBBLabel lblRaceList;
 		private IBBoard.Windows.Forms.IBBButton bttnSelectRace;
@@ -38,6 +35,7 @@
 		private GameSystem system;
 		private Race race;
 		private string armyName;
+		private ToolTip gameSystemToolTip;
 		private int maxPoints;
 
 		public FrmNewArmy(GameSystem system)
@@ -51,6 +49,17 @@
 				gameSystems.Items.Add(gameSystem);
 			}
 
+			if (gameSystems.Items.Count > 0)
+			{
+				gameSystems.Enabled = true;
+				lblGameSystem.Image = null;
+			}
+			else
+			{
+				gameSystems.Enabled = false;
+				gameSystemToolTip.SetToolTip(lblGameSystem, Translation.GetTranslation("newArmyNoGameSystems", "could not load data for game systems - please check logs"));
+			}
+
 			if (system != null)
 			{
 				gameSystems.SelectedItem = system;
@@ -91,6 +100,7 @@
 		/// </summary>
 		private void InitializeComponent()
 		{
+			this.components = new System.ComponentModel.Container();
 			System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmNewArmy));
 			this.lstRaces = new System.Windows.Forms.ListBox();
 			this.bttnCancel = new IBBoard.Windows.Forms.IBBButton();
@@ -100,16 +110,18 @@
 			this.txtArmyName = new System.Windows.Forms.TextBox();
 			this.lblArmySize = new IBBoard.Windows.Forms.IBBLabel();
 			this.armySize = new System.Windows.Forms.NumericUpDown();
+			this.gameSystems = new System.Windows.Forms.ComboBox();
 			this.lblGameSystem = new IBBoard.Windows.Forms.IBBLabel();
-			this.gameSystems = new System.Windows.Forms.ComboBox();
-			((System.ComponentModel.ISupportInitialize) (this.armySize)).BeginInit();
+			this.gameSystemToolTip = new System.Windows.Forms.ToolTip(this.components);
+			((System.ComponentModel.ISupportInitialize)(this.armySize)).BeginInit();
 			this.SuspendLayout();
 			// 
 			// lstRaces
 			// 
-			this.lstRaces.Anchor = ((System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+			this.lstRaces.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
 						| System.Windows.Forms.AnchorStyles.Right)));
 			this.lstRaces.DisplayMember = "Name";
+			this.lstRaces.Enabled = false;
 			this.lstRaces.Location = new System.Drawing.Point(141, 33);
 			this.lstRaces.Name = "lstRaces";
 			this.lstRaces.Size = new System.Drawing.Size(265, 121);
@@ -138,7 +150,7 @@
 			// 
 			// bttnSelectRace
 			// 
-			this.bttnSelectRace.Anchor = ((System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+			this.bttnSelectRace.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
 						| System.Windows.Forms.AnchorStyles.Right)));
 			this.bttnSelectRace.Enabled = false;
 			this.bttnSelectRace.FlatStyle = System.Windows.Forms.FlatStyle.System;
@@ -160,8 +172,9 @@
 			// 
 			// txtArmyName
 			// 
-			this.txtArmyName.Anchor = ((System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+			this.txtArmyName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
 						| System.Windows.Forms.AnchorStyles.Right)));
+			this.txtArmyName.Enabled = false;
 			this.txtArmyName.Location = new System.Drawing.Point(141, 160);
 			this.txtArmyName.Name = "txtArmyName";
 			this.txtArmyName.Size = new System.Drawing.Size(265, 20);
@@ -179,6 +192,7 @@
 			// 
 			// armySize
 			// 
+			this.armySize.Enabled = false;
 			this.armySize.Increment = new decimal(new int[] {
             50,
             0,
@@ -200,18 +214,9 @@
             0,
             0});
 			// 
-			// lblGameSystem
-			// 
-			this.lblGameSystem.Location = new System.Drawing.Point(12, 9);
-			this.lblGameSystem.Name = "lblGameSystem";
-			this.lblGameSystem.Size = new System.Drawing.Size(123, 18);
-			this.lblGameSystem.TabIndex = 12;
-			this.lblGameSystem.Text = "game system";
-			this.lblGameSystem.TextAlign = System.Drawing.ContentAlignment.TopRight;
-			// 
 			// gameSystems
 			// 
-			this.gameSystems.Anchor = ((System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+			this.gameSystems.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
 						| System.Windows.Forms.AnchorStyles.Right)));
 			this.gameSystems.DisplayMember = "Name";
 			this.gameSystems.FormattingEnabled = true;
@@ -221,6 +226,17 @@
 			this.gameSystems.TabIndex = 13;
 			this.gameSystems.SelectedValueChanged += new System.EventHandler(this.gameSystems_SelectedValueChanged);
 			// 
+			// lblGameSystem
+			// 
+			this.lblGameSystem.Image = global::IBBoard.WarFoundry.GUI.WinForms.Properties.Resources.warning_sml;
+			this.lblGameSystem.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
+			this.lblGameSystem.Location = new System.Drawing.Point(12, 9);
+			this.lblGameSystem.Name = "lblGameSystem";
+			this.lblGameSystem.Size = new System.Drawing.Size(123, 18);
+			this.lblGameSystem.TabIndex = 12;
+			this.lblGameSystem.Text = "game system";
+			this.lblGameSystem.TextAlign = System.Drawing.ContentAlignment.TopRight;
+			// 
 			// FrmNewArmy
 			// 
 			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
@@ -236,14 +252,14 @@
 			this.Controls.Add(this.bttnSelectRace);
 			this.Controls.Add(this.lstRaces);
 			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
-			this.Icon = ((System.Drawing.Icon) (resources.GetObject("$this.Icon")));
+			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
 			this.MaximizeBox = false;
 			this.MinimizeBox = false;
 			this.Name = "FrmNewArmy";
 			this.ShowInTaskbar = false;
 			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
 			this.Text = "FrmNewArmy";
-			((System.ComponentModel.ISupportInitialize) (this.armySize)).EndInit();
+			((System.ComponentModel.ISupportInitialize)(this.armySize)).EndInit();
 			this.ResumeLayout(false);
 			this.PerformLayout();
 
@@ -309,6 +325,9 @@
 		private void lstRaces_SelectedIndexChanged(object sender, System.EventArgs e)
 		{
 			setSelectRaceEnabledVal();
+			bool raceSelected = lstRaces.SelectedItem != null;
+			txtArmyName.Enabled = raceSelected;
+			armySize.Enabled = raceSelected;
 		}
 
 		private void gameSystems_SelectedValueChanged(object sender, EventArgs e)
@@ -320,11 +339,13 @@
 			{
 				SetRaces(selected);
 
-				if (lstRaces.Items.Count > 0)
+				if (lstRaces.Items.Count == 1)
 				{
 					lstRaces.SelectedIndex = 0;
 				}
 			}
+
+			lstRaces.Enabled = lstRaces.Items.Count > 0;
 		}
 	}
 }
--- a/FrmNewArmy.resx	Sun Jul 25 17:17:55 2010 +0000
+++ b/FrmNewArmy.resx	Sat Jul 31 14:26:21 2010 +0000
@@ -117,6 +117,9 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
+  <metadata name="gameSystemToolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
+  </metadata>
   <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
   <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>
--- a/IBBoard.WarFoundry.GUI.WinForms.csproj	Sun Jul 25 17:17:55 2010 +0000
+++ b/IBBoard.WarFoundry.GUI.WinForms.csproj	Sat Jul 31 14:26:21 2010 +0000
@@ -109,6 +109,7 @@
     <None Include="icons\edit-redo.png" />
     <None Include="icons\edit-undo.png" />
     <Content Include="icons\list-add.png" />
+    <Content Include="icons\warning-sml.png" />
     <Content Include="libs\log4net.dll" />
     <Content Include="WarFoundryPref.xml">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
--- a/Properties/Resources.Designer.cs	Sun Jul 25 17:17:55 2010 +0000
+++ b/Properties/Resources.Designer.cs	Sat Jul 31 14:26:21 2010 +0000
@@ -101,5 +101,12 @@
                 return ((System.Drawing.Bitmap)(obj));
             }
         }
+        
+        internal static System.Drawing.Bitmap warning_sml {
+            get {
+                object obj = ResourceManager.GetObject("warning-sml", resourceCulture);
+                return ((System.Drawing.Bitmap)(obj));
+            }
+        }
     }
 }
--- a/Properties/Resources.resx	Sun Jul 25 17:17:55 2010 +0000
+++ b/Properties/Resources.resx	Sat Jul 31 14:26:21 2010 +0000
@@ -118,22 +118,25 @@
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
   <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
-  <data name="document-open" type="System.Resources.ResXFileRef, System.Windows.Forms">
-    <value>..\icons\document-open.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
-  </data>
-  <data name="document-new" type="System.Resources.ResXFileRef, System.Windows.Forms">
-    <value>..\icons\document-new.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
-  </data>
-  <data name="document-save" type="System.Resources.ResXFileRef, System.Windows.Forms">
-    <value>..\icons\document-save.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
-  </data>
   <data name="edit-redo" type="System.Resources.ResXFileRef, System.Windows.Forms">
     <value>..\icons\edit-redo.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
   </data>
   <data name="edit-undo" type="System.Resources.ResXFileRef, System.Windows.Forms">
     <value>..\icons\edit-undo.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
   </data>
+  <data name="document-save" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\icons\document-save.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  </data>
+  <data name="document-new" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\icons\document-new.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  </data>
+  <data name="document-open" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\icons\document-open.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  </data>
   <data name="list-add" type="System.Resources.ResXFileRef, System.Windows.Forms">
     <value>..\icons\list-add.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
   </data>
+  <data name="warning-sml" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\icons\warning-sml.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  </data>
 </root>
\ No newline at end of file
--- a/translations/en.translation	Sun Jul 25 17:17:55 2010 +0000
+++ b/translations/en.translation	Sat Jul 31 14:26:21 2010 +0000
@@ -38,6 +38,8 @@
 	<translation id="lblArmyName">Army name:</translation>
 	<translation id="lblArmySize">Army size:</translation>
 	<translation id="bttnSelectRace">Create army</translation>
+	<translation id="newArmyNoGameSystems">WarFoundry couldn't find any game system data.
+Please check the logs for errors and ensure you have some game system data files in the "data" folder.</translation>
 	<translation id="FrmNewUnit">Add New {0} Choice</translation>
 	<translation id="lblUnitList">Unit types:</translation>
 	<translation id="bttnSelectUnit">Create unit</translation>