private void Fingering(int note, int instrument, long startTime, long endTime, int fretNumber, int stringNumber)
{
string noteString = "";
TextBlock textBlock = new TextBlock();
textBlock.FontSize = 20;
textBlock.FontWeight = FontWeights.Light;
textBlock.TextAlignment = TextAlignment.Left;
textBlock.Foreground = new SolidColorBrush(Colors.White);
Canvas.SetZIndex(textBlock, (int)99);
Rectangle r = new Rectangle();
r.StrokeThickness = 0;
if (instrument == 41) { //VIOLIN
int margin = 300;
int padding = 30;
textBlock.Height = 50;
textBlock.Width = 60;
r.Width = 46;
int[,] violin = new int[4, 2] { { 55, 61 }, { 62, 68 }, { 69, 75 }, { 76, 83 } };
int[] ctrl_violin = { 0, 6, 2, 0, 10 };
for (int i = violin.GetLength(0); i > 0; i--) {
if (note >= violin[i - 1, 0] && note <= violin[i - 1, 1]) {
textBlock.Text = Convert.ToString(note - violin[i - 1, 0]);
r.Fill = new SolidColorBrush(color[ctrl_violin[i]]);
r.Stroke = new SolidColorBrush(border[ctrl_violin[i]]);
textBlock.SetValue(Canvas.LeftProperty, (margin + (i * (r.Width + padding))));
r.SetValue(Canvas.LeftProperty, (double)(margin + (i * (r.Width + padding))));
}
}
r.Height = (endTime - startTime) * multiplier;
textBlock.SetValue(Canvas.TopProperty, (double)((-1 * startTime * multiplier) - 35));
r.SetValue(Canvas.BottomProperty, (double)(startTime) * multiplier);
subcanv.Children.Add(r);
subcanv.Children.Add(textBlock);
}
else if (instrument >= 25 && instrument <= 32) { //GUITAR
int margin = 170;
int padding = 10;
textBlock.Height = 50;
textBlock.Width = 50;
r.Height = 46;
int[,] guitar = new int[6, 2] { { 64, 80 }, { 59, 63 }, { 55, 58 }, { 50, 54 }, { 45, 49 }, { 40, 44 } };
int[] ctrl_guitar = { 1, 8, 9, 10, 0, 2, 6 }; // color data begins at index 1
// replaces loop above, makes use of given string and fret numbers
textBlock.Text = fretNumber.ToString();
textBlock.SetValue(Canvas.TopProperty, (8 + margin + (stringNumber * (r.Height + padding))));
r.Fill = new SolidColorBrush(color[ctrl_guitar[stringNumber + 1]]);
r.Stroke = new SolidColorBrush(border[ctrl_guitar[stringNumber + 1]]);
r.SetValue(Canvas.TopProperty, (margin + (stringNumber * (r.Height + padding))));
r.Width = (endTime - startTime) * multiplier;
textBlock.SetValue(Canvas.LeftProperty, (double)((startTime * multiplier) + 3));
r.SetValue(Canvas.LeftProperty, (double)(startTime) * multiplier);
subcanv.Children.Add(r);
subcanv.Children.Add(textBlock);
}
else if (instrument >= 33 && instrument <= 40) { //BASS
int margin = 200;
int padding = 10;
textBlock.Height = 50;
textBlock.Width = 50;
r.Height = 46;
int[,] bass = new int[4, 2] { { 28, 32 }, { 33, 37 }, { 38, 42 }, { 43, 47 } };
int[] ctrl_bass = { 1, 6, 2, 0, 10 };
for (int i = bass.GetLength(0); i > 0; i--) {
if (note >= bass[i - 1, 0] && note <= bass[i - 1, 1]) {
textBlock.Text = Convert.ToString(note - bass[i - 1, 0]);
r.Fill = new SolidColorBrush(color[ctrl_bass[i]]);
r.Stroke = new SolidColorBrush(border[ctrl_bass[i]]);
textBlock.SetValue(Canvas.TopProperty, (5 + margin + ((i - 1) * (r.Height + padding))));
r.SetValue(Canvas.TopProperty, (double)(margin + ((i - 1) * (r.Height + padding))));
}
}
r.Width = (endTime - startTime) * multiplier;
textBlock.SetValue(Canvas.LeftProperty, (double)((startTime * multiplier) - 14));
r.SetValue(Canvas.LeftProperty, (double)(startTime) * multiplier);
subcanv.Children.Add(r);
subcanv.Children.Add(textBlock);
}
else if (instrument == 74) { //FLUTE
int margin = 40;
int padding = 30;
if (note == 50)
noteString = "01111001110";
else if (note == 51)
noteString = "01111001111";
else if (note == 52 || note == 64)
noteString = "01111001101";
else if (note == 53)
noteString = "01111001001";
else if (note == 54 || note == 66)
noteString = "01111000011";
else if (note == 55 || note == 67)
noteString = "01111000001";
else if (note == 56 || note == 68)
noteString = "01111010001";
else if (note == 57 || note == 69)
noteString = "01110000001";
else if (note == 58)
noteString = "01100001001";
else if (note == 59 || note == 71)
noteString = "01100000001";
else if (note == 60 || note == 72)
noteString = "00100000001";
else if (note == 61 || note == 73)
noteString = "00000000001";
else if (note == 62)
noteString = "01011001110";
else if (note == 63)
noteString = "01011001111";
else if (note == 70)
noteString = "10100000001";
else if (note == 74)
noteString = "01011000001";
else if (note == 75)
noteString = "01111011111";
else if (note == 76)
noteString = "01110001101";
else if (note == 77)
noteString = "01101001001";
else if (note == 78)
noteString = "01101000011";
else if (note == 79)
noteString = "00111000001";
else if (note == 80)
noteString = "00011010001";
else if (note == 81)
noteString = "01010001001";
Rectangle[] rect = new Rectangle[noteString.Length];
for (int i = 0; i < noteString.Length; i++) {
rect[i] = new Rectangle();
}
int rWidth = 46;
for (int i = 0; i < noteString.Length; i++) {
if (i == 0)
rect[i].SetValue(Canvas.LeftProperty, (double)(margin + rWidth));
else
rect[i].SetValue(Canvas.LeftProperty, (double)(margin + ((i + 1) * (rWidth + padding))));
rect[i].Width = rWidth;
if (noteString[i] == '1' && noteString.Length > 3) {
rect[i].Fill = new SolidColorBrush(color[i]);
rect[i].Stroke = new SolidColorBrush(border[i]);
}
rect[i].StrokeThickness = 2;
rect[i].Height = (endTime - startTime) * multiplier;
rect[i].SetValue(Canvas.BottomProperty, (double)(startTime) * multiplier);
subcanv.Children.Add(rect[i]);
}
}
}