Exemplo n.º 1
0
        protected override ContextMenuStrip GetMultiselectContextMenu(ItemsContextMenuRequestEventArgs requestEventArgs)
        {
            if (requestEventArgs.Items.Count != 2)
            {
                return(null);
            }
            var revisions = new List <Revision>(requestEventArgs.Items.Count);

            foreach (var item in requestEventArgs.Items)
            {
                var revItem = item as RevisionListItem;
                if (revItem != null)
                {
                    revisions.Add(revItem.DataContext);
                }
            }
            if (revisions.Count == 2)
            {
                var menu = new RevisionsMenu(revisions);
                Utility.MarkDropDownForAutoDispose(menu);
                return(menu);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        protected override ContextMenuStrip GetMultiselectContextMenu(ItemsContextMenuRequestEventArgs requestEventArgs)
        {
            var stagedStatus = StagedStatus.None;
            var items        = new TreeItem[requestEventArgs.Items.Count];
            int id           = 0;

            foreach (var item in requestEventArgs.Items)
            {
                var treeItem = ((ITreeItemListItem)item).TreeItem;
                items[id++]   = treeItem;
                stagedStatus |= treeItem.StagedStatus;
            }
            ContextMenuStrip menu;

            switch (stagedStatus)
            {
            case StagedStatus.Staged:
                menu = new ContextMenuStrip();
                menu.Items.Add(GuiItemFactory.GetUnstageItem <ToolStripMenuItem>(_repository, items));
                break;

            case StagedStatus.Unstaged:
                menu = new ContextMenuStrip();
                menu.Items.Add(GuiItemFactory.GetStageItem <ToolStripMenuItem>(_repository, items));
                if (HasRevertableItems(items))
                {
                    menu.Items.Add(GuiItemFactory.GetRevertPathsItem <ToolStripMenuItem>(items));
                }
                break;

            default:
                menu = null;
                break;
            }
            if (menu != null)
            {
                Utility.MarkDropDownForAutoDispose(menu);
            }
            return(menu);
        }