From 315c7a44f5a3a71440f075e41d5c7b07a0a93d90 Mon Sep 17 00:00:00 2001 From: michael-hawker Date: Tue, 17 Sep 2019 15:56:55 -0700 Subject: [PATCH 1/2] Remove the Menu Control --- .../SamplePages/Menu/Commands/VsCommands.cs | 91 --- .../SamplePages/Menu/Menu.bind | 228 -------- .../SamplePages/Menu/Menu.png | Bin 1281 -> 0 bytes .../SamplePages/Menu/MenuPage.xaml | 19 - .../SamplePages/Menu/MenuPage.xaml.cs | 66 --- .../SamplePages/samples.json | 12 - .../Menu/Menu.Events.cs | 232 -------- .../Menu/Menu.Extensions.cs | 87 --- .../Menu/Menu.Logic.cs | 303 ---------- .../Menu/Menu.cs | 134 ----- .../Menu/Menu.xaml | 252 --------- .../Menu/MenuItem.cs | 531 ------------------ .../Microsoft.Toolkit.Uwp.UI.Controls.csproj | 1 - .../Themes/Generic.xaml | 1 - 14 files changed, 1957 deletions(-) delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/Commands/VsCommands.cs delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/Menu.bind delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/Menu.png delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/MenuPage.xaml delete mode 100644 Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/MenuPage.xaml.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.Events.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.Extensions.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.Logic.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.xaml delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls/Menu/MenuItem.cs diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/Commands/VsCommands.cs b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/Commands/VsCommands.cs deleted file mode 100644 index 41de6099bbc..00000000000 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/Commands/VsCommands.cs +++ /dev/null @@ -1,91 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Windows.Input; -using Windows.UI.Popups; - -namespace Microsoft.Toolkit.Uwp.SampleApp.Menu.Commands -{ -#pragma warning disable SA1649 // File name must match first type name - internal class NewProjectCommand : ICommand -#pragma warning restore SA1649 // File name must match first type name - { - event EventHandler ICommand.CanExecuteChanged - { - add - { - } - - remove - { - } - } - - public bool CanExecute(object parameter) - { - return true; - } - - public async void Execute(object parameter) - { - var dialog = new MessageDialog("Create New Project"); - await dialog.ShowAsync(); - } - } - -#pragma warning disable SA1402 // File may only contain a single class - internal class NewFileCommand : ICommand -#pragma warning restore SA1402 // File may only contain a single class - { - event EventHandler ICommand.CanExecuteChanged - { - add - { - } - - remove - { - } - } - - public bool CanExecute(object parameter) - { - return true; - } - - public async void Execute(object parameter) - { - var dialog = new MessageDialog("Create New File"); - await dialog.ShowAsync(); - } - } - -#pragma warning disable SA1402 // File may only contain a single class - internal class GenericCommand : ICommand -#pragma warning restore SA1402 // File may only contain a single class - { - event EventHandler ICommand.CanExecuteChanged - { - add - { - } - - remove - { - } - } - - public bool CanExecute(object parameter) - { - return true; - } - - public async void Execute(object parameter) - { - var dialog = new MessageDialog(parameter.ToString()); - await dialog.ShowAsync(); - } - } -} diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/Menu.bind b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/Menu.bind deleted file mode 100644 index acb89e9136d..00000000000 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/Menu.bind +++ /dev/null @@ -1,228 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/Menu.png b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/Menu.png deleted file mode 100644 index 09031f8fa40bb0cab5d16d2384bd8155e6294fbf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1281 zcmeAS@N?(olHy`uVBq!ia0y~yU{nCI4{)#n$t4^1Z39v)#ZI0f96(URk!#(qMuKE?hz{nlH|DL-);~w{B z`Ag~y_w*T=l2|x81QitA8X6?Vxi)&2kK`~Np04y)_leM%A*5Kwk-=wVx5ZJ>(XYSQU4FSmPhbD_vuDS?rf=B2JDQ!Hee2e(S6}|xzI}UX zMMcE(=g;TfV_$Wzfa%t~d++|74iDYBX;aYRizmLOmz0!Tv9t>fm6nz+EhxC~vv$F$ z`3ZXt-MJI`(Z)?PA84=wCef4}bmoHT{d^2?Iv7AV3L^{BI#V|KzQ$ zt>uqB{&=at;?33bpZ@*(_w&n_FE1ZGdQ|*N=gV}?6@|Zl|2|#Y?H_tI!C;1b|8eh^ z#TW9Ku2}f5SdhweWyj>nlb4@N`J`IgS6@|8QDJ9oU48a)ScQ9)`7Yzx-QC^i?a~*9 zs^N>oV{pZ39$Vi3V) zy-<4l=FOiIL2hh69QRiz_wZ*SwFSrCzJIU(UDqyj+rvsp#w?IMY7V`xUz`0oeE9I^ zn>TMR2Rd{6z20|cj*;L_s4*Z{v8*WE_AoQ@y<2%&vh=)ZGx27Hawl_0aDYQa7#3!3^&&$scMnx~kRO S`4m{DF?hQAxvX - - - - - - - - - - \ No newline at end of file diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/MenuPage.xaml.cs b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/MenuPage.xaml.cs deleted file mode 100644 index 06ca9a5b57d..00000000000 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/MenuPage.xaml.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Toolkit.Uwp.UI.Controls; -using Microsoft.Toolkit.Uwp.UI.Extensions; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; - -namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages -{ - public sealed partial class MenuPage : IXamlRenderListener - { - private MenuItem fileMenu; - - public MenuPage() - { - InitializeComponent(); - Load(); - } - - public void OnXamlRendered(FrameworkElement control) - { - fileMenu = control.FindChildByName("FileMenu") as MenuItem; - } - - private void Load() - { - SampleController.Current.RegisterNewCommand("Append Item to file menu", (sender, args) => - { - if (fileMenu != null) - { - var flyoutItem = new MenuFlyoutItem - { - Text = "Click to remove" - }; - - flyoutItem.Click += (a, b) => - { - fileMenu.Items.Remove(flyoutItem); - }; - - fileMenu.Items.Add(flyoutItem); - } - }); - - SampleController.Current.RegisterNewCommand("Prepend Item to file menu", (sender, args) => - { - if (fileMenu != null) - { - var flyoutItem = new MenuFlyoutItem - { - Text = "Click to remove" - }; - - flyoutItem.Click += (a, b) => - { - fileMenu.Items.Remove(flyoutItem); - }; - - fileMenu.Items.Insert(0, flyoutItem); - } - }); - } - } -} diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json index 5089c58954b..501bd92f624 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json @@ -239,18 +239,6 @@ "Icon": "/SamplePages/OrbitView/OrbitView.png", "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/OrbitView.md" }, - { - "Name": "Menu", - "Type": "MenuPage", - "Subcategory": "Menus and Toolbars", - "About": "This control will be removed in a future major release. Please use the MenuBar control from the WinUI Library instead.", - "BadgeUpdateVersionRequired": "DEPRECATED", - "DeprecatedWarning": "This control will be removed in a future major release. Please use the MenuBar control from the WinUI Library instead.", - "CodeUrl": "https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/Menu", - "XamlCodeFile": "Menu.bind", - "Icon": "/SamplePages/Menu/Menu.png", - "DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/Menu.md" - }, { "Name": "InAppNotification", "Type": "InAppNotificationPage", diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.Events.cs b/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.Events.cs deleted file mode 100644 index fba628da34e..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.Events.cs +++ /dev/null @@ -1,232 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Windows.Foundation; -using Windows.System; -using Windows.UI.Core; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Input; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// Menu Control defines a menu of choices for users to invoke. - /// - public partial class Menu - { - private const uint AltScanCode = 56; - private bool _onlyAltCharacterPressed = true; - private Control _lastFocusElement; - private bool _isLostFocus = true; - private Control _lastFocusElementBeforeMenu; - private Rect _bounds; - - private bool AllowTooltip => (bool)GetValue(AllowTooltipProperty); - - private void Menu_Loaded(object sender, RoutedEventArgs e) - { - _wrapPanel = ItemsPanelRoot as WrapPanel; - if (_wrapPanel != null) - { - _wrapPanel.Orientation = Orientation; - } - - UpdateMenuItemsFlyoutPlacement(); - - Window.Current.CoreWindow.PointerMoved -= CoreWindow_PointerMoved; - LostFocus -= Menu_LostFocus; - LostFocus += Menu_LostFocus; - Dispatcher.AcceleratorKeyActivated -= Dispatcher_AcceleratorKeyActivated; - Window.Current.CoreWindow.KeyDown -= CoreWindow_KeyDown; - Dispatcher.AcceleratorKeyActivated += Dispatcher_AcceleratorKeyActivated; - Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown; - Window.Current.CoreWindow.PointerMoved += CoreWindow_PointerMoved; - } - - private void Menu_Unloaded(object sender, RoutedEventArgs e) - { - Window.Current.CoreWindow.PointerMoved -= CoreWindow_PointerMoved; - Dispatcher.AcceleratorKeyActivated -= Dispatcher_AcceleratorKeyActivated; - Window.Current.CoreWindow.KeyDown -= CoreWindow_KeyDown; - - // Clear Cache - foreach (MenuItem menuItem in Items) - { - var menuFlyoutItems = menuItem.GetMenuFlyoutItems(); - foreach (var flyoutItem in menuFlyoutItems) - { - RemoveElementFromCache(flyoutItem); - } - - RemoveElementFromCache(menuItem); - } - } - - private void CoreWindow_PointerMoved(CoreWindow sender, PointerEventArgs args) - { - // if contained with the whole Menu control - if (IsOpened && _bounds.Contains(args.CurrentPoint.Position)) - { - // if hover over current opened item - if (SelectedMenuItem.ContainsPoint(args.CurrentPoint.Position)) - { - return; - } - - foreach (MenuItem menuItem in Items) - { - if (menuItem.ContainsPoint(args.CurrentPoint.Position)) - { - SelectedMenuItem.HideMenu(); - menuItem.Focus(FocusState.Keyboard); - menuItem.ShowMenu(); - } - } - } - } - - private void CoreWindow_KeyDown(CoreWindow sender, KeyEventArgs args) - { - if (IsInTransitionState) - { - return; - } - - if (NavigateUsingKeyboard(args, this, Orientation)) - { - return; - } - - string gestureKey = MapInputToGestureKey(args.VirtualKey); - - if (gestureKey == null) - { - return; - } - - if (MenuItemInputGestureCache.ContainsKey(gestureKey)) - { - var cachedMenuItem = MenuItemInputGestureCache[gestureKey]; - if (cachedMenuItem is MenuFlyoutItem) - { - var menuFlyoutItem = (MenuFlyoutItem)cachedMenuItem; - menuFlyoutItem.Command?.Execute(menuFlyoutItem.CommandParameter); - } - } - } - - private void Menu_LostFocus(object sender, RoutedEventArgs e) - { - var menuItem = FocusManager.GetFocusedElement() as MenuItem; - - if (AllowTooltip) - { - HideMenuItemsTooltips(); - } - - if (menuItem != null || IsOpened) - { - return; - } - - _isLostFocus = true; - if (!AllowTooltip) - { - RemoveUnderlineMenuItems(); - } - } - - private void Dispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args) - { - if (Items.Count == 0) - { - return; - } - - _lastFocusElement = FocusManager.GetFocusedElement() as Control; - - if (args.KeyStatus.ScanCode != AltScanCode) - { - _onlyAltCharacterPressed = false; - } - - if (args.VirtualKey == VirtualKey.Menu) - { - if (!IsOpened) - { - if (_isLostFocus) - { - if (_onlyAltCharacterPressed && args.KeyStatus.IsKeyReleased) - { - ((MenuItem)Items[0]).Focus(FocusState.Programmatic); - - if (!(_lastFocusElement is MenuItem)) - { - _lastFocusElementBeforeMenu = _lastFocusElement; - } - } - - if (AllowTooltip) - { - ShowMenuItemsToolTips(); - } - else - { - UnderlineMenuItems(); - } - - if (args.KeyStatus.IsKeyReleased) - { - _isLostFocus = false; - } - } - else if (args.KeyStatus.IsKeyReleased) - { - HideToolTip(); - _lastFocusElementBeforeMenu?.Focus(FocusState.Keyboard); - } - } - } - else if ((args.KeyStatus.IsMenuKeyDown || !_isLostFocus) && args.KeyStatus.IsKeyReleased) - { - var gestureKey = MapInputToGestureKey(args.VirtualKey, !_isLostFocus); - if (gestureKey == null) - { - return; - } - - if (MenuItemInputGestureCache.ContainsKey(gestureKey)) - { - var cachedMenuItem = MenuItemInputGestureCache[gestureKey]; - if (cachedMenuItem is MenuItem) - { - var menuItem = (MenuItem)cachedMenuItem; - menuItem.ShowMenu(); - menuItem.Focus(FocusState.Keyboard); - } - } - } - - if (args.KeyStatus.IsKeyReleased && args.EventType == CoreAcceleratorKeyEventType.KeyUp) - { - _onlyAltCharacterPressed = true; - _isLostFocus = true; - HideToolTip(); - } - } - - private void HideToolTip() - { - if (AllowTooltip) - { - HideMenuItemsTooltips(); - } - else - { - RemoveUnderlineMenuItems(); - } - } - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.Extensions.cs b/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.Extensions.cs deleted file mode 100644 index 9cf5afc5e40..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.Extensions.cs +++ /dev/null @@ -1,87 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Windows.UI.Xaml; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// Menu Control defines a menu of choices for users to invoke. - /// - public partial class Menu - { - private const string InputGestureTextName = "InputGestureText"; - private const string AllowTooltipName = "AllowTooltip"; - - /// - /// Sets the text describing an input gesture that will call the command tied to the specified item. - /// - public static readonly DependencyProperty InputGestureTextProperty = DependencyProperty.RegisterAttached(InputGestureTextName, typeof(string), typeof(FrameworkElement), new PropertyMetadata(null, InputGestureTextChanged)); - - private static void InputGestureTextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) - { - var element = sender as FrameworkElement; - - var inputGestureValue = element?.GetValue(InputGestureTextProperty).ToString(); - if (string.IsNullOrEmpty(inputGestureValue)) - { - return; - } - - inputGestureValue = inputGestureValue.ToUpper(); - if (MenuItemInputGestureCache.ContainsKey(inputGestureValue)) - { - MenuItemInputGestureCache[inputGestureValue] = element; - return; - } - - MenuItemInputGestureCache.Add(inputGestureValue.ToUpper(), element); - } - - /// - /// Gets InputGestureText attached property - /// - /// Target MenuFlyoutItem - /// Input gesture text - public static string GetInputGestureText(FrameworkElement obj) - { - return (string)obj.GetValue(InputGestureTextProperty); - } - - /// - /// Sets InputGestureText attached property - /// - /// Target MenuFlyoutItem - /// Input gesture text - public static void SetInputGestureText(FrameworkElement obj, string value) - { - obj.SetValue(InputGestureTextProperty, value); - } - - /// - /// Gets or sets a value indicating whether to allow tooltip on alt or not - /// - public static readonly DependencyProperty AllowTooltipProperty = DependencyProperty.RegisterAttached(AllowTooltipName, typeof(bool), typeof(Menu), new PropertyMetadata(false)); - - /// - /// Gets AllowTooltip attached property - /// - /// Target Menu - /// AllowTooltip - public static bool GetAllowTooltip(Menu obj) - { - return (bool)obj.GetValue(AllowTooltipProperty); - } - - /// - /// Sets AllowTooltip attached property - /// - /// Target Menu - /// AllowTooltip - public static void SetAllowTooltip(Menu obj, bool value) - { - obj.SetValue(AllowTooltipProperty, value); - } - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.Logic.cs b/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.Logic.cs deleted file mode 100644 index 84fe733e1c4..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.Logic.cs +++ /dev/null @@ -1,303 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Linq; -using System.Text; -using Windows.Foundation; -using Windows.System; -using Windows.UI.Core; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Input; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// Menu Control defines a menu of choices for users to invoke. - /// - public partial class Menu - { - private const string CtrlValue = "CTRL"; - private const string ShiftValue = "SHIFT"; - private const string AltValue = "ALT"; - - /// - /// Gets or sets the current flyout placement, internal because the child menu item needs it to respect the menu direction of submenus - /// - internal FlyoutPlacementMode? CurrentFlyoutPlacement { get; set; } - - private static bool NavigateUsingKeyboard(KeyEventArgs args, Menu menu, Orientation orientation) - { - var element = FocusManager.GetFocusedElement(); - - if (element is MenuFlyoutPresenter && - ((args.VirtualKey == VirtualKey.Down) || - (args.VirtualKey == VirtualKey.Up) || - (args.VirtualKey == VirtualKey.Left) || - (args.VirtualKey == VirtualKey.Right))) - { - // Hack to delay and let next element get focus - FocusManager.FindNextFocusableElement(FocusNavigationDirection.Right); - return true; - } - - if (!menu.IsOpened && element is MenuItem) - { - menu.UpdateMenuItemsFlyoutPlacement(); - - if (args.VirtualKey == VirtualKey.Enter || - ((args.VirtualKey == VirtualKey.Down) && menu.CurrentFlyoutPlacement == FlyoutPlacementMode.Bottom) || - ((args.VirtualKey == VirtualKey.Up) && menu.CurrentFlyoutPlacement == FlyoutPlacementMode.Top) || - ((args.VirtualKey == VirtualKey.Left) && menu.CurrentFlyoutPlacement == FlyoutPlacementMode.Left) || - ((args.VirtualKey == VirtualKey.Right) && menu.CurrentFlyoutPlacement == FlyoutPlacementMode.Right)) - { - menu.SelectedMenuItem.ShowMenu(); - return true; - } - - if ((args.VirtualKey == VirtualKey.Left && orientation == Orientation.Horizontal) || - (args.VirtualKey == VirtualKey.Up && orientation == Orientation.Vertical)) - { - GetNextMenuItem(menu, -1); - return true; - } - - if ((args.VirtualKey == VirtualKey.Right && orientation == Orientation.Horizontal) || - (args.VirtualKey == VirtualKey.Down && orientation == Orientation.Vertical)) - { - GetNextMenuItem(menu, +1); - return true; - } - } - - if ((menu.CurrentFlyoutPlacement == FlyoutPlacementMode.Left && - args.VirtualKey == VirtualKey.Right) || - (args.VirtualKey == VirtualKey.Left && - menu.CurrentFlyoutPlacement != FlyoutPlacementMode.Left)) - { - if (element is MenuFlyoutItem) - { - menu.IsInTransitionState = true; - menu.SelectedMenuItem.HideMenu(); - GetNextMenuItem(menu, -1).ShowMenu(); - return true; - } - - if (element is MenuFlyoutSubItem menuFlyoutSubItem) - { - if (menuFlyoutSubItem.Parent is MenuItem && element == menu._lastFocusElement) - { - menu.IsInTransitionState = true; - menu.SelectedMenuItem.HideMenu(); - GetNextMenuItem(menu, -1).ShowMenu(); - return true; - } - } - } - - if ((args.VirtualKey == VirtualKey.Right && - menu.CurrentFlyoutPlacement != FlyoutPlacementMode.Left) || - (args.VirtualKey == VirtualKey.Left && - menu.CurrentFlyoutPlacement == FlyoutPlacementMode.Left)) - { - if (element is MenuFlyoutItem) - { - menu.IsInTransitionState = true; - menu.SelectedMenuItem.HideMenu(); - GetNextMenuItem(menu, +1).ShowMenu(); - return true; - } - } - - return false; - } - - private static MenuItem GetNextMenuItem(Menu menu, int moveCount) - { - var currentMenuItemIndex = menu.Items.IndexOf(menu.SelectedMenuItem); - var nextIndex = (currentMenuItemIndex + moveCount + menu.Items.Count) % menu.Items.Count; - var nextItem = menu.Items.ElementAt(nextIndex) as MenuItem; - nextItem?.Focus(FocusState.Keyboard); - return nextItem; - } - - private static string MapInputToGestureKey(VirtualKey key, bool menuHasFocus = false) - { - var isCtrlDown = Window.Current.CoreWindow.GetKeyState(VirtualKey.Control).HasFlag(CoreVirtualKeyStates.Down); - var isShiftDown = Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down); - var isAltDown = Window.Current.CoreWindow.GetKeyState(VirtualKey.Menu).HasFlag(CoreVirtualKeyStates.Down) || menuHasFocus; - - if (!isCtrlDown && !isShiftDown && !isAltDown) - { - return null; - } - - StringBuilder gestureKeyBuilder = new StringBuilder(); - - if (isCtrlDown) - { - gestureKeyBuilder.Append(CtrlValue); - gestureKeyBuilder.Append("+"); - } - - if (isShiftDown) - { - gestureKeyBuilder.Append(ShiftValue); - gestureKeyBuilder.Append("+"); - } - - if (isAltDown) - { - gestureKeyBuilder.Append(AltValue); - gestureKeyBuilder.Append("+"); - } - - if (key == VirtualKey.None) - { - gestureKeyBuilder.Remove(gestureKeyBuilder.Length - 1, 1); - } - else - { - gestureKeyBuilder.Append(key); - } - - return gestureKeyBuilder.ToString(); - } - - internal bool UpdateMenuItemsFlyoutPlacement() - { - var placementMode = GetMenuFlyoutPlacementMode(); - - if (placementMode == CurrentFlyoutPlacement) - { - return false; - } - - CurrentFlyoutPlacement = placementMode; - - foreach (MenuItem menuItem in Items) - { - if (menuItem.MenuFlyout != null) - { - menuItem.MenuFlyout.Placement = CurrentFlyoutPlacement.Value; - } - } - - return true; - } - - internal FlyoutPlacementMode GetMenuFlyoutPlacementMode() - { - var ttv = TransformToVisual(Window.Current.Content); - var menuCoords = ttv.TransformPoint(new Point(0, 0)); - - if (Orientation == Orientation.Horizontal) - { - var menuCenter = menuCoords.Y + (ActualHeight / 2); - - if (menuCenter <= Window.Current.Bounds.Height / 2) - { - return FlyoutPlacementMode.Bottom; - } - else - { - return FlyoutPlacementMode.Top; - } - } - else - { - var menuCenter = menuCoords.X + (ActualWidth / 2); - - if (menuCenter <= Window.Current.Bounds.Width / 2) - { - return FlyoutPlacementMode.Right; - } - else - { - return FlyoutPlacementMode.Left; - } - } - } - - private static void OrientationPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - var menu = (Menu)d; - if (menu._wrapPanel != null) - { - menu._wrapPanel.Orientation = menu.Orientation; - } - - menu.UpdateMenuItemsFlyoutPlacement(); - } - - private static void RemoveElementFromCache(FrameworkElement descendant) - { - var value = descendant.GetValue(InputGestureTextProperty); - if (value == null) - { - return; - } - - var inputGestureText = value.ToString().ToUpper(); - if (!MenuItemInputGestureCache.ContainsKey(inputGestureText)) - { - return; - } - - var cachedMenuItem = MenuItemInputGestureCache[inputGestureText]; - if (cachedMenuItem == descendant) - { - MenuItemInputGestureCache.Remove(inputGestureText); - } - } - - private void ShowMenuItemsToolTips() - { - foreach (MenuItem item in Items) - { - item.ShowTooltip(); - } - } - - private void UnderlineMenuItems() - { - foreach (MenuItem item in Items) - { - item.Underline(); - } - } - - private void RemoveUnderlineMenuItems() - { - foreach (MenuItem item in Items) - { - item.RemoveUnderline(); - } - } - - private void HideMenuItemsTooltips() - { - foreach (MenuItem item in Items) - { - item.HideTooltip(); - } - } - - internal void CalculateBounds() - { - var ttv = TransformToVisual(Window.Current.Content); - Point screenCoords = ttv.TransformPoint(new Point(0, 0)); - _bounds.X = screenCoords.X; - _bounds.Y = screenCoords.Y; - _bounds.Width = ActualWidth; - _bounds.Height = ActualHeight; - - foreach (MenuItem item in Items) - { - item.CalculateBounds(); - } - } - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.cs b/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.cs deleted file mode 100644 index 93e6fd11e18..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.cs +++ /dev/null @@ -1,134 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// Menu Control defines a menu of choices for users to invoke. - /// - [Obsolete("This control will be removed in a future major release. Please use the MenuBar control from the WinUI Library instead.")] - public partial class Menu : ItemsControl - { - private WrapPanel _wrapPanel; - - /// - /// Initializes a new instance of the class. - /// - public Menu() - { - DefaultStyleKey = typeof(Menu); - } - - // even if we have multiple menus in the same page we need only one cache because only one menu item will have certain short cut. - private static readonly Dictionary MenuItemInputGestureCache = new Dictionary(); - - /// - /// Gets or sets the orientation of the Menu, Horizontal or vertical means that child controls will be added horizontally - /// until the width of the panel can't fit more control then a new row is added to fit new horizontal added child controls, - /// vertical means that child will be added vertically until the height of the panel is received then a new column is added - /// - public Orientation Orientation - { - get { return (Orientation)GetValue(OrientationProperty); } - set { SetValue(OrientationProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty OrientationProperty = - DependencyProperty.Register( - nameof(Orientation), - typeof(Orientation), - typeof(Menu), - new PropertyMetadata(Orientation.Horizontal, OrientationPropertyChanged)); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty MenuFlyoutStyleProperty = DependencyProperty.Register(nameof(MenuFlyoutStyle), typeof(Style), typeof(Menu), new PropertyMetadata(default(Style))); - - /// - /// Gets or sets the menu style for MenuItem - /// - public Style MenuFlyoutStyle - { - get { return (Style)GetValue(MenuFlyoutStyleProperty); } - set { SetValue(MenuFlyoutStyleProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty TooltipStyleProperty = DependencyProperty.Register(nameof(TooltipStyle), typeof(Style), typeof(Menu), new PropertyMetadata(default(Style))); - - /// - /// Gets or sets the tooltip styles for menu - /// - public Style TooltipStyle - { - get { return (Style)GetValue(TooltipStyleProperty); } - set { SetValue(TooltipStyleProperty, value); } - } - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty TooltipPlacementProperty = DependencyProperty.Register(nameof(TooltipPlacement), typeof(PlacementMode), typeof(Menu), new PropertyMetadata(default(PlacementMode))); - - /// - /// Gets or sets the tooltip placement on menu - /// - public PlacementMode TooltipPlacement - { - get { return (PlacementMode)GetValue(TooltipPlacementProperty); } - set { SetValue(TooltipPlacementProperty, value); } - } - - /// - /// Gets the current selected menu header item - /// - public MenuItem SelectedMenuItem { get; internal set; } - - /// - /// Gets a value indicating whether the menu is opened or not - /// - public bool IsOpened { get; internal set; } - - /// - /// Gets or sets a value indicating whether the menu is in transition state between menu closing state and menu opened state. - /// - internal bool IsInTransitionState { get; set; } - - /// - protected override void OnApplyTemplate() - { - Loaded -= Menu_Loaded; - Unloaded -= Menu_Unloaded; - - Loaded += Menu_Loaded; - Unloaded += Menu_Unloaded; - - base.OnApplyTemplate(); - } - - /// - protected override bool IsItemItsOwnContainerOverride(object item) - { - return item is MenuItem; - } - - /// - protected override DependencyObject GetContainerForItemOverride() - { - return new MenuItem(); - } - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.xaml b/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.xaml deleted file mode 100644 index 221644775c8..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/Menu/Menu.xaml +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Menu/MenuItem.cs b/Microsoft.Toolkit.Uwp.UI.Controls/Menu/MenuItem.cs deleted file mode 100644 index 684fece2370..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls/Menu/MenuItem.cs +++ /dev/null @@ -1,531 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Microsoft.Toolkit.Uwp.UI.Extensions; -using Windows.Foundation; -using Windows.Foundation.Collections; -using Windows.Foundation.Metadata; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Documents; -using Windows.UI.Xaml.Input; -using Windows.UI.Xaml.Media; - -namespace Microsoft.Toolkit.Uwp.UI.Controls -{ - /// - /// Menu Item is the items main container for Class Menu control - /// - [Obsolete("This control will be removed in a future major release. Please use the MenuBar control from the WinUI Library instead.")] - public class MenuItem : HeaderedItemsControl - { - private const string FlyoutButtonName = "FlyoutButton"; - private const char UnderlineCharacter = '^'; - private readonly bool _isAccessKeySupported = ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 3); - private readonly bool _isTextTextDecorationsSupported = ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 4); - private Menu _parentMenu; - private bool _isOpened; - private bool _menuFlyoutRepositioned; - private bool _menuFlyoutPlacementChanged; - private string _originalHeader; - private bool _isInternalHeaderUpdate; - - internal MenuFlyout MenuFlyout { get; set; } - - internal Button FlyoutButton { get; private set; } - - private Rect _bounds; - - private object InternalHeader - { - set - { - _isInternalHeaderUpdate = true; - Header = value; - _isInternalHeaderUpdate = false; - } - } - - /// - /// Gets a value indicating whether the menu is opened or not - /// - public bool IsOpened - { - get - { - return _isOpened; - } - - private set - { - _parentMenu.IsOpened = _isOpened = value; - } - } - - /// - /// Initializes a new instance of the class. - /// - public MenuItem() - { - DefaultStyleKey = typeof(MenuItem); - IsFocusEngagementEnabled = true; - } - - internal bool ContainsPoint(Point point) - { - return _bounds.Contains(point); - } - - /// - /// This method is used to hide the menu for current item - /// - public void HideMenu() - { - MenuFlyout?.Hide(); - } - - /// - protected override void OnApplyTemplate() - { - FlyoutButton = GetTemplateChild(FlyoutButtonName) as Button; - _parentMenu = this.FindParent(); - IsOpened = false; - - Items.VectorChanged -= Items_VectorChanged; - IsEnabledChanged -= MenuItem_IsEnabledChanged; - - if (MenuFlyout == null) - { - MenuFlyout = new MenuFlyout(); - } - else - { - MenuFlyout.Opened -= MenuFlyout_Opened; - - MenuFlyout.Closed -= MenuFlyout_Closed; - } - - if (FlyoutButton != null) - { - FlyoutButton.PointerExited -= FlyoutButton_PointerExited; - Items.VectorChanged += Items_VectorChanged; - - MenuFlyout.Opened += MenuFlyout_Opened; - MenuFlyout.Closed += MenuFlyout_Closed; - FlyoutButton.PointerExited += FlyoutButton_PointerExited; - - MenuFlyout.MenuFlyoutPresenterStyle = _parentMenu.MenuFlyoutStyle; - ReAddItemsToFlyout(); - - IsEnabledChanged += MenuItem_IsEnabledChanged; - - if (_isAccessKeySupported) - { - FlyoutButton.AccessKey = AccessKey; - AccessKey = string.Empty; - } - } - - if (_parentMenu?.CurrentFlyoutPlacement != null) - { - MenuFlyout.Placement = _parentMenu.CurrentFlyoutPlacement.Value; - } - - UpdateEnabledVisualState(); - - base.OnApplyTemplate(); - } - - private void MenuItem_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e) - { - var menuItemControl = (MenuItem)sender; - menuItemControl.UpdateEnabledVisualState(); - } - - internal void CalculateBounds() - { - var ttv = TransformToVisual(Window.Current.Content); - Point screenCoords = ttv.TransformPoint(new Point(0, 0)); - _bounds.X = screenCoords.X; - _bounds.Y = screenCoords.Y; - _bounds.Width = ActualWidth; - _bounds.Height = ActualHeight; - } - - internal IEnumerable GetMenuFlyoutItems() - { - var allItems = new List(); - if (MenuFlyout != null) - { - GetMenuFlyoutItemItems(MenuFlyout.Items, allItems); - } - - return allItems; - } - - private void GetMenuFlyoutItemItems(IList menuFlyoutItems, List allItems) - { - foreach (var menuFlyoutItem in menuFlyoutItems) - { - allItems.Add(menuFlyoutItem); - - if (menuFlyoutItem is MenuFlyoutSubItem) - { - var menuItem = (MenuFlyoutSubItem)menuFlyoutItem; - GetMenuFlyoutItemItems(menuItem.Items, allItems); - } - } - } - - internal void ShowTooltip() - { - var inputGestureText = GetValue(Menu.InputGestureTextProperty) as string; - if (string.IsNullOrEmpty(inputGestureText)) - { - return; - } - - var tooltip = ToolTipService.GetToolTip(FlyoutButton) as ToolTip; - if (tooltip == null) - { - tooltip = new ToolTip(); - tooltip.Style = _parentMenu.TooltipStyle; - ToolTipService.SetToolTip(FlyoutButton, tooltip); - } - - tooltip.Placement = _parentMenu.TooltipPlacement; - tooltip.Content = RemoveAlt(inputGestureText); - tooltip.IsOpen = true; - tooltip.IsEnabled = true; - } - - private string RemoveAlt(string inputGesture) - { - if (string.IsNullOrEmpty(inputGesture)) - { - return string.Empty; - } - - return inputGesture.Replace("Alt+", string.Empty); - } - - internal void HideTooltip() - { - var tooltip = ToolTipService.GetToolTip(FlyoutButton) as ToolTip; - if (tooltip != null) - { - tooltip.IsOpen = false; - tooltip.IsEnabled = false; - } - } - - private void ReAddItemsToFlyout() - { - if (MenuFlyout == null) - { - return; - } - - MenuFlyout.Items.Clear(); - foreach (var item in Items) - { - AddItemToFlyout(item); - } - } - - private void AddItemToFlyout(object item) - { - var menuItem = item as MenuFlyoutItemBase; - if (menuItem != null) - { - MenuFlyout.Items.Add(menuItem); - } - else - { - var newMenuItem = new MenuFlyoutItem(); - newMenuItem.DataContext = item; - MenuFlyout.Items.Add(newMenuItem); - } - } - - private void InsertItemToFlyout(object item, int index) - { - var menuItem = item as MenuFlyoutItemBase; - if (menuItem != null) - { - MenuFlyout.Items.Insert(index, menuItem); - } - else - { - var newMenuItem = new MenuFlyoutItem(); - newMenuItem.DataContext = item; - MenuFlyout.Items.Insert(index, newMenuItem); - } - } - - private void Items_VectorChanged(IObservableVector sender, IVectorChangedEventArgs e) - { - var index = (int)e.Index; - switch (e.CollectionChange) - { - case CollectionChange.Reset: - ReAddItemsToFlyout(); - break; - case CollectionChange.ItemInserted: - InsertItemToFlyout(sender.ElementAt(index), index); - break; - case CollectionChange.ItemRemoved: - MenuFlyout.Items.RemoveAt(index); - break; - case CollectionChange.ItemChanged: - MenuFlyout.Items.RemoveAt(index); - InsertItemToFlyout(sender.ElementAt(index), index); - break; - } - } - - private void FlyoutButton_PointerExited(object sender, PointerRoutedEventArgs e) - { - if (IsOpened) - { - VisualStateManager.GoToState(this, "Opened", true); - } - } - - private void MenuFlyout_Closed(object sender, object e) - { - IsOpened = false; - _menuFlyoutRepositioned = false; - _menuFlyoutPlacementChanged = false; - VisualStateManager.GoToState(this, "Normal", true); - } - - private void MenuFlyout_Opened(object sender, object e) - { - if (_parentMenu.UpdateMenuItemsFlyoutPlacement() && !_menuFlyoutPlacementChanged) - { - _menuFlyoutPlacementChanged = true; - ShowMenu(); - } - - _parentMenu.CalculateBounds(); - IsOpened = true; - VisualStateManager.GoToState(this, "Opened", true); - _parentMenu.IsInTransitionState = false; - - if (!_menuFlyoutRepositioned) - { - var popup = VisualTreeHelper.GetOpenPopups(Window.Current).FirstOrDefault(p => p.Child is MenuFlyoutPresenter); - - if (popup != null) - { - var mfp = (MenuFlyoutPresenter)popup.Child; - var height = mfp.ActualHeight; - var width = mfp.ActualWidth; - - var flytoutButtonPoint = FlyoutButton.TransformToVisual(Window.Current.Content).TransformPoint(new Point(0, 0)); - - if ((width > Window.Current.Bounds.Width - flytoutButtonPoint.X && - (MenuFlyout.Placement == FlyoutPlacementMode.Bottom)) || - (height > Window.Current.Bounds.Height - flytoutButtonPoint.Y && - (MenuFlyout.Placement == FlyoutPlacementMode.Right))) - { - ShowMenuRepositioned(width, height); - } - } - } - } - - private void ShowMenuRepositioned(double menuWidth, double menuHeight) - { - if (!IsEnabled || MenuFlyout.Items.Count == 0) - { - return; - } - - _menuFlyoutRepositioned = true; - Point location; - if (MenuFlyout.Placement == FlyoutPlacementMode.Bottom) - { - location = new Point(FlyoutButton.ActualWidth - menuWidth, FlyoutButton.ActualHeight); - } - else if (MenuFlyout.Placement == FlyoutPlacementMode.Right) - { - location = new Point(FlyoutButton.ActualWidth, FlyoutButton.ActualHeight - menuHeight); - } - else - { - // let the flyout decide where to show - MenuFlyout.ShowAt(FlyoutButton); - return; - } - - MenuFlyout.ShowAt(FlyoutButton, location); - } - - /// - /// This method is used to show the menu for current item - /// - public void ShowMenu() - { - if (!IsEnabled || MenuFlyout.Items.Count == 0) - { - return; - } - - Point location; - if (MenuFlyout.Placement == FlyoutPlacementMode.Bottom) - { - location = new Point(0, FlyoutButton.ActualHeight); - } - else if (MenuFlyout.Placement == FlyoutPlacementMode.Right) - { - location = new Point(FlyoutButton.ActualWidth, 0); - } - else - { - // let the flyout decide where to show - MenuFlyout.ShowAt(FlyoutButton); - return; - } - - MenuFlyout.ShowAt(FlyoutButton, location); - } - - /// - protected override void OnTapped(TappedRoutedEventArgs e) - { - _parentMenu.SelectedMenuItem = this; - ShowMenu(); - base.OnTapped(e); - } - - /// - protected override void OnGotFocus(RoutedEventArgs e) - { - _parentMenu.SelectedMenuItem = this; - base.OnGotFocus(e); - } - - internal void Underline() - { - if (_originalHeader == null) - { - return; - } - - var underlineCharacterIndex = _originalHeader.IndexOf(UnderlineCharacter); - - var underlinedCharacter = _originalHeader[underlineCharacterIndex + 1]; - var text = new TextBlock(); - - var runWithUnderlinedCharacter = new Run - { - Text = underlinedCharacter.ToString() - }; - - if (_isTextTextDecorationsSupported) - { - runWithUnderlinedCharacter.TextDecorations = Windows.UI.Text.TextDecorations.Underline; - } - - var firstPartBuilder = new StringBuilder(); - var secondPartBuilder = new StringBuilder(); - - for (int i = 0; i < underlineCharacterIndex; i++) - { - firstPartBuilder.Append(_originalHeader[i]); - } - - for (int i = underlineCharacterIndex + 2; i < _originalHeader.Length; i++) - { - secondPartBuilder.Append(_originalHeader[i]); - } - - var firstPart = firstPartBuilder.ToString(); - var secondPart = secondPartBuilder.ToString(); - - if (!string.IsNullOrEmpty(firstPart)) - { - text.Inlines.Add(new Run - { - Text = firstPart - }); - } - - text.Inlines.Add(runWithUnderlinedCharacter); - - if (!string.IsNullOrEmpty(secondPart)) - { - text.Inlines.Add(new Run - { - Text = secondPart - }); - } - - InternalHeader = text; - } - - /// - protected override void OnHeaderChanged(object oldValue, object newValue) - { - base.OnHeaderChanged(oldValue, newValue); - - if (_isInternalHeaderUpdate) - { - return; - } - - _originalHeader = null; - - var headerString = newValue as string; - - if (string.IsNullOrEmpty(headerString)) - { - return; - } - - var underlineCharacterIndex = headerString.IndexOf(UnderlineCharacter); - - if (underlineCharacterIndex == -1) - { - return; - } - - if (underlineCharacterIndex == headerString.Length - 1) - { - InternalHeader = headerString.Replace(UnderlineCharacter.ToString(), string.Empty); - return; - } - - _originalHeader = headerString; - InternalHeader = headerString.Replace(UnderlineCharacter.ToString(), string.Empty); - } - - internal void RemoveUnderline() - { - if (_originalHeader != null) - { - InternalHeader = _originalHeader.Replace(UnderlineCharacter.ToString(), string.Empty); - } - } - - internal void UpdateEnabledVisualState() - { - if (IsEnabled) - { - VisualStateManager.GoToState(this, "Normal", true); - } - else - { - VisualStateManager.GoToState(this, "Disabled", true); - } - } - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj b/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj index 77ab588f90e..cc82ffbae85 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj +++ b/Microsoft.Toolkit.Uwp.UI.Controls/Microsoft.Toolkit.Uwp.UI.Controls.csproj @@ -26,7 +26,6 @@ - Loading: LoadingControl helps to show content with animation to the user while the app is doing some calculation. - MarkdownTextBlock: An efficient and extensible control that can parse and render markdown. - MasterDetailsView: The MasterDetailsView control allows the user to implement the Master/Details design pattern. - - Menu: This control will be removed in a future major release. Please use the MenuBar control from the WinUI Library instead. - OrbitView: The OrbitView Control positions items in a circle around a center element and supports orbits and anchors. - RadialGauge: The radial gauge displays a value within a range, using a needle on a circular face. - RadialProgressBar: The radial progress bar displays progress as a circle getting filled. diff --git a/Microsoft.Toolkit.Uwp.UI.Controls/Themes/Generic.xaml b/Microsoft.Toolkit.Uwp.UI.Controls/Themes/Generic.xaml index 52eaf5c2b10..72d719a8632 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls/Themes/Generic.xaml +++ b/Microsoft.Toolkit.Uwp.UI.Controls/Themes/Generic.xaml @@ -19,7 +19,6 @@ - From b084e2aa013da7814e51fa7f2bb2658225eb2278 Mon Sep 17 00:00:00 2001 From: michael-hawker Date: Tue, 17 Sep 2019 18:18:24 -0500 Subject: [PATCH 2/2] Design Data Remove Menu Control --- .../Microsoft.Toolkit.Uwp.SampleApp.csproj | 10 ---- .../MenuItemMetadata.cs | 49 ------------------- .../MenuMetadata.cs | 36 -------------- ...soft.Toolkit.Uwp.UI.Controls.Design.csproj | 2 - 4 files changed, 97 deletions(-) delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls.Design/MenuItemMetadata.cs delete mode 100644 Microsoft.Toolkit.Uwp.UI.Controls.Design/MenuMetadata.cs diff --git a/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj b/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj index 8a0ce0d023a..138950be4bf 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj +++ b/Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj @@ -340,7 +340,6 @@ - @@ -468,7 +467,6 @@ - @@ -691,10 +689,6 @@ MarkdownParserPage.xaml - - - MenuPage.xaml - MouseCursorPage.xaml @@ -1159,10 +1153,6 @@ Designer MSBuild:Compile - - MSBuild:Compile - Designer - Designer MSBuild:Compile diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Design/MenuItemMetadata.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Design/MenuItemMetadata.cs deleted file mode 100644 index 8a63b3992c1..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Design/MenuItemMetadata.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Toolkit.Uwp.UI.Controls.Design.Common; -using Microsoft.Windows.Design; -using Microsoft.Windows.Design.Metadata; -using Microsoft.Windows.Design.PropertyEditing; -using System.ComponentModel; - -namespace Microsoft.Toolkit.Uwp.UI.Controls.Design -{ - internal class MenuItemMetadata : AttributeTableBuilder - { - public MenuItemMetadata() - : base() - { - AddCallback(typeof(MenuItem), - b => - { - b.AddCustomAttributes(nameof(MenuItem.Header), - new PropertyOrderAttribute(PropertyOrder.Early), - new CategoryAttribute(Properties.Resources.CategoryCommon) - ); - b.AddCustomAttributes(nameof(MenuItem.IsOpened), - new CategoryAttribute(Properties.Resources.CategoryCommon) - ); - b.AddCustomAttributes(nameof(MenuItem.HeaderTemplate), - new EditorBrowsableAttribute(EditorBrowsableState.Advanced), - new CategoryAttribute(Properties.Resources.CategoryCommon) - ); - b.AddCustomAttributes(nameof(MenuItem.Items), - new PropertyOrderAttribute(PropertyOrder.Early), - new CategoryAttribute(Properties.Resources.CategoryCommon), - //The following is necessary because this is a collection of an abstract type, so we help - //the designer with populating supported types that can be added to the collection - new NewItemTypesAttribute(new System.Type[] { - typeof(MenuItem), - }), - new AlternateContentPropertyAttribute() - ); - - b.AddCustomAttributes(new ToolboxCategoryAttribute(ToolboxCategoryPaths.Toolkit, false)); - b.AddCustomAttributes(new ToolboxBrowsableAttribute(false)); - } - ); - } - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Design/MenuMetadata.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Design/MenuMetadata.cs deleted file mode 100644 index 164c4fa7b70..00000000000 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Design/MenuMetadata.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.Toolkit.Uwp.UI.Controls.Design.Common; -using Microsoft.Windows.Design; -using Microsoft.Windows.Design.Metadata; -using Microsoft.Windows.Design.PropertyEditing; -using System.ComponentModel; - -namespace Microsoft.Toolkit.Uwp.UI.Controls.Design -{ - internal class MenuMetadata : AttributeTableBuilder - { - public MenuMetadata() - : base() - { - AddCallback(typeof(Microsoft.Toolkit.Uwp.UI.Controls.Menu), - b => - { - b.AddCustomAttributes(nameof(Menu.Items), - new PropertyOrderAttribute(PropertyOrder.Early), - new CategoryAttribute(Properties.Resources.CategoryCommon), - //The following is necessary because this is a collection of an abstract type, so we help - //the designer with populating supported types that can be added to the collection - new NewItemTypesAttribute(new System.Type[] { - typeof(MenuItem), - }), - new AlternateContentPropertyAttribute() - ); - b.AddCustomAttributes(new ToolboxCategoryAttribute(ToolboxCategoryPaths.Toolkit, false)); - } - ); - } - } -} diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Design/Microsoft.Toolkit.Uwp.UI.Controls.Design.csproj b/Microsoft.Toolkit.Uwp.UI.Controls.Design/Microsoft.Toolkit.Uwp.UI.Controls.Design.csproj index b611399dd13..3c3c3d63e2a 100644 --- a/Microsoft.Toolkit.Uwp.UI.Controls.Design/Microsoft.Toolkit.Uwp.UI.Controls.Design.csproj +++ b/Microsoft.Toolkit.Uwp.UI.Controls.Design/Microsoft.Toolkit.Uwp.UI.Controls.Design.csproj @@ -100,8 +100,6 @@ - -