Browse Source

fixed a .where usage: Added a function to get the visible instruments.

Matthias 9 years ago
parent
commit
284b09f97e
2 changed files with 11 additions and 1 deletions
  1. 1 1
      src/MusicalScore/Graphical/MusicSystem.ts
  2. 10 0
      src/MusicalScore/MusicSheet.ts

+ 1 - 1
src/MusicalScore/Graphical/MusicSystem.ts

@@ -179,7 +179,7 @@ export class MusicSystem extends GraphicalObject {
 
     public createMusicSystemLabel(instrumentLabelTextHeight: number, systemLabelsRightMargin: number, labelMarginBorderFactor: number): void {
         if (this.parent === this.parent.Parent.MusicPages[0] && this === this.parent.MusicSystems[0]) {
-            let instruments: Instrument[] = this.parent.Parent.ParentMusicSheet.Instruments.Where(i => i.Voices.length > 0 && i.Voices[0].Visible);
+            let instruments: Instrument[] = this.parent.Parent.ParentMusicSheet.getVisibleInstruments();
             for (let idx: number = 0, len: number = instruments.length; idx < len; ++idx) {
                 let instrument: Instrument = instruments[idx];
                 let graphicalLabel: GraphicalLabel = new GraphicalLabel(instrument.NameLabel, instrumentLabelTextHeight, TextAlignment.LeftCenter, this.boundingBox);

+ 10 - 0
src/MusicalScore/MusicSheet.ts

@@ -479,4 +479,14 @@ export class MusicSheet /*implements ISettableMusicSheet, IComparable<MusicSheet
             }
         }
     }
+
+    public getVisibleInstruments(): Instrument[] {
+        var visInstruments: Instrument[] = [];
+        for (var idx: number = 0, len = this.Instruments.length; idx < len; ++idx) {
+            var instrument: Instrument = this.Instruments[idx];
+            if (instrument.Voices.length > 0 && instrument.Voices[0].Visible)
+                visInstruments.push(instrument);
+        }
+        return visInstruments;
+    }
 }