public void selectNotes(int ticksFrom, int ticksTo) { foreach (MusicSymbol s in symbols) { // s is a chordsymbol if (s.GetType() == typeof(ChordSymbol)) { ChordSymbol C = (ChordSymbol)s; s.Selected = false; foreach (MidiNote midinote in C.Notes) { if (midinote.StartTime >= ticksFrom && midinote.StartTime < ticksTo) { midinote.Selected = true; s.Selected = true; } else { midinote.Selected = false; } } } } }
public List <MidiNote> getSelectedNotes() { List <MidiNote> L = new List <MidiNote>(); foreach (MusicSymbol s in symbols) { // s is a chordsymbol if (s.GetType() == typeof(ChordSymbol)) { // Pour une raison que j'ignore, on perd la valeur Selected du symbole, mais pas celle des notes ... //if (s.Selected) //{ ChordSymbol C = (ChordSymbol)s; foreach (MidiNote n in C.Notes) { if (n.Selected) { L.Add(n); } } //} } } return(L); }
/** Find the initial clef to use for this staff. Use the clef of * the first ChordSymbol. */ private Clef FindClef(List <MusicSymbol> list) { foreach (MusicSymbol m in list) { if (m is ChordSymbol) { ChordSymbol c = (ChordSymbol)m; return(c.Clef); } } return(Clef.Treble); }
public void ClearSelectedNotes() { foreach (MusicSymbol s in symbols) { // s is a chordsymbol if (s.GetType() == typeof(ChordSymbol)) { ChordSymbol C = (ChordSymbol)s; foreach (MidiNote n in C.Notes) { n.Selected = false; } } } }
/// <summary> /// Using SlNotes, select notes /// </summary> /// <param name="SlNotes"></param> public void RestoreSelectedNotes(List <MidiNote> SlNotes) { for (int i = 0; i < SlNotes.Count; i++) { MidiNote note = SlNotes[i]; foreach (MusicSymbol s in symbols) { // s is a chordsymbol if (s.GetType() == typeof(ChordSymbol)) { ChordSymbol C = (ChordSymbol)s; foreach (MidiNote n in C.Notes) { if (note.Number == n.Number && note.StartTime == n.StartTime) { n.Selected = true; s.Selected = true; } } } } } }
/** Calculate the start and end time of this staff. */ private void CalculateStartEndTime() { starttime = endtime = 0; if (symbols.Count == 0) { return; } starttime = symbols[0].StartTime; foreach (MusicSymbol m in symbols) { if (endtime < m.StartTime) { endtime = m.StartTime; } if (m is ChordSymbol) { ChordSymbol c = (ChordSymbol)m; if (endtime < c.EndTime) { endtime = c.EndTime; } } } }
/** Shade all the chords played in the given time. * Un-shade any chords shaded in the previous pulse time. * Store the x coordinate location where the shade was drawn. */ public void ShadeNotes(Graphics g, Rectangle clip, SolidBrush shadeBrush, Pen pen, int currentPulseTime, int prevPulseTime, ref int x_shade, Rectangle selrect, int OffsetX) { /* If there's nothing to unshade, or shade, return */ if ((starttime > prevPulseTime || endtime < prevPulseTime) && (starttime > currentPulseTime || endtime < currentPulseTime)) { return; } int yy = ytop; /* Skip the left side Clef symbol and key signature */ int xpos = keysigWidth; MusicSymbol curr = null; ChordSymbol prevChord = null; int prev_xpos = 0; /* Loop through the symbols. * Unshade symbols where start <= prevPulseTime < end * Shade symbols where start <= currentPulseTime < end */ for (int i = 0; i < symbols.Count; i++) { curr = symbols[i]; if (curr is BarSymbol) { xpos += curr.Width; continue; } int start = curr.StartTime; int end = 0; if (i + 2 < symbols.Count && symbols[i + 1] is BarSymbol) { end = symbols[i + 2].StartTime; } else if (i + 1 < symbols.Count) { end = symbols[i + 1].StartTime; } else { end = endtime; } // Sortir dès le premier symbole dont le startTime est supérieur à currentPulsetime /* If we've past the previous and current times, we're done. */ if ((start > prevPulseTime) && (start > currentPulseTime)) { if (x_shade == 0) { x_shade = xpos; } return; } // comprend pas !!!!!!!!!!!!!!! /* If shaded notes are the same, we're done */ if ((start <= currentPulseTime) && (currentPulseTime < end) && (start <= prevPulseTime) && (prevPulseTime < end)) { x_shade = xpos; return; } bool redrawLines = false; /* If symbol is in the previous time, draw a white background */ if ((start <= prevPulseTime) && (prevPulseTime < end)) { /* * g.TranslateTransform(xpos - 2, -2); * g.FillRectangle(Brushes.White, 0, 0, curr.Width + 4, this.Height + 4); * g.TranslateTransform(-(xpos - 2), 2); * g.TranslateTransform(xpos, 0); * curr.Draw(g, pen, yy); * g.TranslateTransform(-xpos, 0); * * redrawLines = true; */ } /* If symbol is in the current time, draw a shaded background */ if ((start <= currentPulseTime) && (currentPulseTime < end)) { x_shade = xpos; //FAB: 09/04/2015 return; /* * g.TranslateTransform(xpos, 0); * g.FillRectangle(shadeBrush, 0, 0, curr.Width, this.Height); * curr.Draw(g, pen, yy); * g.TranslateTransform(-xpos, 0); * redrawLines = true; */ } /* If either a gray or white background was drawn, we need to redraw * the horizontal staff lines, and redraw the stem of the previous chord. */ if (redrawLines) { int line = 1; //int y = ytop - 5* SheetMusic.LineWidth; int y = yy; //FAB //int y = ytop - SheetMusic.LineWidth; pen.Width = 1; g.TranslateTransform(xpos - 2, 0); for (line = 1; line <= 5; line++) { g.DrawLine(pen, 0, y, curr.Width + 4, y); y += SheetMusic.LineWidth + SheetMusic.LineSpace; } g.TranslateTransform(-(xpos - 2), 0); if (prevChord != null) { g.TranslateTransform(prev_xpos, 0); prevChord.Draw(g, pen, yy, this.tracknum, selrect, OffsetX); g.TranslateTransform(-prev_xpos, 0); } if (showMeasures) { DrawMeasureNumbers(g, clip, pen); } if (lyrics != null) { DrawLyrics(g, clip, pen); } } if (curr is ChordSymbol) { ChordSymbol chord = (ChordSymbol)curr; if (chord.Stem != null && !chord.Stem.Receiver) { prevChord = (ChordSymbol)curr; prev_xpos = xpos; } } xpos += curr.Width; } }
public void findScroll(int currentPulseTime, int prevPulseTime, ref int x_shade) { /* If there's nothing to unshade, or shade, return */ if ((starttime > prevPulseTime || endtime < prevPulseTime) && (starttime > currentPulseTime || endtime < currentPulseTime)) { return; } /* Skip the left side Clef symbol and key signature */ int xpos = keysigWidth; MusicSymbol curr = null; ChordSymbol prevChord = null; int prev_xpos = 0; /* Loop through the symbols. * Unshade symbols where start <= prevPulseTime < end * Shade symbols where start <= currentPulseTime < end */ for (int i = 0; i < symbols.Count; i++) { curr = symbols[i]; if (curr is BarSymbol) { xpos += curr.Width; continue; } int start = curr.StartTime; int end = 0; if (i + 2 < symbols.Count && symbols[i + 1] is BarSymbol) { end = symbols[i + 2].StartTime; } else if (i + 1 < symbols.Count) { end = symbols[i + 1].StartTime; } else { end = endtime; } // Sortir dès le premier symbole dont le startTime est supérieur à currentPulsetime /* If we've past the previous and current times, we're done. */ if ((start > prevPulseTime) && (start > currentPulseTime)) { if (x_shade == 0) { x_shade = xpos; } return; } // comprend pas !!!!!!!!!!!!!!! /* If shaded notes are the same, we're done */ if ((start <= currentPulseTime) && (currentPulseTime < end) && (start <= prevPulseTime) && (prevPulseTime < end)) { x_shade = xpos; return; } /* If symbol is in the current time, draw a shaded background */ if ((start <= currentPulseTime) && (currentPulseTime < end)) { x_shade = xpos; //FAB: 09/04/2015 return; } if (curr is ChordSymbol) { ChordSymbol chord = (ChordSymbol)curr; if (chord.Stem != null && !chord.Stem.Receiver) { prevChord = (ChordSymbol)curr; prev_xpos = xpos; } } xpos += curr.Width; } }