view UI/StatColumnStyle.cs @ 62:0e7c257ca8d6 WarFoundry_v0.1beta2_Winforms

Fixes #164: Show unit cost in army tree * Add points value in army tree for units, category and army (aggregating as it goes up the tree) * Add code to update tree node text as points values change * Remove references to now deprecated points-related properties Also: * Add rolling log file appender to logging config
author IBBoard <dev@ibboard.co.uk>
date Sat, 19 Sep 2009 19:44:45 +0000
parents 740350673006
children e04bea5b7b3d
line wrap: on
line source

// This file (StatColumnStyle.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2009 IBBoard.
//
// 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.

using System;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using IBBoard.WarFoundry.API.Objects;

namespace IBBoard.WarFoundry.GUI.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);
			}
		}
	}
}