Example #1
0
        private void FileTreeContextMenu_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            var gitItem     = tvGitTree.SelectedNode?.Tag as GitItem;
            var enableItems = gitItem != null && gitItem.IsBlob;

            if (gitItem != null && gitItem.IsCommit)
            {
                openSubmoduleMenuItem.Visible = true;
                if (!openSubmoduleMenuItem.Font.Bold)
                {
                    openSubmoduleMenuItem.Font = new Font(openSubmoduleMenuItem.Font, FontStyle.Bold);
                }
            }
            else
            {
                openSubmoduleMenuItem.Visible = false;
            }

            saveAsToolStripMenuItem.Visible                  = enableItems;
            openFileToolStripMenuItem.Visible                = enableItems;
            openFileWithToolStripMenuItem.Visible            = enableItems;
            openWithToolStripMenuItem.Visible                = enableItems;
            copyFilenameToClipboardToolStripMenuItem.Visible = gitItem != null && FormBrowseUtil.IsFileOrDirectory(FormBrowseUtil.GetFullPathFromGitItem(Module, gitItem));
            editCheckedOutFileToolStripMenuItem.Visible      = enableItems;
        }
Example #2
0
        private void FileTreeContextMenu_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            var gitItem     = tvGitTree.SelectedNode?.Tag as GitItem;
            var enableItems = gitItem != null && gitItem.ObjectType == GitObjectType.Blob;

            if (gitItem != null && gitItem.ObjectType == GitObjectType.Commit)
            {
                openSubmoduleMenuItem.Visible = true;
                if (!openSubmoduleMenuItem.Font.Bold)
                {
                    openSubmoduleMenuItem.Font = new Font(openSubmoduleMenuItem.Font, FontStyle.Bold);
                }
            }
            else
            {
                openSubmoduleMenuItem.Visible = false;
            }
            this.fileHistoryToolStripMenuItem.Enabled = gitItem != null;

            this.resetToThisRevisionToolStripMenuItem.Enabled     =
                this.blameToolStripMenuItem1.Enabled              =
                    this.fileTreeArchiveToolStripMenuItem.Enabled =
                        enableItems;

            saveAsToolStripMenuItem.Visible                  = enableItems;
            openFileToolStripMenuItem.Visible                = enableItems;
            openFileWithToolStripMenuItem.Visible            = enableItems;
            openWithToolStripMenuItem.Visible                = enableItems;
            copyFilenameToClipboardToolStripMenuItem.Visible = gitItem != null && FormBrowseUtil.IsFileOrDirectory(FormBrowseUtil.GetFullPathFromGitItem(Module, gitItem));
            editCheckedOutFileToolStripMenuItem.Visible      = enableItems;
            toolStripSeparator18.Visible = enableItems;
        }
        private void FileTreeContextMenu_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            var gitItem                   = tvGitTree.SelectedNode?.Tag as GitItem;
            var itemSelected              = gitItem != null;
            var isFile                    = itemSelected && gitItem.ObjectType == GitObjectType.Blob;
            var isFolder                  = itemSelected && gitItem.ObjectType == GitObjectType.Tree;
            var isFileOrFolder            = isFile || isFolder;
            var isExistingFileOrDirectory = itemSelected && FormBrowseUtil.IsFileOrDirectory(_fullPathResolver.Resolve(gitItem.FileName));

            if (itemSelected && gitItem.ObjectType == GitObjectType.Commit)
            {
                openSubmoduleMenuItem.Visible = true;
                if (!openSubmoduleMenuItem.Font.Bold)
                {
                    openSubmoduleMenuItem.Font = new Font(openSubmoduleMenuItem.Font, FontStyle.Bold);
                }
            }
            else
            {
                openSubmoduleMenuItem.Visible = false;
            }

            saveAsToolStripMenuItem.Visible = isFile;
            resetToThisRevisionToolStripMenuItem.Visible = isFileOrFolder && !Module.IsBareRepository();
            toolStripSeparatorFileSystemActions.Visible  = isFileOrFolder;

            copyFilenameToClipboardToolStripMenuItem.Visible      = itemSelected;
            fileTreeOpenContainingFolderToolStripMenuItem.Enabled = isExistingFileOrDirectory;
            fileTreeArchiveToolStripMenuItem.Enabled          = itemSelected;
            fileTreeCleanWorkingTreeToolStripMenuItem.Visible = isFileOrFolder;
            fileTreeCleanWorkingTreeToolStripMenuItem.Enabled = isExistingFileOrDirectory;

            fileHistoryToolStripMenuItem.Enabled = itemSelected;
            blameToolStripMenuItem1.Visible      = isFile;

            editCheckedOutFileToolStripMenuItem.Visible = isFile;
            editCheckedOutFileToolStripMenuItem.Enabled = isExistingFileOrDirectory;
            openWithToolStripMenuItem.Visible           = isFile;
            openWithToolStripMenuItem.Enabled           = isExistingFileOrDirectory;
            openWithDifftoolToolStripMenuItem.Visible   = isFile;
            openWithDifftoolToolStripMenuItem.Enabled   = FileText.OpenWithDifftool != null;
            openFileToolStripMenuItem.Visible           = isFile;
            openFileWithToolStripMenuItem.Visible       = isFile;

            toolStripSeparatorGitActions.Visible            = isFile;
            stopTrackingThisFileToolStripMenuItem.Visible   = isFile;
            stopTrackingThisFileToolStripMenuItem.Enabled   = isExistingFileOrDirectory;
            assumeUnchangedTheFileToolStripMenuItem.Visible = isFile;
            assumeUnchangedTheFileToolStripMenuItem.Enabled = isExistingFileOrDirectory;
            findToolStripMenuItem.Enabled = tvGitTree.Nodes.Count > 0;

            toolStripSeparatorFileTreeActions.Visible = isFile;
            expandSubtreeToolStripMenuItem.Visible    = isFolder;
        }
