public ScorePartwisePartBuilder() { part = new ScorePartwisePartMusicXML { Measure = new List <ScorePartwisePartMeasureMusicXML>() }; }
private void AddDefaultPart() { ScorePartwisePartBuilder partBuilder = new ScorePartwisePartBuilder(); ScorePartwisePartMusicXML part = partBuilder.Build(); this.AddPart(part, "Part 0"); }
private void SetMainFields(ScorePartwiseMusicXML score, string partIdValue) { _partId = partIdValue; _currentPart = score.Part.FirstOrDefault(i => i.Id == _partId); _partIndex = score.Part.FindIndex(i => i.Id == _partId); FindPartSystems(score); _numberOfStaves = score.Part[_partIndex].GetStavesCount(); }
/// <summary> /// Generates measure Number between rangeOfMeasures(first,last) of selected Part object /// </summary> /// <param name="part"></param> /// <param name="rangeOfMeasures"></param> /// <returns>Collection of measure Numbers between first and last measure Number of range</returns> public static List <string> TryGetMeasuresIdRange(this ScorePartwisePartMusicXML part, Tuple <string, string> rangeOfMeasures) { List <string> measuresRange = new List <string>(); int startindex = part.Measure.IndexOf(part.Measure.Select(i => i).FirstOrDefault(i => i.Number == rangeOfMeasures.Item1)); int endindex = part.Measure.IndexOf(part.Measure.Select(i => i).FirstOrDefault(i => i.Number == rangeOfMeasures.Item2)); int count = endindex - startindex + 1; measuresRange = part.Measure.GetRange(startindex, count).Select(i => i.Number).ToList(); return(measuresRange); }
public ScorePartwiseBuilder AddPart(ScorePartwisePartMusicXML part, String partName) { if (!score.Part.Any(p => p.Id.Equals(p.Id))) { score.Partlist.ScoreParts.Add(new ScorePartMusicXML { PartId = part.Id, PartName = partName }); score.Part.Add(part); } else { Console.WriteLine($"Part with id {part.Id} already found!"); } return(this); }
/// <summary> /// Search for new-page layout element of measure to calculate Pages count (if loaded score supports layout elements and elements were set) /// </summary> /// <param name="part"></param> /// <returns></returns> public static int TryGetNumberOfPages(this ScorePartwisePartMusicXML part) { int result = 1; foreach (var measure in part.Measure) { var print = measure.Items.OfType <PrintMusicXML>().FirstOrDefault(); if (print != null) { var newPage = print.NewPageSpecified ? print.NewPage : Model.Helpers.SimpleTypes.YesNoMusicXML.no; if (newPage == Model.Helpers.SimpleTypes.YesNoMusicXML.yes) { result++; } } } return(result); }
/// <summary> /// Search for measure object in this part using measure Number /// </summary> /// <param name="part">Selected Part for searching</param> /// <param name="measureNumber">Number value (unique for each measure inside one part)</param> /// <returns></returns> public static ScorePartwisePartMeasureMusicXML GetMeasureUsingId(this ScorePartwisePartMusicXML part, string measureNumber) { var measure = part.Measure.Select(i => i).FirstOrDefault(i => i.Number == measureNumber); return(measure); }
/// <summary> /// Extension method, search for layout elements inside Part object and convers them to list of pages /// </summary> /// <param name="part"></param> /// <returns>Collection of Pages(Collections of system(first measure number, last measure number)</returns> public static List <List <Tuple <string, string> > > TryGetLinesPerPage(this ScorePartwisePartMusicXML part) { List <Tuple <string, string> > measuresPerLine = new List <Tuple <string, string> >(); int pagesCount = part.TryGetNumberOfPages(); List <List <Tuple <string, string> > > linesPerPage = new List <List <Tuple <string, string> > >(); string fistNumber = ""; string lastNumber = ""; foreach (var measure in part.Measure) { var print = measure.Items.OfType <PrintMusicXML>().FirstOrDefault(); if (print != null) { if (print.NewSystemSpecified) { if (print.NewSystem == Model.Helpers.SimpleTypes.YesNoMusicXML.yes) { lastNumber = part.Measure[part.Measure.IndexOf(measure) - 1].Number; Tuple <string, string> t = new Tuple <string, string>(fistNumber, lastNumber); if (part.Measure.IndexOf(measure) != 0) { measuresPerLine.Add(t); } fistNumber = measure.Number; } } if (print.NewPageSpecified) { if (print.NewPage == Model.Helpers.SimpleTypes.YesNoMusicXML.yes) { lastNumber = part.Measure[part.Measure.IndexOf(measure) - 1].Number; Tuple <string, string> t = new Tuple <string, string>(fistNumber, lastNumber); measuresPerLine.Add(t); linesPerPage.Add(new List <Tuple <string, string> >(measuresPerLine)); measuresPerLine.Clear(); fistNumber = measure.Number; } } if (part.Measure.IndexOf(measure) == 0) { fistNumber = measure.Number; } if (part.Measure.IndexOf(measure) == part.Measure.Count - 1) { lastNumber = measure.Number; Tuple <string, string> t = new Tuple <string, string>(fistNumber, lastNumber); measuresPerLine.Add(t); if (measuresPerLine.Count != 0) { linesPerPage.Add(new List <Tuple <string, string> >(measuresPerLine)); } } } else { if (part.Measure.IndexOf(measure) == 0) { fistNumber = measure.Number; } if (part.Measure.IndexOf(measure) == part.Measure.Count - 1) { lastNumber = measure.Number; Tuple <string, string> t = new Tuple <string, string>(fistNumber, lastNumber); measuresPerLine.Add(t); if (measuresPerLine.Count != 0) { linesPerPage.Add(new List <Tuple <string, string> >(measuresPerLine)); } } lastNumber = measure.Number; } } return(linesPerPage); }