private void EditNoteModeSlide(ScoreEditorHitTestResult hit, MouseEventArgs e) { var editor = _visualizer.Editor; Note lastNote = null; if (editor.HasOneSelectedNote) { lastNote = editor.GetSelectedNote(); } else if (hit.HitAnyNote && editor.HasSelectedNotes) { Debug.Print("You can only select one note to create a slide group."); return; } Note thisNote = null; var isNoteAdded = false; if (hit.HitAnyNote) { // The clicked note is always selected. thisNote = hit.Note == _lastMouseDownNote ? hit.Note : null; } else if (hit.HitBarGridIntersection) { // If not selected, add a note and select it. thisNote = EditorAddNote(hit); isNoteAdded = true; } // If the user clicked on nothing, then clear all selections. if (thisNote == null) { ClearNoteAndBarSelection(); editor.Invalidate(); return; } // If the user clicked on the same note, just perform the standard note selection. if (lastNote == null || lastNote == thisNote) { thisNote.EditorToggleSelected(); editor.Invalidate(); return; } var relationCreated = false; do { // If the selected note is already a slide note and there is a slide relation between the // two notes, then switch selection. if (NoteHelper.AreNotesInSlideChain(thisNote, lastNote)) { // Yep just switch selection. Do nothing in this branch. } else { var errStr = EnsureSlideValid(thisNote, lastNote); if (errStr != null) { if (isNoteAdded) { thisNote.Basic.Bar.RemoveNote(thisNote); } Debug.Print(errStr); break; } // Make slide. var(first, second) = NoteHelper.Split(thisNote, lastNote); NoteHelper.MakeSlide(first, second); _visualizer.InformProjectModified(); relationCreated = true; } } while (false); // Now handle a special case: link flick after a slide. if (!relationCreated) { var(first, second) = NoteHelper.Split(thisNote, lastNote); if (first.Basic.FinishPosition != second.Basic.FinishPosition) { if (first.Helper.IsSlideEnd && second.Helper.IsFlickStart) { NoteHelper.MakeSlideToFlick(first, second); _visualizer.InformProjectModified(); relationCreated = true; } } } if (relationCreated) { thisNote.EditorUnselect(); lastNote.EditorUnselect(); } else { lastNote.EditorUnselect(); thisNote.EditorSelect(); } editor.Invalidate(); }