Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.WinForms
diff UI/StatColumnStyle.cs @ 27:526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
* Add StatColumnStyle (custom data grid style)
* Use custom column style and fix positioning of columns
Also, moved some forms from IBBoard.WarFoundry namespace to IBBoard.WarFoundry.WinForms
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 01 Aug 2009 14:01:56 +0000 |
parents | |
children | 6ab7ddc038f9 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UI/StatColumnStyle.cs Sat Aug 01 14:01:56 2009 +0000 @@ -0,0 +1,32 @@ +using System; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using IBBoard.WarFoundry.API.Objects; + +namespace IBBoard.WarFoundry.WinForms.UI +{ + class StatColumnStyle : DataGridTextBoxColumn + { + protected override void Paint(Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, Brush backBrush, Brush foreBrush, bool alignToRight) + { + Object obj = GetColumnValueAtRow(source, rowNum); + Rectangle rect = bounds; + g.FillRectangle(backBrush, rect); + rect.Offset(0, 2); + rect.Height -= 2; + + if (obj is Stat) + { + Stat stat = (Stat) obj; + StringFormat stringFormat = new StringFormat(); + stringFormat.Alignment = (stat.ParentSlotName == "Name" ? StringAlignment.Near : StringAlignment.Center); + g.DrawString(stat.SlotValueString, this.DataGridTableStyle.DataGrid.Font, foreBrush, rect, stringFormat); + } + else + { + g.DrawString(NullText, this.DataGridTableStyle.DataGrid.Font, foreBrush, rect); + } + } + } +}