public static void ResizeToNeighbour(List<PitchBar> listPitchBar, PitchBar newPitchBar) { int index = listPitchBar.IndexOf(newPitchBar); bool isNeedResize = false; // check left if (index - 1 >= 0) { PitchBar leftPitchBar = listPitchBar[index - 1]; if (newPitchBar.StartTime < leftPitchBar.EndTime) { newPitchBar.StartTime = leftPitchBar.EndTime; newPitchBar.Left = leftPitchBar.Left + leftPitchBar.Width; isNeedResize = true; } } // check right if (index + 1 < listPitchBar.Count) { PitchBar rightPitchBar = listPitchBar[index + 1]; if (newPitchBar.EndTime > rightPitchBar.StartTime) { newPitchBar.EndTime = rightPitchBar.StartTime; isNeedResize = true; } } // check need to resize if (isNeedResize) newPitchBar.ResizeAccordingToPixelPerSecond(); }
private void ApplyPropertyPanel(PitchBar pitchBar) { if (pitchBar != null && ValidatePropertyPanel()) { // apply properties pitchBar.StartTime = startTimeProperty; pitchBar.EndTime = endTimeProperty; pitchBar.NoteIndex = Program.RegisteredNotes.Count - 1 - comboBoxNoteIndex.SelectedIndex; pitchBar.Lyric = textBoxLyric.Text; pitchBar.IsLastWord = checkBoxIsEnd.Checked; pitchBar.ResizeAccordingToPixelPerSecond(); Program.ProcessGroupAndWordIndex(ucEditor.PitchBars); CheckIsUICompatible(pitchBar); ucEditor.RefreshScreen(); UpdateStatus("Property Applied"); currencyManager.Refresh(); SaveManager.isDirty = true; // check UI compatible if (pitchBar.Lyric != null && pitchBar.Lyric != "") { //CheckIsUICompatible(); //List<PitchBar> pitchBarInSentence = PitchBar.GetPitchBarsInSentences(ucEditor.PitchBars, pitchBar); //CheckIsUICompatible(pitchBarInSentence); } } }