Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WPF] Allows setting the WPF control background when setting the terminal theme #10026

Merged
1 commit merged into from
May 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/cascadia/WpfTerminalControl/TerminalControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public ITerminalConnection Connection
/// <param name="theme">The color theme to use in the terminal.</param>
/// <param name="fontFamily">The font family to use in the terminal.</param>
/// <param name="fontSize">The font size to use in the terminal.</param>
public void SetTheme(TerminalTheme theme, string fontFamily, short fontSize)
/// <param name="externalBackground">Color for the control background when the terminal window is smaller than the hosting WPF window.</param>
public void SetTheme(TerminalTheme theme, string fontFamily, short fontSize, Color externalBackground = default)
{
PresentationSource source = PresentationSource.FromVisual(this);

Expand All @@ -92,7 +93,12 @@ public void SetTheme(TerminalTheme theme, string fontFamily, short fontSize)
byte g = Convert.ToByte((theme.DefaultBackground >> 8) & 0xff);
byte r = Convert.ToByte(theme.DefaultBackground & 0xff);

this.terminalGrid.Background = new SolidColorBrush(Color.FromRgb(r, g, b));
// Set the background color for the control only if one is provided.
// This is only shown when the terminal renderer is smaller than the enclosing WPF window.
if (externalBackground != default)
{
this.Background = new SolidColorBrush(externalBackground);
}
}

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/cascadia/WpfTerminalControl/TerminalTheme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

namespace Microsoft.Terminal.Wpf
{
using System;
using System.Runtime.InteropServices;

/// <summary>
Expand Down