changeset 154:24d0cfaa95da

Re #269: Handle multiple stat lines * Add debug logging to work out what was going on * Migrate to using a FlowLayoutPanel Previous problem fixed - test data file had stats override, which stopped multiple stat lines showing TODO: Reduce the width of the stats a bit so that we only get vertical scrollbars
author IBBoard <dev@ibboard.co.uk>
date Thu, 27 May 2010 20:01:07 +0000
parents fcd90498d9a2
children 67b4b84f5674
files FrmUnit.cs
diffstat 1 files changed, 13 insertions(+), 3 deletions(-) [+]
line diff
     1.1 --- a/FrmUnit.cs	Wed May 26 20:05:20 2010 +0000
     1.2 +++ b/FrmUnit.cs	Thu May 27 20:01:07 2010 +0000
     1.3 @@ -17,6 +17,7 @@
     1.4  using IBBoard.WarFoundry.API.Objects;
     1.5  using IBBoard.WarFoundry.GUI.WinForms.UI;
     1.6  using IBBoard.WarFoundry.GUI.WinForms.Util;
     1.7 +using log4net;
     1.8  
     1.9  namespace IBBoard.WarFoundry.GUI.WinForms
    1.10  {
    1.11 @@ -25,6 +26,7 @@
    1.12  	/// </summary>
    1.13  	public class FrmUnit : IBBoard.Windows.Forms.IBBForm
    1.14  	{
    1.15 +		private static readonly ILog log = LogManager.GetLogger(typeof(FrmUnit));
    1.16  		private static readonly int COLUMN_WIDTH = 40;
    1.17  		private static readonly int BORDER_WIDTH = 1;
    1.18  		private Unit unit;
    1.19 @@ -45,7 +47,7 @@
    1.20  		private TextBox notes;
    1.21  		private ListBox abilitiesList;
    1.22  		private IBBLabel lblAbilities;
    1.23 -		private Panel statsPanel;
    1.24 +		private FlowLayoutPanel statsPanel;
    1.25  		/// <summary>
    1.26  		/// Required designer variable.
    1.27  		/// </summary>
    1.28 @@ -107,6 +109,7 @@
    1.29  			Stat[][] stats = unit.UnitStatsArraysWithName;
    1.30  			string[] statsIDs = unit.UnitStatsArrayIDs;
    1.31  			int statsCount = stats.Length;
    1.32 +			log.DebugFormat("Unit {0} has {1} stats arrays", unit.UnitType.Name, statsCount);
    1.33  
    1.34  			for (int i = 0; i < statsCount; i++)
    1.35  			{
    1.36 @@ -114,8 +117,9 @@
    1.37  				DataTable dt = (DataTable)statsGrid.DataSource;
    1.38  				DataRow dr = dt.NewRow();
    1.39  				dr.ItemArray = stats[i];
    1.40 +				log.DebugFormat("Add row to data table for {0}", statsIDs[i]);
    1.41  				dt.Rows.Add(dr);
    1.42 -				statsGrid.SelectedCells[0].Selected = false;
    1.43 +				statsGrid.ClearSelection();
    1.44  			}
    1.45  		}
    1.46  
    1.47 @@ -138,6 +142,7 @@
    1.48  
    1.49  		private DataGridView CreateDataGridView(string statsID)
    1.50  		{
    1.51 +			log.DebugFormat("Create DataGridView for stats ID {0}", statsID);
    1.52  			SystemStats sysStats = unit.Race.GameSystem.GetSystemStatsForID(statsID);
    1.53  			StatSlot[] sysStatSlots = sysStats.StatSlots;
    1.54  			StatSlot[] statsWithName = new StatSlot[sysStatSlots.Length + 1];
    1.55 @@ -170,12 +175,14 @@
    1.56  
    1.57  		private static DataColumn CreateDataColumn(string slotName)
    1.58  		{
    1.59 +			log.DebugFormat("Create column {0}", slotName);
    1.60  			DataColumn tempCol = new DataColumn(slotName,  typeof(Stat));
    1.61  			return tempCol;
    1.62  		}
    1.63  
    1.64  		public DataGridView CreateDataGridView()
    1.65  		{
    1.66 +			log.Debug("Create DataGridView widget");
    1.67  			DataGridView statsGrid = new DataGridView();
    1.68  			statsGrid.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    1.69  						| System.Windows.Forms.AnchorStyles.Right)));
    1.70 @@ -207,6 +214,7 @@
    1.71  		{
    1.72  			DataGridViewRowCollection rows = statsGrid.Rows;
    1.73  			statsGrid.Height = statsGrid.Columns[0].HeaderCell.Size.Height + (rows.Count * rows[0].Height);
    1.74 +			log.DebugFormat("Set height to {0} for grid of {1} rows", statsGrid.Height, rows.Count);
    1.75  		}
    1.76  
    1.77  		private void SetWeapons()
    1.78 @@ -271,7 +279,7 @@
    1.79  			this.notes = new System.Windows.Forms.TextBox();
    1.80  			this.abilitiesList = new System.Windows.Forms.ListBox();
    1.81  			this.lblAbilities = new IBBoard.Windows.Forms.IBBLabel();
    1.82 -			this.statsPanel = new System.Windows.Forms.Panel();
    1.83 +			this.statsPanel = new System.Windows.Forms.FlowLayoutPanel();
    1.84  			((System.ComponentModel.ISupportInitialize)(this.unitSize)).BeginInit();
    1.85  			this.SuspendLayout();
    1.86  			// 
    1.87 @@ -422,6 +430,8 @@
    1.88  			// 
    1.89  			// statsPanel
    1.90  			// 
    1.91 +			this.statsPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    1.92 +						| System.Windows.Forms.AnchorStyles.Right)));
    1.93  			this.statsPanel.AutoScroll = true;
    1.94  			this.statsPanel.Location = new System.Drawing.Point(8, 35);
    1.95  			this.statsPanel.Name = "statsPanel";