@@ -1057,6 +1057,15 @@ namespace winrt::TerminalApp::implementation
1057
1057
}
1058
1058
});
1059
1059
1060
+ // Using the static method on the base class seems to do what we want in terms of placement.
1061
+ WUX::Controls::Primitives::FlyoutBase::SetAttachedFlyout (profileMenuItem, _CreateRunAsAdminFlyout (profileIndex));
1062
+
1063
+ // Since we are not setting the ContextFlyout property of the item we have to handle the ContextRequested event
1064
+ // and rely on the base class to show our menu.
1065
+ profileMenuItem.ContextRequested ([profileMenuItem](auto &&, auto &&) {
1066
+ WUX::Controls::Primitives::FlyoutBase::ShowAttachedFlyout (profileMenuItem);
1067
+ });
1068
+
1060
1069
return profileMenuItem;
1061
1070
}
1062
1071
@@ -4113,6 +4122,33 @@ namespace winrt::TerminalApp::implementation
4113
4122
}
4114
4123
}
4115
4124
4125
+ winrt::fire_and_forget TerminalPage::ShowTerminalWorkingDirectory ()
4126
+ {
4127
+ auto weakThis{ get_weak () };
4128
+ co_await wil::resume_foreground (Dispatcher ());
4129
+ if (auto page{ weakThis.get () })
4130
+ {
4131
+ // If we haven't ever loaded the TeachingTip, then do so now and
4132
+ // create the toast for it.
4133
+ if (page->_windowCwdToast == nullptr )
4134
+ {
4135
+ if (auto tip{ page->FindName (L" WindowCwdToast" ).try_as <MUX::Controls::TeachingTip>() })
4136
+ {
4137
+ page->_windowCwdToast = std::make_shared<Toast>(tip);
4138
+ // Make sure to use the weak ref when setting up this
4139
+ // callback.
4140
+ tip.Closed ({ page->get_weak (), &TerminalPage::_FocusActiveControl });
4141
+ }
4142
+ }
4143
+ _UpdateTeachingTipTheme (WindowCwdToast ().try_as <winrt::Windows::UI::Xaml::FrameworkElement>());
4144
+
4145
+ if (page->_windowCwdToast != nullptr )
4146
+ {
4147
+ page->_windowCwdToast ->Open ();
4148
+ }
4149
+ }
4150
+ }
4151
+
4116
4152
// Method Description:
4117
4153
// - Called when the user hits the "Ok" button on the WindowRenamer TeachingTip.
4118
4154
// - Will raise an event that will bubble up to the monarch, asking if this
@@ -4940,4 +4976,42 @@ namespace winrt::TerminalApp::implementation
4940
4976
// _RemoveTab will make sure to null out the _stashed.draggedTab
4941
4977
_RemoveTab (*_stashed.draggedTab );
4942
4978
}
4979
+
4980
+ // / <summary>
4981
+ // / Creates a sub flyout menu for profile items in the split button menu that when clicked will show a menu item for
4982
+ // / Run as Administrator
4983
+ // / </summary>
4984
+ // / <param name="profileIndex">The index for the profileMenuItem</param>
4985
+ // / <returns>MenuFlyout that will show when the context is request on a profileMenuItem</returns>
4986
+ WUX::Controls::MenuFlyout TerminalPage::_CreateRunAsAdminFlyout (int profileIndex)
4987
+ {
4988
+ // Create the MenuFlyout and set its placement
4989
+ WUX::Controls::MenuFlyout profileMenuItemFlyout{};
4990
+ profileMenuItemFlyout.Placement (WUX::Controls::Primitives::FlyoutPlacementMode::BottomEdgeAlignedRight);
4991
+
4992
+ // Create the menu item and an icon to use in the menu
4993
+ WUX::Controls::MenuFlyoutItem runAsAdminItem{};
4994
+ WUX::Controls::FontIcon adminShieldIcon{};
4995
+
4996
+ adminShieldIcon.Glyph (L" \xEA18 " );
4997
+ adminShieldIcon.FontFamily (Media::FontFamily{ L" Segoe Fluent Icons, Segoe MDL2 Assets" });
4998
+
4999
+ runAsAdminItem.Icon (adminShieldIcon);
5000
+ runAsAdminItem.Text (RS_ (L" RunAsAdminFlyout/Text" ));
5001
+
5002
+ // Click handler for the flyout item
5003
+ runAsAdminItem.Click ([profileIndex, weakThis{ get_weak () }](auto &&, auto &&) {
5004
+ if (auto page{ weakThis.get () })
5005
+ {
5006
+ NewTerminalArgs args{ profileIndex };
5007
+ args.Elevate (true );
5008
+ page->_OpenNewTerminalViaDropdown (args);
5009
+ }
5010
+ });
5011
+
5012
+ profileMenuItemFlyout.Items ().Append (runAsAdminItem);
5013
+
5014
+ return profileMenuItemFlyout;
5015
+ }
5016
+
4943
5017
}
0 commit comments