private int AddSurplusCell(Grid grid, int gridRow, int gridColumn, LedgerEntryLine line)
{
AddBorderToGridCell(grid, SurplusBackground, false, gridRow, gridColumn);
var stackPanel = new StackPanel { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Right };
grid.Children.Add(stackPanel);
Grid.SetRow(stackPanel, gridRow);
Grid.SetColumn(stackPanel, gridColumn);
if (line.SurplusBalances.Any(b => b.Balance < 0))
{
var warningImage = new ContentControl
{
Template = (ControlTemplate)FindResource("WarningImage"),
Width = 20,
Height = 20,
Margin = new Thickness(5),
ToolTip = "There are one or more negative surplus balances!"
};
stackPanel.Children.Add(warningImage);
}
var hyperlink = new Hyperlink(new Run(line.CalculatedSurplus.ToString("N", CultureInfo.CurrentCulture)))
{
Command = this.showSurplusBalancesCommand,
CommandParameter = line
};
var textBlock = new TextBlock(hyperlink)
{
Style = (Style)FindResource(ImportantNumberStyle),
ToolTip = string.Format(CultureInfo.CurrentCulture, "Total Surplus: {0:N}. Click for more detail...", line.CalculatedSurplus),
Foreground = (Brush)FindResource(SurplusTextBrush)
};
stackPanel.Children.Add(textBlock);
return ++gridRow;
}