bunch of dead ends in this

This commit is contained in:
Mike Griese 2021-09-30 16:00:37 -05:00
parent f49c3fca01
commit 3b8e7236ae
6 changed files with 62 additions and 2 deletions

View file

@ -6,7 +6,11 @@
#include "pch.h"
#include "AdminWarningPlaceholder.h"
#include "AdminWarningPlaceholder.g.cpp"
#include <UIAutomationCore.h>
#include <LibraryResources.h>
using namespace winrt::Windows::UI::Xaml;
using namespace winrt::Windows::UI::Xaml::Automation::Peers;
namespace winrt::TerminalApp::implementation
{
@ -22,19 +26,63 @@ namespace winrt::TerminalApp::implementation
{
RootGrid().Background(termControl.BackgroundBrush());
}
_layoutUpdatedRevoker = RootGrid().LayoutUpdated(winrt::auto_revoke, [this](auto /*s*/, auto /*e*/) {
// Only let this succeed once.
_layoutUpdatedRevoker.revoke();
if (auto automationPeer{ FrameworkElementAutomationPeer::FromElement(ApproveCommandlineWarningTitle()) })
{
// automationPeer.try_as<FrameworkElementAutomationPeer>().RaiseStructureChangedEvent(Automation::Peers::AutomationStructureChangeType::ChildrenBulkAdded, ApproveCommandlineWarningPrefixTextBlock());
automationPeer.RaiseNotificationEvent(
AutomationNotificationKind::ActionCompleted,
AutomationNotificationProcessing::CurrentThenMostRecent,
L"Foo",
L"ApproveCommandlineWarningTitle" /* unique name for this notification category */
);
}
CancelButton().Focus(FocusState::Programmatic);
});
}
void AdminWarningPlaceholder::_primaryButtonClick(winrt::Windows::Foundation::IInspectable const& /*sender*/,
RoutedEventArgs const& e)
{
if (auto automationPeer{ FrameworkElementAutomationPeer::FromElement(PrimaryButton()) })
{
automationPeer.RaiseNotificationEvent(
AutomationNotificationKind::ActionCompleted,
AutomationNotificationProcessing::CurrentThenMostRecent,
L"PrimaryButton",
L"_primaryButtonClick" /* unique name for this notification category */
);
}
_PrimaryButtonClickedHandlers(*this, e);
}
void AdminWarningPlaceholder::_cancelButtonClick(winrt::Windows::Foundation::IInspectable const& /*sender*/,
RoutedEventArgs const& e)
{
if (auto automationPeer{ FrameworkElementAutomationPeer::FromElement(CancelButton()) })
{
automationPeer.RaiseNotificationEvent(
AutomationNotificationKind::ActionCompleted,
AutomationNotificationProcessing::CurrentThenMostRecent,
L"CancelButton",
L"_cancelButtonClick" /* unique name for this notification category */
);
}
_CancelButtonClickedHandlers(*this, e);
}
winrt::Windows::UI::Xaml::Controls::UserControl AdminWarningPlaceholder::Control()
{
return _control;
}
winrt::hstring AdminWarningPlaceholder::ControlName() const
{
return RS_(L"AdminWarningPlaceholderControlName");
}
}

View file

@ -11,7 +11,7 @@ namespace winrt::TerminalApp::implementation
struct AdminWarningPlaceholder : AdminWarningPlaceholderT<AdminWarningPlaceholder>
{
AdminWarningPlaceholder(const winrt::Microsoft::Terminal::Control::TermControl& control, const winrt::hstring& cmdline);
winrt::hstring ControlName() const;
winrt::Windows::UI::Xaml::Controls::UserControl Control();
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Commandline, _PropertyChangedHandlers);
@ -27,5 +27,7 @@ namespace winrt::TerminalApp::implementation
winrt::Windows::UI::Xaml::RoutedEventArgs const& e);
void _cancelButtonClick(winrt::Windows::Foundation::IInspectable const& sender,
winrt::Windows::UI::Xaml::RoutedEventArgs const& e);
winrt::Windows::UI::Xaml::Controls::Grid::LayoutUpdated_revoker _layoutUpdatedRevoker;
};
}

View file

@ -7,5 +7,6 @@ namespace TerminalApp
Windows.UI.Xaml.Data.INotifyPropertyChanged
{
String Commandline { get; };
String ControlName { get; };
}
}

View file

@ -9,6 +9,8 @@
xmlns:local="using:TerminalApp"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mux="using:Microsoft.UI.Xaml.Controls"
AutomationProperties.Name="{x:Bind ControlName, Mode=OneWay}"
IsTabStop="True"
mc:Ignorable="d">
<!--
@ -33,6 +35,7 @@
CornerRadius="{ThemeResource OverlayCornerRadius}">
<StackPanel Orientation="Vertical">
<TextBlock x:Uid="ApproveCommandlineWarningTitle"
x:Name="ApproveCommandlineWarningTitle"
Padding="0,0,0,16"
HorizontalAlignment="Left"
FontSize="20"
@ -40,6 +43,7 @@
TextWrapping="WrapWholeWords" />
<TextBlock x:Uid="ApproveCommandlineWarningPrefixTextBlock"
x:Name="ApproveCommandlineWarningPrefixTextBlock"
HorizontalAlignment="Left"
TextWrapping="WrapWholeWords" />
@ -57,11 +61,13 @@
<Button x:Name="PrimaryButton"
x:Uid="ApproveCommandlineWarning_PrimaryButton"
Margin="8"
IsTabStop="True"
HorizontalAlignment="Right"
Click="_primaryButtonClick"
Style="{StaticResource AccentButtonStyle}" />
<Button x:Name="CancelButton"
x:Uid="ApproveCommandlineWarning_CancelButton"
IsTabStop="True"
HorizontalAlignment="Right"
Click="_cancelButtonClick" />
</StackPanel>

View file

@ -564,6 +564,9 @@
<value>Enter a wt commandline to run</value>
<comment>{Locked="wt"} </comment>
</data>
<data name="AdminWarningPlaceholderControlName" xml:space="preserve">
<value>Admin Warning Dialog</value>
</data>
<data name="CrimsonColorButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Crimson</value>
</data>

View file

@ -1616,7 +1616,7 @@ namespace winrt::TerminalApp::implementation
{
// NOTE: For debugging purposes, changing this to `true || IsElevated()`
// is a handy way of forcing the elevation logic, even when unelevated.
if (IsElevated())
if (true || IsElevated())
{
// If the cmdline is EXACTLY an executable in
// `C:\WINDOWS\System32`, then ignore this check.