Пример #1
0
        private ContextMenuStrip GenerateRightClickMenu()
        {
            var menu = new ContextMenuStrip();

            var currentBranch = Settings.Default.CurrentBranch;

            _branchesMenuItem = new ToolStripMenuItem(string.Format("[{0}]", currentBranch), Resources.Branch);

            foreach (var branch in _branchProvider.GetAllRemoteBranches())
            {
                _branchesMenuItem.DropDownItems.Add(new ToolStripMenuItem(branch, null, ChangeBranchClick)
                {
                    Tag = branch
                });
            }

            menu.Items.Add(_branchesMenuItem);
            menu.Items.Add(new ToolStripSeparator());

            _undoToolStripMenuItem = new ToolStripMenuItem(Resources.Undo);
            var lastReservedMigration = Settings.Default.LastResrevedMigration;

            if (lastReservedMigration == null ||
                lastReservedMigration.MigrationType == MigrationType.None)
            {
                DisableUndo();
            }
            else
            {
                EnableUndo(lastReservedMigration);
            }
            _undoToolStripMenuItem.Click += UndoClick;

            menu.Items.Add(_undoToolStripMenuItem);

            var addMigrationMenu = new ToolStripMenuItem("Reserve && copy for", Resources.AddMigration);

            foreach (MigrationType enumValue in Enum.GetValues(typeof(MigrationType)))
            {
                if (enumValue == MigrationType.None)
                {
                    continue;
                }

                addMigrationMenu.DropDownItems.Add(CreateMigrationItem(enumValue));
            }

            menu.Items.Add(addMigrationMenu);
            menu.Items.Add("Manage manually...", Resources.ChangeManually, ShowManageManually);
            menu.Items.Add("&Settings...", Resources.Settings, ShowSettings);
            menu.Items.Add(new ToolStripSeparator());
            menu.Items.Add("&Exit", Resources.Exit, (sender, args) => Application.Exit());
            return(menu);
        }