public void HideOthers()
 {
     _commands.HideOthers();
 }
Ejemplo n.º 2
0
        private NativeMenu CreateDefaultAppMenu()
        {
            var result = new NativeMenu();

            var aboutItem = new NativeMenuItem("About Avalonia");

            aboutItem.Click += async(sender, e) =>
            {
                var dialog = new AboutAvaloniaDialog();

                var mainWindow = (Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow;

                await dialog.ShowDialog(mainWindow);
            };
            result.Add(aboutItem);

            var macOpts = AvaloniaLocator.Current.GetService <MacOSPlatformOptions>();

            if (macOpts == null || !macOpts.DisableDefaultApplicationMenuItems)
            {
                result.Add(new NativeMenuItemSeparator());

                var servicesMenu = new NativeMenuItem("Services");
                servicesMenu.Menu = new NativeMenu
                {
                    [MacOSNativeMenuCommands.IsServicesSubmenuProperty] = true
                };
                result.Add(servicesMenu);

                result.Add(new NativeMenuItemSeparator());

                var hideItem = new NativeMenuItem("Hide " + Application.Current.Name)
                {
                    Gesture = new KeyGesture(Key.H, KeyModifiers.Meta)
                };
                hideItem.Click += (sender, args) =>
                {
                    _applicationCommands.HideApp();
                };
                result.Add(hideItem);


                var hideOthersItem = new NativeMenuItem("Hide Others")
                {
                    Gesture = new KeyGesture(Key.Q, KeyModifiers.Meta | KeyModifiers.Alt)
                };
                hideOthersItem.Click += (sender, args) =>
                {
                    _applicationCommands.HideOthers();
                };
                result.Add(hideOthersItem);


                var showAllItem = new NativeMenuItem("Show All");
                showAllItem.Click += (sender, args) =>
                {
                    _applicationCommands.ShowAll();
                };
                result.Add(showAllItem);

                result.Add(new NativeMenuItemSeparator());

                var quitItem = new NativeMenuItem("Quit")
                {
                    Gesture = new KeyGesture(Key.Q, KeyModifiers.Meta)
                };
                quitItem.Click += (sender, args) =>
                {
                    _applicationCommands.ShowAll();
                };
                result.Add(quitItem);
            }


            return(result);
        }