use the background from the control when we can
This commit is contained in:
parent
62fe8235dc
commit
5e9d0b8195
|
@ -15,6 +15,13 @@ namespace winrt::TerminalApp::implementation
|
||||||
_Commandline{ cmdline }
|
_Commandline{ cmdline }
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
// If the content we're hosting is a TermControl, then use the control's
|
||||||
|
// BG as our BG, to give the impression that it's there, under the
|
||||||
|
// dialog.
|
||||||
|
if (const auto termControl{ control.try_as<winrt::Microsoft::Terminal::Control::TermControl>() })
|
||||||
|
{
|
||||||
|
RootGrid().Background(termControl.BackgroundBrush());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void AdminWarningPlaceholder::_primaryButtonClick(winrt::Windows::Foundation::IInspectable const& /*sender*/,
|
void AdminWarningPlaceholder::_primaryButtonClick(winrt::Windows::Foundation::IInspectable const& /*sender*/,
|
||||||
RoutedEventArgs const& e)
|
RoutedEventArgs const& e)
|
||||||
|
|
|
@ -11,50 +11,63 @@
|
||||||
xmlns:mux="using:Microsoft.UI.Xaml.Controls"
|
xmlns:mux="using:Microsoft.UI.Xaml.Controls"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
|
||||||
<Grid HorizontalAlignment="Center"
|
<!--
|
||||||
VerticalAlignment="Center">
|
We have to use two grids to be tricky here:
|
||||||
<Border Margin="8,8,8,8"
|
- The outer grid will get its background from the control it hosts, and
|
||||||
Padding="16,8,16,8"
|
expands to fit its container. This will make it look like the background
|
||||||
Background="{ThemeResource SystemControlBackgroundAltHighBrush}"
|
fills the space available.
|
||||||
BorderBrush="{ThemeResource SystemAccentColor}"
|
- The inner grid is set to Center,Center, so that the "dialog" appears
|
||||||
BorderThickness="2,2,2,2"
|
centered
|
||||||
CornerRadius="{ThemeResource OverlayCornerRadius}">
|
-->
|
||||||
<StackPanel Orientation="Vertical">
|
|
||||||
<TextBlock x:Uid="ApproveCommandlineWarningTitle"
|
|
||||||
Padding="0,0,0,16"
|
|
||||||
HorizontalAlignment="Left"
|
|
||||||
FontSize="20"
|
|
||||||
FontWeight="Normal"
|
|
||||||
TextWrapping="WrapWholeWords" />
|
|
||||||
|
|
||||||
<TextBlock x:Uid="ApproveCommandlineWarningPrefixTextBlock"
|
<Grid x:Name="RootGrid"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Stretch"
|
||||||
TextWrapping="WrapWholeWords" />
|
VerticalAlignment="Stretch">
|
||||||
|
<Grid HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center">
|
||||||
|
<Border Margin="8,8,8,8"
|
||||||
|
Padding="16,8,16,8"
|
||||||
|
Background="{ThemeResource SystemControlBackgroundAltHighBrush}"
|
||||||
|
BorderBrush="{ThemeResource SystemAccentColor}"
|
||||||
|
BorderThickness="2,2,2,2"
|
||||||
|
CornerRadius="{ThemeResource OverlayCornerRadius}">
|
||||||
|
<StackPanel Orientation="Vertical">
|
||||||
|
<TextBlock x:Uid="ApproveCommandlineWarningTitle"
|
||||||
|
Padding="0,0,0,16"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
FontSize="20"
|
||||||
|
FontWeight="Normal"
|
||||||
|
TextWrapping="WrapWholeWords" />
|
||||||
|
|
||||||
<TextBlock Margin="0,8,0,8"
|
<TextBlock x:Uid="ApproveCommandlineWarningPrefixTextBlock"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Left"
|
||||||
FontFamily="Cascadia Code"
|
TextWrapping="WrapWholeWords" />
|
||||||
Text="{x:Bind Commandline, Mode=OneWay}"
|
|
||||||
TextWrapping="WrapWholeWords" />
|
|
||||||
|
|
||||||
<TextBlock x:Uid="ApproveCommandlineWarningSuffixTextBlock"
|
<TextBlock Margin="0,8,0,8"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Center"
|
||||||
TextWrapping="WrapWholeWords" />
|
FontFamily="Cascadia Code"
|
||||||
<StackPanel HorizontalAlignment="Right"
|
Text="{x:Bind Commandline, Mode=OneWay}"
|
||||||
Orientation="Horizontal">
|
TextWrapping="WrapWholeWords" />
|
||||||
<Button x:Name="PrimaryButton"
|
|
||||||
x:Uid="ApproveCommandlineWarning_PrimaryButton"
|
<TextBlock x:Uid="ApproveCommandlineWarningSuffixTextBlock"
|
||||||
Margin="8"
|
HorizontalAlignment="Left"
|
||||||
HorizontalAlignment="Right"
|
TextWrapping="WrapWholeWords" />
|
||||||
Click="_primaryButtonClick"
|
<StackPanel HorizontalAlignment="Right"
|
||||||
Style="{StaticResource AccentButtonStyle}" />
|
Orientation="Horizontal">
|
||||||
<Button x:Name="CancelButton"
|
<Button x:Name="PrimaryButton"
|
||||||
x:Uid="ApproveCommandlineWarning_CancelButton"
|
x:Uid="ApproveCommandlineWarning_PrimaryButton"
|
||||||
HorizontalAlignment="Right"
|
Margin="8"
|
||||||
Click="_cancelButtonClick" />
|
HorizontalAlignment="Right"
|
||||||
|
Click="_primaryButtonClick"
|
||||||
|
Style="{StaticResource AccentButtonStyle}" />
|
||||||
|
<Button x:Name="CancelButton"
|
||||||
|
x:Uid="ApproveCommandlineWarning_CancelButton"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Click="_cancelButtonClick" />
|
||||||
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</Border>
|
||||||
</Border>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|
|
@ -1597,10 +1597,9 @@ namespace winrt::TerminalApp::implementation
|
||||||
// - true if we should prompt the user for approval.
|
// - true if we should prompt the user for approval.
|
||||||
bool TerminalPage::_shouldPromptForCommandline(const winrt::hstring& cmdline) const
|
bool TerminalPage::_shouldPromptForCommandline(const winrt::hstring& cmdline) const
|
||||||
{
|
{
|
||||||
// NOTE: For debugging purposes, changing this to `true ||
|
// NOTE: For debugging purposes, changing this to `true || _isElevated()`
|
||||||
// _isElevated()` is a handy way of forcing the elevation logic, even
|
// is a handy way of forcing the elevation logic, even when unelevated.
|
||||||
// when unelevated.
|
if (true || _isElevated())
|
||||||
if (_isElevated())
|
|
||||||
{
|
{
|
||||||
// If the cmdline is EXACTLY an executable in
|
// If the cmdline is EXACTLY an executable in
|
||||||
// `C:\WINDOWS\System32`, then ignore this check.
|
// `C:\WINDOWS\System32`, then ignore this check.
|
||||||
|
|
|
@ -2590,4 +2590,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||||
{
|
{
|
||||||
return _core.ReadEntireBuffer();
|
return _core.ReadEntireBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Media::Brush TermControl::BackgroundBrush()
|
||||||
|
{
|
||||||
|
return RootGrid().Background();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,6 +111,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||||
|
|
||||||
hstring ReadEntireBuffer() const;
|
hstring ReadEntireBuffer() const;
|
||||||
|
|
||||||
|
Windows::UI::Xaml::Media::Brush BackgroundBrush();
|
||||||
|
|
||||||
// -------------------------------- WinRT Events ---------------------------------
|
// -------------------------------- WinRT Events ---------------------------------
|
||||||
// clang-format off
|
// clang-format off
|
||||||
WINRT_CALLBACK(FontSizeChanged, Control::FontSizeChangedEventArgs);
|
WINRT_CALLBACK(FontSizeChanged, Control::FontSizeChangedEventArgs);
|
||||||
|
|
|
@ -71,5 +71,7 @@ namespace Microsoft.Terminal.Control
|
||||||
void ToggleReadOnly();
|
void ToggleReadOnly();
|
||||||
|
|
||||||
String ReadEntireBuffer();
|
String ReadEntireBuffer();
|
||||||
|
|
||||||
|
Windows.UI.Xaml.Media.Brush BackgroundBrush { get; };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ static winrt::com_ptr<implementation::Profile> makeProfile(const std::wstring& d
|
||||||
wil::unique_cotaskmem_string systemPath;
|
wil::unique_cotaskmem_string systemPath;
|
||||||
THROW_IF_FAILED(wil::GetSystemDirectoryW(systemPath));
|
THROW_IF_FAILED(wil::GetSystemDirectoryW(systemPath));
|
||||||
std::wstring command(systemPath.get());
|
std::wstring command(systemPath.get());
|
||||||
WSLDistro->Commandline(command + L"\\wsl.exe -d " + distName);
|
WSLDistro->Commandline(winrt::hstring{ command + L"\\wsl.exe -d " + distName });
|
||||||
WSLDistro->DefaultAppearance().ColorSchemeName(L"Campbell");
|
WSLDistro->DefaultAppearance().ColorSchemeName(L"Campbell");
|
||||||
WSLDistro->StartingDirectory(winrt::hstring{ DEFAULT_STARTING_DIRECTORY });
|
WSLDistro->StartingDirectory(winrt::hstring{ DEFAULT_STARTING_DIRECTORY });
|
||||||
WSLDistro->Icon(L"ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png");
|
WSLDistro->Icon(L"ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png");
|
||||||
|
|
Loading…
Reference in a new issue