changeset 155:67b4b84f5674

Fixes #269: Handle multiple stat lines * Reduce the width of the tables to only show a vertical scrollbar * Make the width of the columns more proportional to how many there are
author IBBoard <dev@ibboard.co.uk>
date Fri, 28 May 2010 19:49:34 +0000
parents 24d0cfaa95da
children d3f498514122
files FrmUnit.cs
diffstat 1 files changed, 11 insertions(+), 12 deletions(-) [+]
line diff
     1.1 --- a/FrmUnit.cs	Thu May 27 20:01:07 2010 +0000
     1.2 +++ b/FrmUnit.cs	Fri May 28 19:49:34 2010 +0000
     1.3 @@ -27,8 +27,8 @@
     1.4  	public class FrmUnit : IBBoard.Windows.Forms.IBBForm
     1.5  	{
     1.6  		private static readonly ILog log = LogManager.GetLogger(typeof(FrmUnit));
     1.7 -		private static readonly int COLUMN_WIDTH = 40;
     1.8  		private static readonly int BORDER_WIDTH = 1;
     1.9 +		private static readonly int NAME_COL_WIDTH_MULTIPLIER = 3;
    1.10  		private Unit unit;
    1.11  		private Dictionary<UnitEquipmentItem, UnitEquipmentChoice> equipmentChoices = new Dictionary<UnitEquipmentItem, UnitEquipmentChoice>();
    1.12  		private Dictionary<string, DataGridView> DataGridViews = new Dictionary<string, DataGridView>();
    1.13 @@ -145,30 +145,29 @@
    1.14  			log.DebugFormat("Create DataGridView for stats ID {0}", statsID);
    1.15  			SystemStats sysStats = unit.Race.GameSystem.GetSystemStatsForID(statsID);
    1.16  			StatSlot[] sysStatSlots = sysStats.StatSlots;
    1.17 -			StatSlot[] statsWithName = new StatSlot[sysStatSlots.Length + 1];
    1.18 +			int statsCount = sysStatSlots.Length;
    1.19 +			int statsWithNameCount = statsCount + 1;
    1.20 +			StatSlot[] statsWithName = new StatSlot[statsWithNameCount];
    1.21  			statsWithName[0] = new StatSlot("Name");
    1.22  			sysStatSlots.CopyTo(statsWithName, 1);
    1.23  			DataTable dt = new DataTable();
    1.24 -			int statsCount = statsWithName.Length;
    1.25  			DataGridView statsGrid = CreateDataGridView();
    1.26  			statsGrid.DataSource = dt;
    1.27 +			int columnWidth = statsGrid.Width / (statsCount + NAME_COL_WIDTH_MULTIPLIER);
    1.28  
    1.29 -			for (int i = 0; i < statsCount; i++)
    1.30 +			for (int i = 0; i < statsWithNameCount; i++)
    1.31  			{
    1.32  				StatSlot stat = statsWithName[i];
    1.33  				string slotName = stat.Name;
    1.34  				dt.Columns.Add(CreateDataColumn(slotName));
    1.35 -				statsGrid.Columns[i].Width = COLUMN_WIDTH;
    1.36 +				DataGridViewColumn col = statsGrid.Columns[i];
    1.37 +				col.Width = columnWidth;
    1.38 +				col.CellTemplate = new StatsDataGridViewCell();
    1.39  			}
    1.40  
    1.41  			DataGridViewColumn nameColumn = statsGrid.Columns[0];
    1.42  			nameColumn.Name = Translation.GetTranslation("UnitName", "Name");
    1.43 -			nameColumn.Width = statsGrid.ClientSize.Width - (sysStatSlots.Length * (COLUMN_WIDTH + BORDER_WIDTH));
    1.44 -
    1.45 -			for (int i = 0; i < statsCount; i++)
    1.46 -			{
    1.47 -				statsGrid.Columns[i].CellTemplate = new StatsDataGridViewCell();
    1.48 -			}
    1.49 +			nameColumn.Width = statsGrid.Width - (statsCount * columnWidth);
    1.50  			
    1.51  			return statsGrid;
    1.52  		}
    1.53 @@ -198,7 +197,7 @@
    1.54  			statsGrid.BackgroundColor = SystemColors.Control;
    1.55  			statsGrid.RowsAdded += new DataGridViewRowsAddedEventHandler(statsGrid_RowsAdded);
    1.56  			statsPanel.Controls.Add(statsGrid);
    1.57 -			statsGrid.Width = statsPanel.Width;
    1.58 +			statsGrid.Width = statsPanel.Width - (int)Math.Round(SystemInformation.VerticalScrollBarWidth * 1.4);
    1.59  			return statsGrid;
    1.60  		}
    1.61