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)); }
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 ToolStripItem BuildMove(TrackedMove move, Action accept, Action discard) { var menu = new ToolStripDropDownButton($"{move.Name} ({move.Extension})"); menu.DropDownDirection = ToolStripDropDownDirection.Left; menu.DropDownItems.Add(new MenuButton("Accept move", accept)); menu.DropDownItems.Add(new MenuButton("Discard", discard)); if (move.Exe != null) { menu.DropDownItems.Add(new MenuButton("Open diff tool", () => DiffToolLauncher.Launch(move))); } menu.DropDownItems.Add(BuildShowInExplorer(move.Temp)); return(menu); }