BudgetAnalyser.LedgerBook.LedgerBookGridBuilderV2.AddSurplusCell C# (CSharp) Method

AddSurplusCell() private method

private AddSurplusCell ( Grid grid, int gridRow, int gridColumn, LedgerEntryLine line ) : int
grid System.Windows.Controls.Grid
gridRow int
gridColumn int
line BudgetAnalyser.Engine.Ledger.LedgerEntryLine
return int
        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;
        }