private void DrawCell(TargetBase target, RectangleF rect, IRenderableScreenCell cell, bool isCursor, bool hasFocus)
        {
            var context2D = target.DeviceManager.ContextDirect2D;

            // 1. Paint background
            {
                Color backgroundColor;
                if (isCursor && hasFocus)
                {
                    var color = this.screenPreview.ColorTheme.ColorTable[ScreenColor.CursorBackground];
                    backgroundColor = new Color(color.R, color.G, color.B, color.A);
                }
                else
                {
                    var color = this.GetColor(cell.BackgroundColor);
                    backgroundColor = new Color(color.R, color.G, color.B, color.A);
                }

                if (backgroundColor != TerminalBackgroundColor)
                {
                    Brush backgroundBrush = GetBrush(context2D, backgroundColor);
                    context2D.FillRectangle(rect, backgroundBrush);
                }
            }

            // 2. Paint border
            {
                if (isCursor && !hasFocus)
                {
                    var color = this.screenPreview.ColorTheme.ColorTable[ScreenColor.CursorBackground];
                    Color borderColor = new Color(color.R, color.G, color.B, color.A);
                    Brush borderBrush = GetBrush(context2D, borderColor);
                    context2D.DrawRectangle(rect, borderBrush);
                }
            }

            // 3. Paint foreground (character)
            {
                Color foregroundColor;
                if (isCursor && hasFocus)
                {
                    var color = this.screenPreview.ColorTheme.ColorTable[ScreenColor.CursorForeground];
                    foregroundColor = new Color(color.R, color.G, color.B, color.A);
                }
                else
                {
                    var color = this.GetColor(cell.ForegroundColor);
                    foregroundColor = new Color(color.R, color.G, color.B, color.A);
                }

                var foregroundBrush = GetBrush(context2D, foregroundColor);

                if (cell.Character != ' ')
                {
                    TextFormat textFormat = this.textFormatNormal;
                    if (cell.Modifications.HasFlag(ScreenCellModifications.Bold))
                    {
                        textFormat = this.textFormatBold;
                    }

                    context2D.DrawText(cell.Character.ToString(), textFormat, rect, foregroundBrush, DrawTextOptions.Clip);
                }

                if (cell.Modifications.HasFlag(ScreenCellModifications.Underline))
                {
                    var point1 = new Vector2(rect.Left, rect.Bottom - 1.0f);
                    var point2 = new Vector2(rect.Right, rect.Bottom - 1.0f);
                    context2D.DrawLine(point1, point2, foregroundBrush);
                }
            }
        }
        private void DrawCell(TargetBase target, RectangleF rect, IRenderableScreenCell cell, bool isCursor, bool hasFocus)
        {
            var context2D = target.DeviceManager.ContextDirect2D;

            // 1. Paint background
            {
                Color backgroundColor;
                if (isCursor && hasFocus)
                {
                    var color = this.screenPreview.ColorTheme.ColorTable[ScreenColor.CursorBackground];
                    backgroundColor = new Color(color.R, color.G, color.B, color.A);
                }
                else
                {
                    var color = this.GetColor(cell.BackgroundColor);
                    backgroundColor = new Color(color.R, color.G, color.B, color.A);
                }

                if (backgroundColor != TerminalBackgroundColor)
                {
                    Brush backgroundBrush = GetBrush(context2D, backgroundColor);
                    context2D.FillRectangle(rect, backgroundBrush);
                }
            }

            // 2. Paint border
            {
                if (isCursor && !hasFocus)
                {
                    var   color       = this.screenPreview.ColorTheme.ColorTable[ScreenColor.CursorBackground];
                    Color borderColor = new Color(color.R, color.G, color.B, color.A);
                    Brush borderBrush = GetBrush(context2D, borderColor);
                    context2D.DrawRectangle(rect, borderBrush);
                }
            }

            // 3. Paint foreground (character)
            {
                Color foregroundColor;
                if (isCursor && hasFocus)
                {
                    var color = this.screenPreview.ColorTheme.ColorTable[ScreenColor.CursorForeground];
                    foregroundColor = new Color(color.R, color.G, color.B, color.A);
                }
                else
                {
                    var color = this.GetColor(cell.ForegroundColor);
                    foregroundColor = new Color(color.R, color.G, color.B, color.A);
                }

                var foregroundBrush = GetBrush(context2D, foregroundColor);

                if (cell.Character != ' ')
                {
                    TextFormat textFormat = this.textFormatNormal;
                    if (cell.Modifications.HasFlag(ScreenCellModifications.Bold))
                    {
                        textFormat = this.textFormatBold;
                    }

                    context2D.DrawText(cell.Character.ToString(), textFormat, rect, foregroundBrush, DrawTextOptions.Clip);
                }

                if (cell.Modifications.HasFlag(ScreenCellModifications.Underline))
                {
                    var point1 = new Vector2(rect.Left, rect.Bottom - 1.0f);
                    var point2 = new Vector2(rect.Right, rect.Bottom - 1.0f);
                    context2D.DrawLine(point1, point2, foregroundBrush);
                }
            }
        }