public SlideTapRelayReverseOperation(Slide slide, List <Note> noteList) { var tapList = noteList.Where(x => slide.Contains(x) && x is SlideTap).ToList(); var relayList = noteList.Where(x => slide.Contains(x) && x is SlideRelay).ToList(); var tapToRelay = new SlideTapToRelayOperation(slide, tapList); var relayToTap = new SlideRelayToTapOperation(slide, relayList); Invoke += () => { tapToRelay.Invoke(); relayToTap.Invoke(); }; Undo += () => { relayToTap.Undo(); tapToRelay.Undo(); }; }
public SlideRelayToTapOperation(Slide slide, List <Note> noteList) { var tapList = new List <SlideTap>(); var relayList = noteList.Where(x => slide.Contains(x) && x is SlideRelay).ToList(); relayList.ForEach(x => tapList.Add(new SlideTap(x))); Invoke += () => { relayList.ForEach(x => slide.Remove(x)); tapList.ForEach(x => slide.Add(x)); }; Undo += () => { tapList.ForEach(x => slide.Remove(x)); relayList.ForEach(x => slide.Add(x)); }; }
private static bool IsPatternValid(Slide slide, List <Note> pattern) { if (pattern.Count < 2) { return(false); } foreach (var note in pattern) { if (!slide.Contains(note)) { return(false); } } var patternStartTick = pattern.OrderBy(x => x.Position.Tick).First().Position.Tick; var patternEndTick = pattern.OrderBy(x => x.Position.Tick).Last().Position.Tick; if (slide.Where( x => patternStartTick <= x.Position.Tick && x.Position.Tick <= patternEndTick) .Count() != pattern.Count) { return(false); } return(true); }