Example #4
0
        private void FileTreeContextMenu_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            var gitItem        = tvGitTree.SelectedNode?.Tag as GitItem;
            var itemSelected   = gitItem is not null;
            var isFile         = itemSelected && gitItem.ObjectType == GitObjectType.Blob;
            var isFolder       = itemSelected && gitItem.ObjectType == GitObjectType.Tree;
            var isFileOrFolder = isFile || isFolder;

            // Many items does not make sense if a local file does not exist, why this is used for Enabled
            var isExistingFileOrDirectory = itemSelected && FormBrowseUtil.IsFileOrDirectory(_fullPathResolver.Resolve(gitItem.FileName));

            var openSubVisible = itemSelected && gitItem.ObjectType == GitObjectType.Commit && isExistingFileOrDirectory;

            openSubmoduleMenuItem.Visible = openSubVisible;
            if (openSubVisible)
            {
                if (!openSubmoduleMenuItem.Font.Bold)
                {
                    openSubmoduleMenuItem.Font = new Font(openSubmoduleMenuItem.Font, FontStyle.Bold);
                }

                if (fileHistoryToolStripMenuItem.Font.Bold)
                {
                    fileHistoryToolStripMenuItem.Font = new Font(fileHistoryToolStripMenuItem.Font, FontStyle.Regular);
                }
            }
            else if (!fileHistoryToolStripMenuItem.Font.Bold)
            {
                fileHistoryToolStripMenuItem.Font = new Font(fileHistoryToolStripMenuItem.Font, FontStyle.Bold);
            }

            // Diff with workTree (some tools like kdiff3 and meld allows diff to NUL)
            resetToThisRevisionToolStripMenuItem.Visible = itemSelected && !Module.IsBareRepository();
            toolStripSeparatorTopActions.Visible         = itemSelected && ((gitItem.ObjectType == GitObjectType.Commit && isExistingFileOrDirectory) ||
                                                                            !Module.IsBareRepository());

            // RememberFile diff can be done for folders too (as well as for submodules, but that is meaningless)
            // However diffs will open many windows that cannot be aborted, so it is blocked
            // Another reason is that file<->folder compare is not giving any result
            // (and diff is shared with Diff tab that has no notion of folders)
            openWithDifftoolToolStripMenuItem.Visible = isFile;
            openWithToolStripMenuItem.Visible         = isFile;
            openWithToolStripMenuItem.Enabled         = isExistingFileOrDirectory;
            var fsi = _rememberFileContextMenuController.CreateFileStatusItem(gitItem?.FileName, _revision);

            diffWithRememberedFileToolStripMenuItem.Visible = _rememberFileContextMenuController.RememberedDiffFileItem is not null;
            diffWithRememberedFileToolStripMenuItem.Enabled = isFile && fsi != _rememberFileContextMenuController.RememberedDiffFileItem &&
                                                              _rememberFileContextMenuController.ShouldEnableSecondItemDiff(fsi);
            diffWithRememberedFileToolStripMenuItem.Text =
                _rememberFileContextMenuController.RememberedDiffFileItem is not null
                    ? string.Format(Strings.DiffSelectedWithRememberedFile, _rememberFileContextMenuController.RememberedDiffFileItem.Item.Name)
                    : string.Empty;

            rememberFileStripMenuItem.Visible = isFile;
            rememberFileStripMenuItem.Enabled = _rememberFileContextMenuController.ShouldEnableFirstItemDiff(fsi, isSecondRevision: true);

            openFileToolStripMenuItem.Visible           = isFile;
            openFileWithToolStripMenuItem.Visible       = isFile;
            saveAsToolStripMenuItem.Visible             = isFile;
            editCheckedOutFileToolStripMenuItem.Visible = isFile;
            editCheckedOutFileToolStripMenuItem.Enabled = isExistingFileOrDirectory;
            toolStripSeparatorFileSystemActions.Visible = isFile;

            copyFilenameToClipboardToolStripMenuItem.Visible      = itemSelected;
            fileTreeOpenContainingFolderToolStripMenuItem.Visible = itemSelected;
            fileTreeOpenContainingFolderToolStripMenuItem.Enabled = isExistingFileOrDirectory;
            toolStripSeparatorFileNameActions.Visible             = itemSelected;

            fileHistoryToolStripMenuItem.Enabled              = itemSelected;
            blameToolStripMenuItem1.Visible                   = isFile;
            fileTreeArchiveToolStripMenuItem.Enabled          = itemSelected;
            fileTreeCleanWorkingTreeToolStripMenuItem.Visible = isFileOrFolder;
            fileTreeCleanWorkingTreeToolStripMenuItem.Enabled = isExistingFileOrDirectory;
            toolStripSeparatorGitActions.Visible              = itemSelected;

            stopTrackingThisFileToolStripMenuItem.Visible   = isFile;
            stopTrackingThisFileToolStripMenuItem.Enabled   = isExistingFileOrDirectory;
            assumeUnchangedTheFileToolStripMenuItem.Visible = isFile;
            assumeUnchangedTheFileToolStripMenuItem.Enabled = isExistingFileOrDirectory;
            toolStripSeparatorGitTrackingActions.Visible    = isFile;

            findToolStripMenuItem.Enabled          = tvGitTree.Nodes.Count > 0;
            expandSubtreeToolStripMenuItem.Visible = isFolder;
        }
        private void FileTreeContextMenu_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            var gitItem        = tvGitTree.SelectedNode?.Tag as GitItem;
            var itemSelected   = gitItem != null;
            var isFile         = itemSelected && gitItem.ObjectType == GitObjectType.Blob;
            var isFolder       = itemSelected && gitItem.ObjectType == GitObjectType.Tree;
            var isFileOrFolder = isFile || isFolder;

            // Many items does not make sense if a local file does not exist, why this is used for Enabled
            var isExistingFileOrDirectory = itemSelected && FormBrowseUtil.IsFileOrDirectory(_fullPathResolver.Resolve(gitItem.FileName));

            var openSubVisible = itemSelected && gitItem.ObjectType == GitObjectType.Commit && isExistingFileOrDirectory;

            openSubmoduleMenuItem.Visible = openSubVisible;
            if (openSubVisible)
            {
                if (!openSubmoduleMenuItem.Font.Bold)
                {
                    openSubmoduleMenuItem.Font = new Font(openSubmoduleMenuItem.Font, FontStyle.Bold);
                }

                if (fileHistoryToolStripMenuItem.Font.Bold)
                {
                    fileHistoryToolStripMenuItem.Font = new Font(fileHistoryToolStripMenuItem.Font, FontStyle.Regular);
                }
            }
            else if (!fileHistoryToolStripMenuItem.Font.Bold)
            {
                fileHistoryToolStripMenuItem.Font = new Font(fileHistoryToolStripMenuItem.Font, FontStyle.Bold);
            }

            // Diff with workTree (some tools like kdiff3 and meld allows diff to NUL)
            resetToThisRevisionToolStripMenuItem.Visible = itemSelected && !Module.IsBareRepository();
            toolStripSeparatorTopActions.Visible         = itemSelected && ((gitItem.ObjectType == GitObjectType.Commit && isExistingFileOrDirectory) ||
                                                                            !Module.IsBareRepository());

            openWithDifftoolToolStripMenuItem.Visible   = isFile;
            openWithToolStripMenuItem.Visible           = isFile;
            openWithToolStripMenuItem.Enabled           = isExistingFileOrDirectory;
            openFileToolStripMenuItem.Visible           = isFile;
            openFileWithToolStripMenuItem.Visible       = isFile;
            saveAsToolStripMenuItem.Visible             = isFile;
            editCheckedOutFileToolStripMenuItem.Visible = isFile;
            editCheckedOutFileToolStripMenuItem.Enabled = isExistingFileOrDirectory;
            toolStripSeparatorFileSystemActions.Visible = isFile;

            copyFilenameToClipboardToolStripMenuItem.Visible      = itemSelected;
            fileTreeOpenContainingFolderToolStripMenuItem.Visible = itemSelected;
            fileTreeOpenContainingFolderToolStripMenuItem.Enabled = isExistingFileOrDirectory;
            toolStripSeparatorFileNameActions.Visible             = itemSelected;

            fileHistoryToolStripMenuItem.Enabled              = itemSelected;
            blameToolStripMenuItem1.Visible                   = isFile;
            fileTreeArchiveToolStripMenuItem.Enabled          = itemSelected;
            fileTreeCleanWorkingTreeToolStripMenuItem.Visible = isFileOrFolder;
            fileTreeCleanWorkingTreeToolStripMenuItem.Enabled = isExistingFileOrDirectory;
            toolStripSeparatorGitActions.Visible              = itemSelected;

            stopTrackingThisFileToolStripMenuItem.Visible   = isFile;
            stopTrackingThisFileToolStripMenuItem.Enabled   = isExistingFileOrDirectory;
            assumeUnchangedTheFileToolStripMenuItem.Visible = isFile;
            assumeUnchangedTheFileToolStripMenuItem.Enabled = isExistingFileOrDirectory;
            toolStripSeparatorGitTrackingActions.Visible    = isFile;

            findToolStripMenuItem.Enabled          = tvGitTree.Nodes.Count > 0;
            expandSubtreeToolStripMenuItem.Visible = isFolder;
        }