/// <summary> /// Logic that handles selecting two groups of event stubs, and then executing a given action when /// both groups are selected and the Finish button is pressed. /// </summary> private void InitDualGroupSelection(Action<HashSet<EventStub>, HashSet<EventStub>> onSelectionEnd) { HashSet<EventStub> firstSet = new HashSet<EventStub>(); HashSet<EventStub> secondSet = new HashSet<EventStub>(); //all onClick actions Action<EventStub> highlightGreen = (EventStub evnt) => SetEventColor(evnt, Color.green); Action<EventStub> highlightMagenta = (EventStub evnt) => SetEventColor(evnt, Color.magenta); Action<EventStub> addToFirst = (EventStub e) => firstSet.Add(e); Action<EventStub> addToSecond = (EventStub e) => secondSet.Add(e); onEventLeftClick.Add(addToFirst); onEventLeftClick.Add(highlightGreen); ActionBar bar = new ActionBar(true); bar.AddButton("Cancel", () => { onEventLeftClick.Remove(addToFirst); onEventLeftClick.Remove(addToSecond); onEventLeftClick.Remove(highlightGreen); onEventLeftClick.Remove(highlightMagenta); ResetEventColors(firstSet.Union(secondSet)); parent.PopActionBar(); }); bar.AddButton("Next", () => { onEventLeftClick.Remove(addToFirst); onEventLeftClick.Remove(highlightGreen); onEventLeftClick.Add(highlightMagenta); onEventLeftClick.Add(addToSecond); bar.RemoveButton("Next"); bar.AddButton("Finish", () => { onEventLeftClick.Remove(addToSecond); parent.PopActionBar(); onEventLeftClick.Remove(highlightMagenta); ResetEventColors(firstSet.Union(secondSet)); onSelectionEnd.Invoke(firstSet, secondSet); }); }); parent.AddActionBar(bar); }