示例#1
0
        public UnstagedItemMenu(TreeItem item)
        {
            Verify.Argument.IsValidGitObject(item, nameof(item));
            Verify.Argument.AreEqual(StagedStatus.Unstaged, item.StagedStatus & StagedStatus.Unstaged, "item",
                                     "This item is not unstaged.");

            Item = item;

            var dir = Item as TreeDirectory;

            if (Item.Status != FileStatus.Removed)
            {
                var fullPath = Item.FullPath;
                if (dir == null)
                {
                    Items.Add(GuiItemFactory.GetOpenUrlItem <ToolStripMenuItem>(Resources.StrOpen, null, fullPath));
                    Items.Add(GuiItemFactory.GetOpenUrlWithItem <ToolStripMenuItem>(Resources.StrOpenWith.AddEllipsis(), null, fullPath));
                    Items.Add(GuiItemFactory.GetOpenUrlItem <ToolStripMenuItem>(Resources.StrOpenContainingFolder, null, Path.GetDirectoryName(fullPath)));
                }
                else
                {
                    Items.Add(GuiItemFactory.GetOpenUrlItem <ToolStripMenuItem>(Resources.StrOpenInWindowsExplorer, null, fullPath));
                }
                Items.Add(new ToolStripSeparator());
            }
            Items.Add(GuiItemFactory.GetStageItem <ToolStripMenuItem>(Item));
            if (dir != null)
            {
                if (HasRevertableItems(dir))
                {
                    Items.Add(GuiItemFactory.GetRevertPathItem <ToolStripMenuItem>(Item));
                }
            }
            else
            {
                if (Item.Status == FileStatus.Removed || Item.Status == FileStatus.Modified)
                {
                    Items.Add(GuiItemFactory.GetRevertPathItem <ToolStripMenuItem>(Item));
                }
                if (Item.Status == FileStatus.Modified || Item.Status == FileStatus.Added)
                {
                    Items.Add(GuiItemFactory.GetRemovePathItem <ToolStripMenuItem>(Item));
                }
            }
        }