Beispiel #1
0
        /// <summary>
        /// Replaces the DurationSymbol symbolToBeReplaced (which is in this Voice's NoteObjects)
        /// by the all the noteObjects. Sets each of the noteObjects' Voice to this.
        /// </summary>
        public void Replace(DurationSymbol symbolToBeReplaced, List <NoteObject> noteObjects)
        {
            #region conditions
            M.Assert(symbolToBeReplaced != null && symbolToBeReplaced.Voice == this);
            #endregion conditions

            List <NoteObject> tempList = new List <NoteObject>(NoteObjects);
            this.NoteObjects.Clear();
            int i = 0;
            while (tempList.Count > i && tempList[i] != symbolToBeReplaced)
            {
                NoteObjects.Add(tempList[i]);
                i++;
            }
            foreach (NoteObject noteObject in noteObjects)
            {
                noteObject.Voice = this;
                this.NoteObjects.Add(noteObject);
            }
            // tempList[i] is the symbolToBeReplaced
            i++;
            while (tempList.Count > i)
            {
                this.NoteObjects.Add(tempList[i]);
                i++;
            }
            tempList = null;
        }
Beispiel #2
0
 /// <summary>
 /// Appends a clone of the noteObjects to this voice's NoteObjects
 /// (Sets each new noteObjects container to this.)
 /// </summary>
 /// <param name="noteObjects"></param>
 public void AppendNoteObjects(List <NoteObject> noteObjects)
 {
     foreach (NoteObject noteObject in noteObjects)
     {
         noteObject.Voice = this;
         NoteObjects.Add(noteObject);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Sets Chord.Stem.Direction for each chord.
        /// BeamBlocks are created, beginning with a chord that has IsBeamStart == true, and ending with a chord that has IsBeamEnd == true.
        /// BeamBlocks only contain ChordSymbols, but these may be interspersed with other NoteObjects (barlines, clefs, rests, cautionaryChords etc...)
        /// </summary>
        public void SetChordStemDirectionsAndCreateBeamBlocks(PageFormat pageFormat)
        {
            List <List <OutputChordSymbol> > beamedGroups = GetBeamedGroups();

            Clef currentClef = null;
            List <OutputChordSymbol> beamedGroup = null;
            int groupIndex = 0;
            OutputChordSymbol firstChordInVoice = ((OutputChordSymbol)NoteObjects.Find(x => x is OutputChordSymbol));

            foreach (var noteObject in NoteObjects)
            {
                if (noteObject is OutputChordSymbol chord)
                {
                    if (chord.BeamBlockDef != null)
                    {
                        M.Assert(currentClef != null);
                        beamedGroup = beamedGroups[groupIndex];
                        if (chord.IsBeamStart || (chord == firstChordInVoice && (chord.IsBeamRestart || chord.IsBeamEnd)))
                        {
                            groupIndex++;
                        }
                        double beamThickness       = pageFormat.BeamThickness;
                        double beamStrokeThickness = pageFormat.StafflineStemStrokeWidthVBPX;
                        chord.BeamBlock = new BeamBlock(currentClef, beamedGroup, this.StemDirection, beamThickness, beamStrokeThickness);
                    }
                    else if (chord.IsBeamEnd)
                    {
                        beamedGroup = null;
                    }
                    else if (beamedGroup == null)
                    {
                        M.Assert(currentClef != null);
                        if (this.StemDirection == VerticalDir.none)
                        {
                            chord.Stem.Direction = chord.DefaultStemDirection(currentClef);
                        }
                        else
                        {
                            chord.Stem.Direction = this.StemDirection;
                        }
                    }
                }

                if (noteObject is Clef clef)
                {
                    currentClef = clef;
                }
            }
        }