GraphicalMusicPage.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import {BoundingBox} from "./BoundingBox";
  2. module PhonicScore.MusicalScore.Graphical.SheetData {
  3. import GraphicalLabel = PhonicScore.MusicalScore.Graphical.Primitives.GraphicalLabel;
  4. import PointF_2D = PhonicScore.Common.DataObjects.PointF_2D;
  5. export class GraphicalMusicPage extends GraphicalObject {
  6. private musicSystems: List<MusicSystem> = new List<MusicSystem>();
  7. private labels: List<GraphicalLabel> = new List<GraphicalLabel>();
  8. private parent: GraphicalMusicSheet;
  9. constructor(parent: GraphicalMusicSheet) {
  10. this.parent = parent;
  11. this.boundingBox = new BoundingBox(null, this);
  12. }
  13. public get MusicSystems(): List<MusicSystem> {
  14. return this.musicSystems;
  15. }
  16. public set MusicSystems(value: List<MusicSystem>) {
  17. this.musicSystems = value;
  18. }
  19. public get Labels(): List<GraphicalLabel> {
  20. return this.labels;
  21. }
  22. public set Labels(value: List<GraphicalLabel>) {
  23. this.labels = value;
  24. }
  25. public get Parent(): GraphicalMusicSheet {
  26. return this.parent;
  27. }
  28. public set Parent(value: GraphicalMusicSheet) {
  29. this.parent = value;
  30. }
  31. public setMusicPageAbsolutePosition(pageIndex: number, rules: EngravingRules): PointF_2D {
  32. if (rules.PagePlacement == PagePlacementEnum.Down)
  33. return new PointF_2D(0.0f, pageIndex * rules.PageHeight);
  34. else if (rules.PagePlacement == PagePlacementEnum.Right)
  35. return new PointF_2D(pageIndex * this.parent.ParentMusicSheet.PageWidth, 0.0f);
  36. else {
  37. if (pageIndex % 2 == 0) {
  38. if (pageIndex == 0)
  39. return new PointF_2D(0.0f, pageIndex * rules.PageHeight);
  40. else return new PointF_2D(0.0f, (pageIndex - 1) * rules.PageHeight);
  41. }
  42. else {
  43. if (pageIndex == 1)
  44. return new PointF_2D(this.parent.ParentMusicSheet.PageWidth, (pageIndex - 1) * rules.PageHeight);
  45. else return new PointF_2D(this.parent.ParentMusicSheet.PageWidth, (pageIndex - 2) * rules.PageHeight);
  46. }
  47. }
  48. }
  49. }
  50. export enum PagePlacementEnum {
  51. Down,
  52. Right,
  53. RightDown
  54. }
  55. }