Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.WinForms
comparison 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 |
comparison
equal
deleted
inserted
replaced
26:d9aca1dc95d2 | 27:526fefefb16b |
---|---|
1 using System; | |
2 using System.Drawing; | |
3 using System.Text; | |
4 using System.Windows.Forms; | |
5 using IBBoard.WarFoundry.API.Objects; | |
6 | |
7 namespace IBBoard.WarFoundry.WinForms.UI | |
8 { | |
9 class StatColumnStyle : DataGridTextBoxColumn | |
10 { | |
11 protected override void Paint(Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, Brush backBrush, Brush foreBrush, bool alignToRight) | |
12 { | |
13 Object obj = GetColumnValueAtRow(source, rowNum); | |
14 Rectangle rect = bounds; | |
15 g.FillRectangle(backBrush, rect); | |
16 rect.Offset(0, 2); | |
17 rect.Height -= 2; | |
18 | |
19 if (obj is Stat) | |
20 { | |
21 Stat stat = (Stat) obj; | |
22 StringFormat stringFormat = new StringFormat(); | |
23 stringFormat.Alignment = (stat.ParentSlotName == "Name" ? StringAlignment.Near : StringAlignment.Center); | |
24 g.DrawString(stat.SlotValueString, this.DataGridTableStyle.DataGrid.Font, foreBrush, rect, stringFormat); | |
25 } | |
26 else | |
27 { | |
28 g.DrawString(NullText, this.DataGridTableStyle.DataGrid.Font, foreBrush, rect); | |
29 } | |
30 } | |
31 } | |
32 } |