GitUI.CommandsDialogs.FormBrowse.openWithDifftoolToolStripMenuItem_DropDownOpening C# (CSharp) Method

openWithDifftoolToolStripMenuItem_DropDownOpening() private method

private openWithDifftoolToolStripMenuItem_DropDownOpening ( object sender, EventArgs e ) : void
sender object
e EventArgs
return void
        private void openWithDifftoolToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
        {
            bool artificialRevSelected = false;
            bool enableDiffDropDown = true;
            bool showParentItems = false;

            IList<GitRevision> revisions = RevisionGrid.GetSelectedRevisions();

            if (revisions.Count > 0)
            {
                artificialRevSelected = revisions[0].IsArtificial();

                if (revisions.Count == 2)
                {
                    artificialRevSelected = artificialRevSelected || revisions[revisions.Count - 1].IsArtificial();
                    showParentItems = true;
                }
                else
                    enableDiffDropDown = revisions.Count == 1;
            }

            aBToolStripMenuItem.Enabled = enableDiffDropDown;
            bLocalToolStripMenuItem.Enabled = enableDiffDropDown;
            aLocalToolStripMenuItem.Enabled = enableDiffDropDown;
            parentOfALocalToolStripMenuItem.Enabled = enableDiffDropDown;
            parentOfBLocalToolStripMenuItem.Enabled = enableDiffDropDown;

            parentOfALocalToolStripMenuItem.Visible = showParentItems;
            parentOfBLocalToolStripMenuItem.Visible = showParentItems;

            if (!enableDiffDropDown)
                return;
            //enable *<->Local items only when local file exists
            foreach (var item in DiffFiles.SelectedItems)
            {
                string filePath = FormBrowseUtil.GetFullPathFromGitItemStatus(Module, item);
                if (File.Exists(filePath))
                {
                    bLocalToolStripMenuItem.Enabled = !artificialRevSelected;
                    aLocalToolStripMenuItem.Enabled = !artificialRevSelected;
                    parentOfALocalToolStripMenuItem.Enabled = !artificialRevSelected;
                    parentOfBLocalToolStripMenuItem.Enabled = !artificialRevSelected;
                    return;
                }
            }
        }
FormBrowse