private void ReDrawLines(Graphics g, Pen pen, MusicSymbol curr, int xpos, MusicSymbol prevChord, int prev_xpos) { int line = 1; 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, ytop); g.TranslateTransform(-prev_xpos, 0); } if (showMeasures) { DrawMeasureNumbers(g, pen); } if (lyrics != null) { DrawLyrics(g, pen); } }
private int Seek(ref float x) { int xpos = keysigWidth; MusicSymbol curr = null; for (int i = 0; i < symbols.Count; i++) { curr = symbols[i]; if (curr is BarSymbol) { xpos += curr.Width; continue; } if (xpos <= x && x < xpos + curr.Width) { x = xpos; return(i); } /* If we've past, we're done. */ if (x < xpos) { return(-1); } } return(-1); }
private static bool IsChord(MusicSymbol symbol) { return symbol is ChordSymbol; }
public int GetHorizontalScrollDestination(int currentPulseTime, int prevPulseTime) { int scrollDestination = 0; /* If there's nothing to unshade, or shade, return */ if ((starttime > prevPulseTime || endtime < prevPulseTime) && (starttime > currentPulseTime || endtime < currentPulseTime)) { return(scrollDestination); } /* 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; } /* If we've past the previous and current times, we're done. */ if ((start > prevPulseTime) && (start > currentPulseTime)) { if (scrollDestination == 0) { scrollDestination = xpos; } return(scrollDestination); } // If symbol is in the current time, draw a shaded background if ((start <= currentPulseTime) && (currentPulseTime < end)) { scrollDestination = xpos; } if (curr is ChordSymbol) { ChordSymbol chord = (ChordSymbol)curr; if (chord.Stem != null && !chord.Stem.Receiver) { prevChord = (ChordSymbol)curr; prev_xpos = xpos; } } xpos += curr.Width; } return(scrollDestination); }
/// <summary> /// 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. /// </summary> /// <param name="g"></param> /// <param name="shadeBrush"></param> /// <param name="pen"></param> /// <param name="currentPulseTime"></param> /// <param name="prevPulseTime"></param> /// <param name="x_shade"></param> public void ShadeNotes(Graphics g, SolidBrush shadeBrush, Pen pen, 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; } // 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; } // If symbol is in the current time, draw a shaded background if ((start <= currentPulseTime) && (currentPulseTime < end)) { x_shade = xpos; g.TranslateTransform(xpos, 0); g.FillRectangle(shadeBrush, 0, 0, curr.Width, this.Height); g.TranslateTransform(-xpos, 0); } if (curr is ChordSymbol) { ChordSymbol chord = (ChordSymbol)curr; if (chord.Stem != null && !chord.Stem.Receiver) { prevChord = (ChordSymbol)curr; prev_xpos = xpos; } } xpos += curr.Width; } }
/** 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. * Returns the width of the shaded rectangle */ public int ShadeNotes(Graphics g, SolidBrush shadeBrush, Pen pen, int currentPulseTime, ref int x_shade) { /* If there's nothing to unshade, or shade, return */ if (starttime > currentPulseTime || endtime < currentPulseTime) { return(0); } /* Skip the left side Clef symbol and key signature */ int xpos = keysigWidth; MusicSymbol curr = null; /* Loop through the symbols. * Unshade symbols where start <= prevPulseTime < end * Shade symbols where start <= currentPulseTime < end */ int width = 0; 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; } /* If we've past the previous and current times, we're done. */ if (start > currentPulseTime) { if (x_shade == 0) { x_shade = xpos; } return(width); } /* If symbol is in the current time, draw a shaded background */ if ((start <= currentPulseTime) && (currentPulseTime < end)) { width += curr.Width; x_shade = xpos; g.TranslateTransform(xpos, 0); if (shadeBrush.IsClear()) { g.ClearRectangle(0, 0, curr.Width, this.Height); } else { g.FillRectangle(shadeBrush, 0, 0, curr.Width, this.Height); } g.TranslateTransform(-xpos, 0); } xpos += curr.Width; } return(width); }
private static bool InsideClipping(Rectangle clip, int xpos, MusicSymbol s) { return((xpos <= clip.X + clip.Width + 50) && (xpos + s.Width + 50 >= clip.X)); }
private static bool IsChord(MusicSymbol symbol) { return(symbol is ChordSymbol); }
/** 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, SolidBrush shadeBrush, Pen pen, 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; } /* 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; } /* 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, ytop); 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; g.TranslateTransform(xpos, 0); g.FillRectangle(shadeBrush, 0, 0, curr.Width, this.Height); curr.Draw(g, pen, ytop); 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 - 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, ytop); g.TranslateTransform(-prev_xpos, 0); } if (showMeasures) { DrawMeasureNumbers(g, pen); } if (lyrics != null) { DrawLyrics(g, 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 ShadeNotes(Graphics g, SolidBrush shadeBrush, Pen pen, float x_shade, bool shade) { /* 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; } /* If we've past, we're done. */ if (x_shade < xpos) { return; } bool redrawLines = false; /* If symbol is in the current time, draw a shaded background */ if (xpos <= x_shade && x_shade < xpos + curr.Width) { if (shade) { g.TranslateTransform(xpos, 0); g.FillRectangle(shadeBrush, 0, 0, curr.Width, this.Height); curr.Draw(g, pen, ytop); g.TranslateTransform(-xpos, 0); //redrawLines = true; if (curr is ChordSymbol) { (curr as ChordSymbol).Play(); } } else { 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, ytop); 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) { ReDrawLines(g, pen, curr, xpos, prevChord, prev_xpos); } 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 OnClick(Graphics g, SolidBrush shadeBrush, Pen pen, float x) { /* Skip the left side Clef symbol and key signature */ int xpos = keysigWidth; MusicSymbol curr = null; ChordSymbol prevChord = null; int prev_xpos = 0; for (int i = 0; i < symbols.Count; i++) { curr = symbols[i]; 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; } /* If we've past, we're done. */ if (x < xpos) { return; } bool redrawLines = false; /* If symbol is in the current time, draw a shaded background */ if (xpos <= x && x < xpos + curr.Width) { if (curr is RestSymbol) { Insert(g, shadeBrush, pen, i, xpos); 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) { ReDrawLines(g, pen, curr, xpos, prevChord, prev_xpos); } if (curr is ChordSymbol) { ChordSymbol chord = (ChordSymbol)curr; if (chord.Stem != null && !chord.Stem.Receiver) { prevChord = (ChordSymbol)curr; prev_xpos = xpos; } } xpos += curr.Width; } }