protected override void OnActivate()
        {
            base.OnActivate();

            // Set the title of the icon (the ToolTipText) to our IContextMenuTranslations.Title
            _contextMenuTranslations.CreateDisplayNameBinding(this, nameof(IMainContextMenuTranslations.Title));

            var items = new List <IMenuItem>();

            // Lazy values
            items.AddRange(_contextMenuItems.Select(lazy => lazy.Value));

            items.Add(new MenuItem
            {
                Style = MenuItemStyles.Separator,
                Id    = "Y_Separator"
            });
            ConfigureMenuItems(items);

            // Make sure the margin is set, do this AFTER the icon are set
            items.ApplyIconMargin(new Thickness(2, 2, 2, 2));

            SetIcon(new PackIconMaterial
            {
                Kind       = PackIconMaterialKind.Clipboard,
                Background = Brushes.Transparent,
                Foreground = WindowsVersion.IsWindows8OrLater? Brushes.White : Brushes.Black
            });
            Show();
        }
Пример #2
0
        public TitleMenuItem(IMainContextMenuTranslations contextMenuTranslations)
        {
            // automatically update the DisplayName
            contextMenuTranslations.CreateDisplayNameBinding(this, nameof(IMainContextMenuTranslations.Title));
            Id    = "A_Title";
            Style = MenuItemStyles.Title;

            Icon = new PackIconMaterial
            {
                Kind = PackIconMaterialKind.Clipboard
            };
            this.ApplyIconForegroundColor(Brushes.SaddleBrown);
        }
Пример #3
0
 public ExitMenuItem(
     IMainContextMenuTranslations contextMenuTranslations
     )
 {
     // automatically update the DisplayName
     contextMenuTranslations.CreateDisplayNameBinding(this, nameof(IMainContextMenuTranslations.Exit));
     Id   = "Z_Exit";
     Icon = new PackIconMaterial
     {
         Kind = PackIconMaterialKind.Close,
         HorizontalAlignment        = HorizontalAlignment.Stretch,
         VerticalAlignment          = VerticalAlignment.Stretch,
         HorizontalContentAlignment = HorizontalAlignment.Stretch,
         VerticalContentAlignment   = VerticalAlignment.Stretch
     };
     ClickAction = clickedItem =>
     {
         Dapplication.Current.Shutdown();
     };
     this.ApplyIconForegroundColor(Brushes.DarkRed);
 }