Beispiel #1
0
    static ToolStripItem BuildDelete(TrackedDelete delete, Action accept)
    {
        var menu = new SplitButton($"{delete.Name}", accept);

        menu.AddRange(
            new MenuButton("Accept delete", accept),
            BuildShowInExplorer(delete.File));
        return(menu);
    }
Beispiel #2
0
    static IEnumerable <ToolStripItem> BuildTrackingMenuItems(Tracker tracker)
    {
        if (!tracker.TrackingAny)
        {
            yield break;
        }

        var deletes = tracker.Deletes
                      .OrderBy(x => x.File)
                      .ToList();

        var moves = tracker.Moves
                    .OrderBy(x => x.Temp)
                    .ToList();
        var count = moves.Count + deletes.Count;

        yield return(new ToolStripSeparator());

        yield return(new MenuButton($"Clear ({count})", tracker.Clear, Images.Clear));

        if (deletes.Any())
        {
            yield return(new ToolStripSeparator());

            yield return(new MenuButton($"Pending Deletes ({deletes.Count}):", tracker.AcceptAllDeletes, Images.Delete));

            foreach (var delete in deletes)
            {
                var menu = new SplitButton($"{delete.Name}", () => tracker.Accept(delete));
                menu.AddRange(
                    new MenuButton("Accept delete", () => tracker.Accept(delete)),
                    new MenuButton("Open directory", () => ExplorerLauncher.ShowFileInExplorer(delete.File)));
                yield return(menu);
            }
        }

        if (moves.Any())
        {
            yield return(new ToolStripSeparator());

            yield return(new MenuButton($"Pending Moves ({moves.Count}):", tracker.AcceptAllMoves, Images.Accept));

            foreach (var move in moves)
            {
                var menu = new SplitButton($"{move.Name} ({move.Extension})", () => tracker.Accept(move));
                menu.AddRange(
                    new MenuButton("Accept move", () => tracker.Accept(move)),
                    new MenuButton("Open diff tool", () => DiffToolLauncher.Launch(move)),
                    new MenuButton("Open directory", () => ExplorerLauncher.ShowFileInExplorer(move.Temp)));
                yield return(menu);
            }
        }

        yield return(new ToolStripSeparator());

        yield return(new MenuButton($"Accept all ({count})", tracker.AcceptAll, Images.AcceptAll));
    }
Beispiel #3
0
    static ToolStripItem BuildMove(TrackedMove move, Action accept)
    {
        var menu = new SplitButton($"{move.Name} ({move.Extension})", accept);

        menu.AddRange(
            new MenuButton("Accept move", accept),
            new MenuButton("Open diff tool", () => DiffToolLauncher.Launch(move)),
            BuildShowInExplorer(move.Temp));
        return(menu);
    }
    static IEnumerable <ToolStripItem> BuildTrackingMenuItems(Tracker tracker)
    {
        if (!tracker.TrackingAny)
        {
            yield break;
        }

        yield return(new MenuButton("Clear", tracker.Clear, Images.Clear));

        if (tracker.Deletes.Any())
        {
            yield return(new ToolStripSeparator());

            yield return(new MenuButton("Pending Deletes:", tracker.AcceptAllDeletes, Images.Delete));

            foreach (var delete in tracker.Deletes)
            {
                var menu = new SplitButton($"{delete.Name}", () => tracker.Accept(delete));
                menu.AddRange(
                    new MenuButton("Accept change", () => tracker.Accept(delete)),
                    new MenuButton("Open directory", () => ExplorerLauncher.ShowFileInExplorer(delete.File)));
                yield return(menu);
            }
        }

        if (tracker.Moves.Any())
        {
            yield return(new ToolStripSeparator());

            yield return(new MenuButton("Pending Moves:", tracker.AcceptAllMoves, Images.Accept));

            foreach (var move in tracker.Moves)
            {
                var menu = new SplitButton($"{move.Name} ({move.Extension})", () => tracker.Accept(move));
                menu.AddRange(
                    new MenuButton("Accept change", () => tracker.Accept(move)),
                    new MenuButton("Launch diff tool", () => ProcessLauncher.Launch(move)),
                    new MenuButton("Open directory", () => ExplorerLauncher.ShowFileInExplorer(move.Temp)));
                yield return(menu);
            }
        }

        yield return(new ToolStripSeparator());

        yield return(new MenuButton("Accept all", tracker.AcceptAll, Images.AcceptAll));
    }