From 0c4fb00d25b37acfbfad850d34ae16d605ba5006 Mon Sep 17 00:00:00 2001 From: andreww-msft <30507740+andreww-msft@users.noreply.github.com> Date: Tue, 4 Jun 2024 16:05:28 -0700 Subject: [PATCH] AdditionalTools validation & feedback (#3108) * AdditionalTools validation & feedback * Updates per feedback * More updates per feedback * More feedback, another update * Second half of the pin icon fix I missed last time. * Updates per feedback. --- tools/PI/DevHome.PI/BarWindowHorizontal.xaml | 2 +- .../PI/DevHome.PI/BarWindowHorizontal.xaml.cs | 15 ++ tools/PI/DevHome.PI/BarWindowVertical.xaml | 2 +- tools/PI/DevHome.PI/BarWindowVertical.xaml.cs | 10 ++ .../DevHome.PI/Controls/AddToolControl.xaml | 154 ++++++++---------- .../Controls/AddToolControl.xaml.cs | 29 +++- .../DevHome.PI/Controls/EditToolsControl.xaml | 18 +- .../Controls/EditToolsControl.xaml.cs | 26 ++- tools/PI/DevHome.PI/Helpers/WindowHelper.cs | 55 ++++++- tools/PI/DevHome.PI/Pages/AppDetailsPage.xaml | 2 +- .../DevHome.PI/Strings/en-us/Resources.resw | 68 +++++++- 11 files changed, 274 insertions(+), 107 deletions(-) diff --git a/tools/PI/DevHome.PI/BarWindowHorizontal.xaml b/tools/PI/DevHome.PI/BarWindowHorizontal.xaml index 06c36c5760..9215d0b1a3 100644 --- a/tools/PI/DevHome.PI/BarWindowHorizontal.xaml +++ b/tools/PI/DevHome.PI/BarWindowHorizontal.xaml @@ -83,7 +83,7 @@ HorizontalAlignment="Center" Click="ManageExternalToolsButton_Click"> - + diff --git a/tools/PI/DevHome.PI/BarWindowHorizontal.xaml.cs b/tools/PI/DevHome.PI/BarWindowHorizontal.xaml.cs index 1cecbf979a..02bf7e1c10 100644 --- a/tools/PI/DevHome.PI/BarWindowHorizontal.xaml.cs +++ b/tools/PI/DevHome.PI/BarWindowHorizontal.xaml.cs @@ -36,6 +36,8 @@ public partial class BarWindowHorizontal : WindowEx private readonly string _pinMenuItemText = CommonHelper.GetLocalizedString("PinMenuItemText"); private readonly string _unpinMenuItemText = CommonHelper.GetLocalizedString("UnpinMenuItemText"); private readonly BarWindowViewModel _viewModel; + private readonly FontIcon _pinIcon = new() { Glyph = "\uE718" }; + private readonly FontIcon _unpinIcon = new() { Glyph = "\uE77A" }; private ExternalTool? _selectedExternalTool; private INotifyCollectionChanged? _externalTools; @@ -227,6 +229,15 @@ private void ManageExternalToolsButton_Click(object sender, RoutedEventArgs e) ExpandedViewControl.NavigateToSettings(typeof(AdditionalToolsViewModel).FullName!); } + private void ExternalToolsMenu_Opening(object sender, object e) + { + // Cancel the opening of the menu if there are no items. + if (sender is MenuFlyout flyout && flyout?.Items?.Count == 0) + { + flyout.Hide(); + } + } + private void ExternalToolMenuItem_RightTapped(object sender, RightTappedRoutedEventArgs e) { var menuItem = sender as MenuFlyoutItem; @@ -236,10 +247,12 @@ private void ExternalToolMenuItem_RightTapped(object sender, RightTappedRoutedEv if (_selectedExternalTool.IsPinned) { PinUnpinMenuItem.Text = _unpinMenuItemText; + PinUnpinMenuItem.Icon = _unpinIcon; } else { PinUnpinMenuItem.Text = _pinMenuItemText; + PinUnpinMenuItem.Icon = _pinIcon; } ToolContextMenu.ShowAt(menuItem, e.GetPosition(menuItem)); @@ -291,10 +304,12 @@ private void ExternalToolButton_PointerPressed(object sender, PointerRoutedEvent if (_selectedExternalTool.IsPinned) { PinUnpinMenuItem.Text = _unpinMenuItemText; + PinUnpinMenuItem.Icon = _unpinIcon; } else { PinUnpinMenuItem.Text = _pinMenuItemText; + PinUnpinMenuItem.Icon = _pinIcon; } } } diff --git a/tools/PI/DevHome.PI/BarWindowVertical.xaml b/tools/PI/DevHome.PI/BarWindowVertical.xaml index 5ef7f3c187..625f31b92d 100644 --- a/tools/PI/DevHome.PI/BarWindowVertical.xaml +++ b/tools/PI/DevHome.PI/BarWindowVertical.xaml @@ -85,7 +85,7 @@ x:Uid="ManageExternalToolsButton" HorizontalAlignment="Center"> - + diff --git a/tools/PI/DevHome.PI/BarWindowVertical.xaml.cs b/tools/PI/DevHome.PI/BarWindowVertical.xaml.cs index c42a568d89..91f0b347d0 100644 --- a/tools/PI/DevHome.PI/BarWindowVertical.xaml.cs +++ b/tools/PI/DevHome.PI/BarWindowVertical.xaml.cs @@ -95,6 +95,16 @@ private void MainPanel_Loaded(object sender, RoutedEventArgs e) Width = 70; } + private void ExternalToolsMenu_Opening(object sender, object e) + { + // Cancel the opening of the menu if there are no items. + var flyout = sender as MenuFlyout; + if (flyout is not null && flyout.Items is not null && flyout.Items.Count == 0) + { + flyout.Hide(); + } + } + private void ExternalToolButton_Click(object sender, RoutedEventArgs e) { if (sender is Button clickedButton) diff --git a/tools/PI/DevHome.PI/Controls/AddToolControl.xaml b/tools/PI/DevHome.PI/Controls/AddToolControl.xaml index 436f7cda95..9a30aa8d1b 100644 --- a/tools/PI/DevHome.PI/Controls/AddToolControl.xaml +++ b/tools/PI/DevHome.PI/Controls/AddToolControl.xaml @@ -17,95 +17,83 @@ - - - - - - - - - - -