Symphonary.NWGUI.InitializeSubCanvas C# (CSharp) Method

InitializeSubCanvas() private method

Initializes the inner scrolling canvas
private InitializeSubCanvas ( ) : void
return void
        private void InitializeSubCanvas()
        {
            if (i_Channel < 0)
                return;

            long lastNote = 0;
            long smallestNoteLength = 0;
            foreach (Note note in midiInfo.notesForAllChannels[i_Channel]) {
               if (smallestNoteLength == 0)
                        smallestNoteLength = note.EndTime - note.BeginTime;
               else if (smallestNoteLength > (note.EndTime - note.BeginTime))
                        smallestNoteLength = (note.EndTime - note.BeginTime);
               if (note.EndTime > lastNote)
                        lastNote = note.EndTime;
            }
            if (smallestNoteLength < 180 && smallestNoteLength > 0) {
                multiplier = 180 / smallestNoteLength;
                if (multiplier > 3) {
                    debugConsole.AddText("Warning: shit's fast, multiplier = " + multiplier + ", shortest visible note is " + smallestNoteLength + "ms.");
                    multiplier = 3;
                }
            }
            if (midiInfo.i_TimeSignatureNumerator == 0)
            {
                midiInfo.i_TimeSignatureNumerator = 4;
            }

            //DrawGridLines(lastNote, (int)(midiInfo.i_TempoInBPM * multiplier), midiInfo.i_TimeSignatureNumerator);

            Note[] notesForSelectedChannel = midiInfo.notesForAllChannels[i_Channel].ToArray();

            // Transpose for guitar
            Transposer.TransposeReturnStatus transposeReturnStatus = Transposer.Transpose(notesForSelectedChannel, 40, 80);
            midiPlayer.NoteOffset = Transposer.Offset;
            if (transposeReturnStatus == Transposer.TransposeReturnStatus.AllNotesAlreadyInRange) {
                debugConsole.AddText("All channel notes in range, no need to transpose.\n");
            }
            else if (transposeReturnStatus == Transposer.TransposeReturnStatus.TransposeUnsuccessful) {
                debugConsole.AddText("WARNING: Transpose was unsuccessful.\n");
            }
            else {
                debugConsole.AddText("Transpose was successful.\n");
            }

            // Allocate strings for guitar
            stringAllocator.Clear();
            stringAllocator.AllocateNotes(notesForSelectedChannel);

            debugConsole.AddText(string.Format("StringAllocator # dropped notes: {0}\n", stringAllocator.NumDroppedNotes));
            debugConsole.AddText(string.Format("StringAllocator # out of range notes: {0}\n", stringAllocator.NumOutOfRangeNotes));

            curCanvasLastNoteIndex = 20;
            //AddNotesToCanvas(0, int.MaxValue);
            AddNotesToCanvas(0, curCanvasLastNoteIndex);
        }