public TickPair SnapLeftRightTicks(TickPair tickPair, SnapConfig config) { GridPoint gridPointDown = null; GridPoint gridPointUp = null; if (config.SnapGrid) { gridPointDown = guitarTrack.GetCloseGridPointToTick(tickPair.Down); gridPointUp = guitarTrack.GetCloseGridPointToTick(tickPair.Up); } IEnumerable<TickPair> closeLeft6 = null; IEnumerable<TickPair> closeRight6 = null; IEnumerable<TickPair> closeLeft5 = null; IEnumerable<TickPair> closeRight5 = null; if (config.SnapG6 && EditorPro.IsLoaded) { var closeChords6 = Messages.Chords.GetBetweenTick(tickPair.Expand(Utility.TickCloseWidth)).ToList(); closeLeft6 = closeChords6.Where(x => x.TickPair.IsClose(tickPair.Down)).Select(x => x.TickPair); closeRight6 = closeChords6.Where(x => x.TickPair.IsClose(tickPair.Up)).Select(x => x.TickPair); var closePowerups = Messages.Powerups.GetBetweenTick(tickPair.Expand(Utility.TickCloseWidth)).ToList(); if (closePowerups.Any()) { closeLeft6 = closeLeft6.Concat(closePowerups.Where(x => x.TickPair.IsClose(tickPair.Down)).Select(x => x.TickPair)); closeRight6 = closeRight6.Concat(closePowerups.Where(x => x.TickPair.IsClose(tickPair.Up)).Select(x => x.TickPair)); } var closeSolo = Messages.Solos.GetBetweenTick(tickPair.Expand(Utility.TickCloseWidth)).ToList(); if (closeSolo.Any()) { closeLeft6 = closeLeft6.Concat(closeSolo.Where(x => x.TickPair.IsClose(tickPair.Down)).Select(x => x.TickPair)); closeRight6 = closeRight6.Concat(closeSolo.Where(x => x.TickPair.IsClose(tickPair.Up)).Select(x => x.TickPair)); } } if (IsPro && config.SnapG5 && Editor5.IsLoaded) { var closeChords5 = Editor5.Messages.Chords.GetBetweenTick(tickPair.Expand(Utility.TickCloseWidth)).ToList(); closeLeft5 = closeChords5.Where(x => x.TickPair.IsClose(tickPair.Down)).Select(x => x.TickPair); closeRight5 = closeChords5.Where(x => x.TickPair.IsClose(tickPair.Up)).Select(x => x.TickPair); var closePowerups = Editor5.Messages.Powerups.GetBetweenTick(tickPair.Expand(Utility.TickCloseWidth)).ToList(); if (closePowerups.Any()) { closeLeft5 = closeLeft5.Concat(closePowerups.Where(x => x.TickPair.IsClose(tickPair.Down)).Select(x => x.TickPair)); closeRight5 = closeRight5.Concat(closePowerups.Where(x => x.TickPair.IsClose(tickPair.Up)).Select(x => x.TickPair)); } var closeSolo = Editor5.Messages.Solos.GetBetweenTick(tickPair.Expand(Utility.TickCloseWidth)).ToList(); if (closeSolo.Any()) { closeLeft5 = closeLeft5.Concat(closeSolo.Where(x => x.TickPair.IsClose(tickPair.Down)).Select(x => x.TickPair)); closeRight5 = closeRight5.Concat(closeSolo.Where(x => x.TickPair.IsClose(tickPair.Up)).Select(x => x.TickPair)); } } var oldPair = tickPair; var tickPairDown = snapLeftTick(oldPair, gridPointDown, closeLeft6, closeLeft5, config); var tickPairUp = snapRightTick(oldPair, gridPointUp, closeRight6, closeRight5, config); if (tickPairDown.Down != tickPair.Down) { AddSnapPointToRender(GetClientPointFromTick(tickPairDown.Down)); } if (tickPairUp.Up != tickPair.Up) { AddSnapPointToRender(GetClientPointFromTick(tickPairUp.Up)); } return new TickPair(tickPairDown.Down, tickPairUp.Up); }
public List<GuitarChord> PasteCopyBuffer(PastePointParam pastePoint) { var newChords = new List<GuitarChord>(); try { if (CopyChords.Chords.Any()) { if (CurrentSelectionState != TrackEditor.EditorSelectionState.PastingNotes && CurrentSelectionState != TrackEditor.EditorSelectionState.MovingNotes) { CurrentSelectionState = TrackEditor.EditorSelectionState.PastingNotes; return newChords; } BackupSequence(); var copyRange = CopyChords.Chords.GetTickPair(); var stringOffset = (pastePoint.MousePos.Y) - pastePoint.MinNoteString - pastePoint.Offset.Y; var startTick = GetTickFromClientPoint(pastePoint.MousePos.X + pastePoint.Offset.X);// pastePoint.Offset.X + pastePoint.MousePos.X); var pasteRange = new TickPair(startTick, startTick + copyRange.TickLength); var copyTime = guitarTrack.TickToTime(copyRange); var pasteTime = guitarTrack.TickToTime(pasteRange); pasteTime.TimeLength = copyTime.TimeLength; pasteRange.Up = guitarTrack.TimeToTick(pasteTime.Up); pasteRange = EditorPro.SnapTickPairPro(pasteRange); guitarTrack.Remove(Messages.Chords.GetBetweenTick(pasteRange.Expand(-Utility.NoteCloseWidth)).ToList()); foreach (var c in CopyChords.Chords) { var noteTime = guitarTrack.TickToTime(c.TickPair); var delta = noteTime.Down - copyTime.Down; var startEndTick = new TickPair( guitarTrack.TimeToTick(pasteTime.Down + delta), guitarTrack.TimeToTick(pasteTime.Down + delta + c.TimeLength)); var snappedTicks = SnapLeftRightTicks(startEndTick, new SnapConfig(true, true, true)); var newChord = c.CloneAtTime(Messages, snappedTicks, stringOffset); if (newChord != null) { newChords.Add(newChord); } } ClearSelection(); foreach (var c in newChords.Where(x => !x.IsDeleted)) { c.Selected = true; } Invalidate(); } } catch { RestoreBackup(); } return newChords; }