示例#1
0
        private IEnumerable <MenuCommand> CreateViewMenuCommands()
        {
            var resultList = new List <MenuCommand>();

            // the next three MenuCommands just reuse (the currently rather
            //  convoluted) logic from RevisionGrid.
            //  After refactoring the three items should be added to RevisionGrid
            //  as done with "ShowRemoteBranches" and not via RevisionGrid.Designer.cs
            {
                var menuCommand = new MenuCommand();
                menuCommand.Name = "ShowAllBranches";
                menuCommand.Text = "Show all branches";
                menuCommand.ShortcutKeyDisplayString = GetShortcutKeyDisplayStringFromRevisionGridIfAvailable(GitUI.RevisionGrid.Commands.ShowAllBranches);
                menuCommand.ExecuteAction            = () => _revisionGrid.ShowAllBranches_ToolStripMenuItemClick(null, null);
                menuCommand.IsCheckedFunc            = () => _revisionGrid.ShowAllBranches_ToolStripMenuItemChecked;

                resultList.Add(menuCommand);
            }

            {
                var menuCommand = new MenuCommand();
                menuCommand.Name = "ShowCurrentBranchOnly";
                menuCommand.Text = "Show current branch only";
                menuCommand.ShortcutKeyDisplayString = GetShortcutKeyDisplayStringFromRevisionGridIfAvailable(GitUI.RevisionGrid.Commands.ShowCurrentBranchOnly);
                menuCommand.ExecuteAction            = () => _revisionGrid.ShowCurrentBranchOnly_ToolStripMenuItemClick(null, null);
                menuCommand.IsCheckedFunc            = () => _revisionGrid.ShowCurrentBranchOnly_ToolStripMenuItemChecked;

                resultList.Add(menuCommand);
            }

            {
                var menuCommand = new MenuCommand();
                menuCommand.Name = "ShowFilteredBranches";
                menuCommand.Text = "Show filtered branches";
                menuCommand.ShortcutKeyDisplayString = GetShortcutKeyDisplayStringFromRevisionGridIfAvailable(GitUI.RevisionGrid.Commands.ShowFilteredBranches);
                menuCommand.ExecuteAction            = () => _revisionGrid.ShowFilteredBranches_ToolStripMenuItemClick(null, null);
                menuCommand.IsCheckedFunc            = () => _revisionGrid.ShowFilteredBranches_ToolStripMenuItemChecked;

                resultList.Add(menuCommand);
            }

            resultList.Add(MenuCommand.CreateSeparator());

            {
                var menuCommand = new MenuCommand();
                menuCommand.Name = "ShowRemoteBranches";
                menuCommand.Text = "Show remote branches";
                menuCommand.ShortcutKeyDisplayString = GetShortcutKeyDisplayStringFromRevisionGridIfAvailable(GitUI.RevisionGrid.Commands.ShowRemoteBranches);
                menuCommand.ExecuteAction            = () => _revisionGrid.ShowRemoteBranches_ToolStripMenuItemClick(null, null);
                menuCommand.IsCheckedFunc            = () => AppSettings.ShowRemoteBranches;

                resultList.Add(menuCommand);
            }

            {
                var menuCommand = new MenuCommand();
                menuCommand.Name          = "ShowReflogReferences";
                menuCommand.Text          = "Show reflog references";
                menuCommand.ExecuteAction = () => _revisionGrid.ShowReflogReferences_ToolStripMenuItemClick(null, null);
                menuCommand.IsCheckedFunc = () => AppSettings.ShowReflogReferences;

                resultList.Add(menuCommand);
            }

            resultList.Add(MenuCommand.CreateSeparator());

            {
                var menuCommand = new MenuCommand();
                menuCommand.Name          = "ShowSuperprojectTags";
                menuCommand.Text          = "Show superproject tags";
                menuCommand.ExecuteAction = () => _revisionGrid.ShowSuperprojectTags_ToolStripMenuItemClick(null, null);
                menuCommand.IsCheckedFunc = () => AppSettings.ShowSuperprojectTags;

                resultList.Add(menuCommand);
            }

            {
                var menuCommand = new MenuCommand();
                menuCommand.Name          = "ShowSuperprojectBranches";
                menuCommand.Text          = "Show superproject branches";
                menuCommand.ExecuteAction = () => _revisionGrid.ShowSuperprojectBranches_ToolStripMenuItemClick(null, null);
                menuCommand.IsCheckedFunc = () => AppSettings.ShowSuperprojectBranches;

                resultList.Add(menuCommand);
            }

            {
                var menuCommand = new MenuCommand();
                menuCommand.Name          = "ShowSuperprojectRemoteBranches";
                menuCommand.Text          = "Show superproject remote branches";
                menuCommand.ExecuteAction = () => _revisionGrid.ShowSuperprojectRemoteBranches_ToolStripMenuItemClick(null, null);
                menuCommand.IsCheckedFunc = () => AppSettings.ShowSuperprojectRemoteBranches;

                resultList.Add(menuCommand);
            }

            resultList.Add(MenuCommand.CreateSeparator());

            {
                var menuCommand = new MenuCommand();
                menuCommand.Name          = "showRevisionGraphToolStripMenuItem";
                menuCommand.Text          = "Show revision graph";
                menuCommand.ExecuteAction = () => _revisionGrid.ShowRevisionGraph_ToolStripMenuItemClick(null, null);
                menuCommand.IsCheckedFunc = () => _revisionGrid.IsGraphLayout();

                resultList.Add(menuCommand);
            }

            {
                var menuCommand = new MenuCommand();
                menuCommand.Name          = "drawNonrelativesGrayToolStripMenuItem";
                menuCommand.Text          = "Draw non relatives gray";
                menuCommand.ExecuteAction = () => _revisionGrid.DrawNonrelativesGray_ToolStripMenuItemClick(null, null);
                menuCommand.IsCheckedFunc = () => AppSettings.RevisionGraphDrawNonRelativesGray;

                resultList.Add(menuCommand);
            }

            {
                var menuCommand = new MenuCommand();
                menuCommand.Name          = "orderRevisionsByDateToolStripMenuItem";
                menuCommand.Text          = "Order revisions by date";
                menuCommand.ExecuteAction = () => _revisionGrid.OrderRevisionsByDate_ToolStripMenuItemClick(null, null);
                menuCommand.IsCheckedFunc = () => AppSettings.OrderRevisionByDate;

                resultList.Add(menuCommand);
            }

            {
                var menuCommand = new MenuCommand();
                menuCommand.Name          = "showAuthorDateToolStripMenuItem";
                menuCommand.Text          = "Show author date";
                menuCommand.ExecuteAction = () => _revisionGrid.ShowAuthorDate_ToolStripMenuItemClick(null, null);
                menuCommand.IsCheckedFunc = () => AppSettings.ShowAuthorDate;

                resultList.Add(menuCommand);
            }

            {
                var menuCommand = new MenuCommand();
                menuCommand.Name          = "showRelativeDateToolStripMenuItem";
                menuCommand.Text          = "Show relative date";
                menuCommand.ExecuteAction = () => _revisionGrid.ShowRelativeDate_ToolStripMenuItemClick(null, null);
                menuCommand.IsCheckedFunc = () => AppSettings.RelativeDate;

                resultList.Add(menuCommand);
            }

            {
                var menuCommand = new MenuCommand();
                menuCommand.Name = "showMergeCommitsToolStripMenuItem";
                menuCommand.Text = "Show merge commits";
                menuCommand.ShortcutKeyDisplayString = GetShortcutKeyDisplayStringFromRevisionGridIfAvailable(GitUI.RevisionGrid.Commands.ToggleShowMergeCommits);
                menuCommand.ExecuteAction            = () => _revisionGrid.ShowMergeCommits_ToolStripMenuItemClick(null, null);
                menuCommand.IsCheckedFunc            = () => AppSettings.ShowMergeCommits;

                resultList.Add(menuCommand);
            }

            {
                var menuCommand = new MenuCommand();
                menuCommand.Name = "showTagsToolStripMenuItem";
                menuCommand.Text = "Show tags";
                menuCommand.ShortcutKeyDisplayString = GetShortcutKeyDisplayStringFromRevisionGridIfAvailable(GitUI.RevisionGrid.Commands.ToggleShowTags);
                menuCommand.ExecuteAction            = () => _revisionGrid.ShowTags_ToolStripMenuItemClick(null, null);
                menuCommand.IsCheckedFunc            = () => AppSettings.ShowTags;

                resultList.Add(menuCommand);
            }

            {
                var menuCommand = new MenuCommand();
                menuCommand.Name          = "showIdsToolStripMenuItem";
                menuCommand.Text          = "Show SHA-1";
                menuCommand.ExecuteAction = () => _revisionGrid.ShowIds_ToolStripMenuItemClick(null, null);
                menuCommand.IsCheckedFunc = () => AppSettings.ShowIds;

                resultList.Add(menuCommand);
            }

            {
                var menuCommand = new MenuCommand();
                menuCommand.Name          = "showGitNotesToolStripMenuItem";
                menuCommand.Text          = "Show git notes";
                menuCommand.ExecuteAction = () => _revisionGrid.ShowGitNotes_ToolStripMenuItemClick(null, null);
                menuCommand.IsCheckedFunc = () => AppSettings.ShowGitNotes;

                resultList.Add(menuCommand);
            }

            {
                var menuCommand = new MenuCommand();
                menuCommand.Name          = "showIsMessageMultilineToolStripMenuItem";
                menuCommand.Text          = "Show indicator for multiline message";
                menuCommand.ExecuteAction = () =>
                {
                    AppSettings.ShowIndicatorForMultilineMessage = !AppSettings.ShowIndicatorForMultilineMessage;
                    _revisionGrid.ForceRefreshRevisions();
                };
                menuCommand.IsCheckedFunc = () => AppSettings.ShowIndicatorForMultilineMessage;

                resultList.Add(menuCommand);
            }

            resultList.Add(MenuCommand.CreateSeparator());

            {
                var menuCommand = new MenuCommand();
                menuCommand.Name = "ToggleHighlightSelectedBranch";
                menuCommand.Text = "Highlight selected branch (until refresh)";
                menuCommand.ShortcutKeyDisplayString = GetShortcutKeyDisplayStringFromRevisionGridIfAvailable(GitUI.RevisionGrid.Commands.ToggleHighlightSelectedBranch);
                menuCommand.ExecuteAction            = () => _revisionGrid.ExecuteCommand(GitUI.RevisionGrid.Commands.ToggleHighlightSelectedBranch);

                resultList.Add(menuCommand);
            }

            {
                var menuCommand = new MenuCommand();
                menuCommand.Name = "ToggleRevisionCardLayout";
                menuCommand.Text = "Change commit view layout";
                menuCommand.ShortcutKeyDisplayString = GetShortcutKeyDisplayStringFromRevisionGridIfAvailable(GitUI.RevisionGrid.Commands.ToggleRevisionCardLayout);
                menuCommand.ExecuteAction            = () => _revisionGrid.ToggleRevisionCardLayout();

                resultList.Add(menuCommand);
            }

            resultList.Add(MenuCommand.CreateSeparator());

            {
                var menuCommand = new MenuCommand();
                menuCommand.Name  = "showFirstParent";
                menuCommand.Text  = "Show first parents";
                menuCommand.Image = global::GitUI.Properties.Resources.IconShowFirstParent;
                menuCommand.ShortcutKeyDisplayString = GetShortcutKeyDisplayStringFromRevisionGridIfAvailable(GitUI.RevisionGrid.Commands.ShowFirstParent);
                menuCommand.ExecuteAction            = () => _revisionGrid.ShowFirstParent_ToolStripMenuItemClick(null, null);
                menuCommand.IsCheckedFunc            = () => AppSettings.ShowFirstParent;

                resultList.Add(menuCommand);
            }

            {
                var menuCommand = new MenuCommand();
                menuCommand.Name  = "filterToolStripMenuItem";
                menuCommand.Text  = "Set advanced filter";
                menuCommand.Image = global::GitUI.Properties.Resources.IconFilter;
                menuCommand.ShortcutKeyDisplayString = GetShortcutKeyDisplayStringFromRevisionGridIfAvailable(GitUI.RevisionGrid.Commands.RevisionFilter);
                menuCommand.ExecuteAction            = () => _revisionGrid.FilterToolStripMenuItemClick(null, null);

                resultList.Add(menuCommand);
            }

            return(resultList);
        }
        private IEnumerable <MenuCommand> CreateViewMenuCommands()
        {
            return(new[]
            {
                // the first three MenuCommands just reuse (the currently rather
                // convoluted) logic from RevisionGrid.
                //
                // After refactoring the three items should be added to RevisionGrid
                // as done with "ShowRemoteBranches" and not via RevisionGrid.Designer.cs
                new MenuCommand
                {
                    Name = "ShowAllBranches",
                    Text = "Show all branches",
                    ShortcutKeyDisplayString = GetShortcutKeyDisplayStringFromRevisionGridIfAvailable(RevisionGrid.Commands.ShowAllBranches),
                    ExecuteAction = () => _revisionGrid.ShowAllBranches_ToolStripMenuItemClick(null, null),
                    IsCheckedFunc = () => _revisionGrid.ShowAllBranches_ToolStripMenuItemChecked
                },
                new MenuCommand
                {
                    Name = "ShowCurrentBranchOnly",
                    Text = "Show current branch only",
                    ShortcutKeyDisplayString = GetShortcutKeyDisplayStringFromRevisionGridIfAvailable(RevisionGrid.Commands.ShowCurrentBranchOnly),
                    ExecuteAction = () => _revisionGrid.ShowCurrentBranchOnly_ToolStripMenuItemClick(null, null),
                    IsCheckedFunc = () => _revisionGrid.ShowCurrentBranchOnly_ToolStripMenuItemChecked
                },
                new MenuCommand
                {
                    Name = "ShowFilteredBranches",
                    Text = "Show filtered branches",
                    ShortcutKeyDisplayString = GetShortcutKeyDisplayStringFromRevisionGridIfAvailable(RevisionGrid.Commands.ShowFilteredBranches),
                    ExecuteAction = () => _revisionGrid.ShowFilteredBranches_ToolStripMenuItemClick(null, null),
                    IsCheckedFunc = () => _revisionGrid.ShowFilteredBranches_ToolStripMenuItemChecked
                },

                MenuCommand.CreateSeparator(),

                new MenuCommand
                {
                    Name = "ShowRemoteBranches",
                    Text = "Show remote branches",
                    ShortcutKeyDisplayString = GetShortcutKeyDisplayStringFromRevisionGridIfAvailable(RevisionGrid.Commands.ShowRemoteBranches),
                    ExecuteAction = () => _revisionGrid.ShowRemoteBranches_ToolStripMenuItemClick(null, null),
                    IsCheckedFunc = () => AppSettings.ShowRemoteBranches
                },
                new MenuCommand
                {
                    Name = "ShowReflogReferences",
                    Text = "Show reflog references",
                    ExecuteAction = () => _revisionGrid.ShowReflogReferences_ToolStripMenuItemClick(null, null),
                    IsCheckedFunc = () => AppSettings.ShowReflogReferences
                },

                MenuCommand.CreateSeparator(),

                new MenuCommand
                {
                    Name = "ShowSuperprojectTags",
                    Text = "Show superproject tags",
                    ExecuteAction = () => _revisionGrid.ShowSuperprojectTags_ToolStripMenuItemClick(null, null),
                    IsCheckedFunc = () => AppSettings.ShowSuperprojectTags
                },
                new MenuCommand
                {
                    Name = "ShowSuperprojectBranches",
                    Text = "Show superproject branches",
                    ExecuteAction = () => _revisionGrid.ShowSuperprojectBranches_ToolStripMenuItemClick(null, null),
                    IsCheckedFunc = () => AppSettings.ShowSuperprojectBranches
                },
                new MenuCommand
                {
                    Name = "ShowSuperprojectRemoteBranches",
                    Text = "Show superproject remote branches",
                    ExecuteAction = () => _revisionGrid.ShowSuperprojectRemoteBranches_ToolStripMenuItemClick(null, null),
                    IsCheckedFunc = () => AppSettings.ShowSuperprojectRemoteBranches
                },

                MenuCommand.CreateSeparator(),

                new MenuCommand
                {
                    Name = "showRevisionGraphToolStripMenuItem",
                    Text = "Show revision graph",
                    ExecuteAction = () => _revisionGrid.ShowRevisionGraph_ToolStripMenuItemClick(null, null),
                    IsCheckedFunc = () => _revisionGrid.IsGraphLayout()
                },
                new MenuCommand
                {
                    Name = "drawNonrelativesGrayToolStripMenuItem",
                    Text = "Draw non relatives gray",
                    ExecuteAction = () => _revisionGrid.DrawNonrelativesGray_ToolStripMenuItemClick(null, null),
                    IsCheckedFunc = () => AppSettings.RevisionGraphDrawNonRelativesGray
                },
                new MenuCommand
                {
                    Name = "orderRevisionsByDateToolStripMenuItem",
                    Text = "Order revisions by date",
                    ExecuteAction = () => _revisionGrid.OrderRevisionsByDate_ToolStripMenuItemClick(null, null),
                    IsCheckedFunc = () => AppSettings.OrderRevisionByDate
                },
                new MenuCommand
                {
                    Name = "showAuthorDateToolStripMenuItem",
                    Text = "Show author date",
                    ExecuteAction = () => _revisionGrid.ShowAuthorDate_ToolStripMenuItemClick(null, null),
                    IsCheckedFunc = () => AppSettings.ShowAuthorDate
                },
                new MenuCommand
                {
                    Name = "showRelativeDateToolStripMenuItem",
                    Text = "Show relative date",
                    ExecuteAction = () => _revisionGrid.ShowRelativeDate_ToolStripMenuItemClick(null, null),
                    IsCheckedFunc = () => AppSettings.RelativeDate
                },
                new MenuCommand
                {
                    Name = "showMergeCommitsToolStripMenuItem",
                    Text = "Show merge commits",
                    ShortcutKeyDisplayString = GetShortcutKeyDisplayStringFromRevisionGridIfAvailable(RevisionGrid.Commands.ToggleShowMergeCommits),
                    ExecuteAction = () => _revisionGrid.ShowMergeCommits_ToolStripMenuItemClick(null, null),
                    IsCheckedFunc = () => AppSettings.ShowMergeCommits
                },
                new MenuCommand
                {
                    Name = "showTagsToolStripMenuItem",
                    Text = "Show tags",
                    ShortcutKeyDisplayString = GetShortcutKeyDisplayStringFromRevisionGridIfAvailable(RevisionGrid.Commands.ToggleShowTags),
                    ExecuteAction = () => _revisionGrid.ShowTags_ToolStripMenuItemClick(null, null),
                    IsCheckedFunc = () => AppSettings.ShowTags
                },
                new MenuCommand
                {
                    Name = "showIdsToolStripMenuItem",
                    Text = "Show SHA-1",
                    ExecuteAction = () => _revisionGrid.ShowIds_ToolStripMenuItemClick(null, null),
                    IsCheckedFunc = () => AppSettings.ShowIds
                },
                new MenuCommand
                {
                    Name = "showGitNotesToolStripMenuItem",
                    Text = "Show git notes",
                    ExecuteAction = () => _revisionGrid.ShowGitNotes_ToolStripMenuItemClick(null, null),
                    IsCheckedFunc = () => AppSettings.ShowGitNotes
                },
                new MenuCommand
                {
                    Name = "showIsMessageMultilineToolStripMenuItem",
                    Text = "Show indicator for multiline message",
                    ExecuteAction = () =>
                    {
                        AppSettings.ShowIndicatorForMultilineMessage = !AppSettings.ShowIndicatorForMultilineMessage;
                        _revisionGrid.ForceRefreshRevisions();
                    },
                    IsCheckedFunc = () => AppSettings.ShowIndicatorForMultilineMessage
                },

                MenuCommand.CreateSeparator(),

                new MenuCommand
                {
                    Name = "ToggleHighlightSelectedBranch",
                    Text = "Highlight selected branch (until refresh)",
                    ShortcutKeyDisplayString = GetShortcutKeyDisplayStringFromRevisionGridIfAvailable(RevisionGrid.Commands.ToggleHighlightSelectedBranch),
                    ExecuteAction = () => _revisionGrid.ExecuteCommand(RevisionGrid.Commands.ToggleHighlightSelectedBranch)
                },
                new MenuCommand
                {
                    Name = "ToggleRevisionCardLayout",
                    Text = "Change commit view layout",
                    ShortcutKeyDisplayString = GetShortcutKeyDisplayStringFromRevisionGridIfAvailable(RevisionGrid.Commands.ToggleRevisionCardLayout),
                    ExecuteAction = () => _revisionGrid.ToggleRevisionCardLayout()
                },

                MenuCommand.CreateSeparator(),

                new MenuCommand
                {
                    Name = "showFirstParent",
                    Text = "Show first parents",
                    Image = Properties.Resources.IconShowFirstParent,
                    ShortcutKeyDisplayString = GetShortcutKeyDisplayStringFromRevisionGridIfAvailable(RevisionGrid.Commands.ShowFirstParent),
                    ExecuteAction = () => _revisionGrid.ShowFirstParent(),
                    IsCheckedFunc = () => AppSettings.ShowFirstParent
                },
                new MenuCommand
                {
                    Name = "filterToolStripMenuItem",
                    Text = "Set advanced filter",
                    Image = Properties.Resources.IconFilter,
                    ShortcutKeyDisplayString = GetShortcutKeyDisplayStringFromRevisionGridIfAvailable(RevisionGrid.Commands.RevisionFilter),
                    ExecuteAction = () => _revisionGrid.FilterToolStripMenuItemClick(null, null)
                },
                new MenuCommand
                {
                    Name = "ToggleBranchTreePanel",
                    Text = "Toggle left panel",
                    Image = Properties.MsVsImages.Branch_16x,
                    ExecuteAction = () => _revisionGrid.OnToggleBranchTreePanelRequested()
                }
            });
        }