Mercurial > repos > IBBoard.WarFoundry.GUI.WinForms
annotate UI/StatColumnStyle.cs @ 53:e6d0d9eababf
Fixes #163: Show unit cost on unit dialog
* Add a quick label with the points cost of the unit - can be moved and repositioned based on user feedback
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 16 Sep 2009 19:50:39 +0000 |
parents | 740350673006 |
children | e04bea5b7b3d |
rev | line source |
---|---|
36 | 1 // This file (StatColumnStyle.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2009 IBBoard. |
2 // | |
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. | |
4 | |
27
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 using System; |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 using System.Drawing; |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
7 using System.Text; |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 using System.Windows.Forms; |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
9 using IBBoard.WarFoundry.API.Objects; |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
10 |
40
740350673006
Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
11 namespace IBBoard.WarFoundry.GUI.WinForms.UI |
27
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
12 { |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 class StatColumnStyle : DataGridTextBoxColumn |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 { |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 protected override void Paint(Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, Brush backBrush, Brush foreBrush, bool alignToRight) |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 { |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 Object obj = GetColumnValueAtRow(source, rowNum); |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 Rectangle rect = bounds; |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 g.FillRectangle(backBrush, rect); |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
20 rect.Offset(0, 2); |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
21 rect.Height -= 2; |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
22 |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
23 if (obj is Stat) |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 { |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
25 Stat stat = (Stat) obj; |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
26 StringFormat stringFormat = new StringFormat(); |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
27 stringFormat.Alignment = (stat.ParentSlotName == "Name" ? StringAlignment.Near : StringAlignment.Center); |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
28 g.DrawString(stat.SlotValueString, this.DataGridTableStyle.DataGrid.Font, foreBrush, rect, stringFormat); |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
29 } |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
30 else |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
31 { |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
32 g.DrawString(NullText, this.DataGridTableStyle.DataGrid.Font, foreBrush, rect); |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
33 } |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
34 } |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
35 } |
526fefefb16b
Fixes #91: Fix WinForms rendering of unit stats
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
36 } |