Example #1
0
        private void lstRepositories_ContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
            var selectedViews = lstRepositories.SelectedItems?.OfType <RepositoryView>();

            if (selectedViews == null || !selectedViews.Any())
            {
                e.Handled = true;
                return;
            }

            var items = ((FrameworkElement)e.Source).ContextMenu.Items;

            items.Clear();

            var innerRepositories = selectedViews.Select(view => view.Repository);

            foreach (var action in _repositoryActionProvider.GetContextMenuActions(innerRepositories))
            {
                if (action.BeginGroup && items.Count > 0)
                {
                    items.Add(new Separator());
                }

                items.Add(CreateMenuItem(sender, action, selectedViews));
            }
        }
Example #2
0
        private bool LstRepositoriesContextMenuOpening(object sender, ContextMenu ctxMenu)
        {
            if (ctxMenu == null)
            {
                return(false);
            }

            var selectedViews = lstRepositories.SelectedItems?.OfType <RepositoryView>();

            if (selectedViews?.Any() != true)
            {
                return(false);
            }

            var items = ctxMenu.Items;

            items.Clear();

            var innerRepositories = selectedViews.Select(view => view.Repository);

            foreach (var action in _repositoryActionProvider.GetContextMenuActions(innerRepositories))
            {
                if (action.BeginGroup && items.Count > 0)
                {
                    items.Add(new Separator());
                }

                items.Add(CreateMenuItem(sender, action, selectedViews));
            }

            return(true);
        }