Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.WinForms
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 wrap: on
line diff
--- a/FrmUnit.cs Thu May 27 20:01:07 2010 +0000 +++ b/FrmUnit.cs Fri May 28 19:49:34 2010 +0000 @@ -27,8 +27,8 @@ public class FrmUnit : IBBoard.Windows.Forms.IBBForm { private static readonly ILog log = LogManager.GetLogger(typeof(FrmUnit)); - private static readonly int COLUMN_WIDTH = 40; private static readonly int BORDER_WIDTH = 1; + private static readonly int NAME_COL_WIDTH_MULTIPLIER = 3; private Unit unit; private Dictionary<UnitEquipmentItem, UnitEquipmentChoice> equipmentChoices = new Dictionary<UnitEquipmentItem, UnitEquipmentChoice>(); private Dictionary<string, DataGridView> DataGridViews = new Dictionary<string, DataGridView>(); @@ -145,30 +145,29 @@ log.DebugFormat("Create DataGridView for stats ID {0}", statsID); SystemStats sysStats = unit.Race.GameSystem.GetSystemStatsForID(statsID); StatSlot[] sysStatSlots = sysStats.StatSlots; - StatSlot[] statsWithName = new StatSlot[sysStatSlots.Length + 1]; + int statsCount = sysStatSlots.Length; + int statsWithNameCount = statsCount + 1; + StatSlot[] statsWithName = new StatSlot[statsWithNameCount]; statsWithName[0] = new StatSlot("Name"); sysStatSlots.CopyTo(statsWithName, 1); DataTable dt = new DataTable(); - int statsCount = statsWithName.Length; DataGridView statsGrid = CreateDataGridView(); statsGrid.DataSource = dt; + int columnWidth = statsGrid.Width / (statsCount + NAME_COL_WIDTH_MULTIPLIER); - for (int i = 0; i < statsCount; i++) + for (int i = 0; i < statsWithNameCount; i++) { StatSlot stat = statsWithName[i]; string slotName = stat.Name; dt.Columns.Add(CreateDataColumn(slotName)); - statsGrid.Columns[i].Width = COLUMN_WIDTH; + DataGridViewColumn col = statsGrid.Columns[i]; + col.Width = columnWidth; + col.CellTemplate = new StatsDataGridViewCell(); } DataGridViewColumn nameColumn = statsGrid.Columns[0]; nameColumn.Name = Translation.GetTranslation("UnitName", "Name"); - nameColumn.Width = statsGrid.ClientSize.Width - (sysStatSlots.Length * (COLUMN_WIDTH + BORDER_WIDTH)); - - for (int i = 0; i < statsCount; i++) - { - statsGrid.Columns[i].CellTemplate = new StatsDataGridViewCell(); - } + nameColumn.Width = statsGrid.Width - (statsCount * columnWidth); return statsGrid; } @@ -198,7 +197,7 @@ statsGrid.BackgroundColor = SystemColors.Control; statsGrid.RowsAdded += new DataGridViewRowsAddedEventHandler(statsGrid_RowsAdded); statsPanel.Controls.Add(statsGrid); - statsGrid.Width = statsPanel.Width; + statsGrid.Width = statsPanel.Width - (int)Math.Round(SystemInformation.VerticalScrollBarWidth * 1.4); return statsGrid; }