private static MenuFlyoutItemBase GetMenuItem(ContextMenuFlyoutItemViewModel item)
 {
     return(item.ItemType switch
     {
         ItemType.Separator => new MenuFlyoutSeparator(),
         _ => GetMenuFlyoutItem(item),
     });
Esempio n. 2
0
 private static ICommandBarElement GetCommandBarItem(ContextMenuFlyoutItemViewModel item)
 {
     return(item.ItemType switch
     {
         ItemType.Separator => new AppBarSeparator(),
         _ => GetCommandBarButton(item),
     });
Esempio n. 3
0
 private static bool Check(ContextMenuFlyoutItemViewModel item, CurrentInstanceViewModel currentInstanceViewModel, List <ListedItem> selectedItems, bool shiftPressed)
 {
     return((item.ShowInRecycleBin || !currentInstanceViewModel.IsPageTypeRecycleBin) && // Hide non-recycle bin items
            (!item.ShowInCloudDrive || currentInstanceViewModel.IsPageTypeCloudDrive) && // Hide non-cloud drive items
            (!item.SingleItemOnly || selectedItems.Count == 1) &&
            item.ShowItem);
 }
Esempio n. 4
0
        private static ICommandBarElement GetCommandBarButton(ContextMenuFlyoutItemViewModel item)
        {
            ICommandBarElement element;
            FontIcon           icon = null;

            if (!string.IsNullOrEmpty(item.Glyph))
            {
                icon = new FontIcon
                {
                    Glyph = item.Glyph,
                };
            }

            if (!string.IsNullOrEmpty(item.GlyphFontFamilyName))
            {
                var fontFamily = App.Current.Resources[item.GlyphFontFamilyName] as FontFamily;
                icon.FontFamily = fontFamily;
            }
            MenuFlyout ctxFlyout = null;

            if (item.Items.Count > 0)
            {
                ctxFlyout = new MenuFlyout();
                GetMenuFlyoutItemsFromModel(item.Items).ForEach(i => ctxFlyout.Items.Add(i));
            }

            Image content = null;

            if (item.BitmapIcon != null)
            {
                content = new Image()
                {
                    Source = item.BitmapIcon,
                };
            }

            if (item.ItemType == ItemType.Toggle)
            {
                element = new AppBarToggleButton()
                {
                    Label            = item.Text,
                    Tag              = item.Tag,
                    Command          = item.Command,
                    CommandParameter = item.CommandParameter,
                    IsChecked        = item.IsChecked,
                    Content          = content
                };

                if (icon != null)
                {
                    (element as AppBarToggleButton).Icon = icon;
                }

                if (item.IsPrimary)
                {
                    (element as AppBarToggleButton).SetValue(ToolTipService.ToolTipProperty, item.Text);
                }
            }
            else
            {
                element = new AppBarButton()
                {
                    Label            = item.Text,
                    Tag              = item.Tag,
                    Command          = item.Command,
                    CommandParameter = item.CommandParameter,
                    Flyout           = ctxFlyout,
                    Content          = content,
                };

                if (icon != null)
                {
                    (element as AppBarButton).Icon = icon;
                }

                if (item.IsPrimary)
                {
                    (element as AppBarButton).SetValue(ToolTipService.ToolTipProperty, item.Text);
                }
            }

            return(element);
        }