Beispiel #1
0
		public override double Show(Score score, Staff trebleStaff, Staff bassStaff, double left)
		{
			double maxRightClef = left;
			foreach (Staff staff in new[] { trebleStaff, bassStaff })
			{
				string glyphCode = null;
				double glyphTop = staff.StaffPositionToY(StaffPosition.ByLine(2));
				switch (staff.type)
				{
					case Staff.Type.Treble:
						glyphCode = "\x00c9";
						glyphTop -= 57 * score.Magnification;
						break;
					case Staff.Type.Bass:
						glyphCode = "\x00c7";
						glyphTop -= 77.5 * score.Magnification;
						break;
				}
				double rightClef = base.AddFetaGlyph(score, left, glyphTop, glyphCode);
				//Rect boundaryClef = base.AddFetaGlyph(score, left, glyphTop, glyphCode);
				//double rightClef = boundaryClef.Left + boundaryClef.Width;
				if (rightClef > maxRightClef)
					maxRightClef = rightClef;
			}

			double right = maxRightClef + Staff.spaceBetweenSigns * score.Magnification;

			return right;
		}
Beispiel #2
0
		public override double Show(Score score, Staff trebleStaff, Staff bassStaff, double left)
		{
			foreach (Staff staff in new[] { trebleStaff, bassStaff })
			{
				double top = staff.top * score.Magnification;
				UIElement barLine = new Line
				{
					X1 = left,
					X2 = left,
					Y1 = top,
					Y2 = top + Staff.spaceBetweenLines * 4 * score.Magnification,
					Stroke = Brushes.Black,
					StrokeThickness = 1
				};
				base.AddElement(score, barLine);
				//score.Children.Add(barLine);
				//base.elements.Add(barLine);
			}

			double right = left + 1;

			// Czy znak zmieścił sie na pięcolinii?
			if (right >= score.ActualWidth - Staff.marginLeft)
			{
				// Nie zmieścił się - narysujemy ją na następnej pieciolinii.
				Hide(score);

				return -1;
			}

			right = left + 1 + Staff.spaceBetweenSigns * score.Magnification;

			return right;
		}
Beispiel #3
0
		public override double Show(Score score, Staff trebleStaff, Staff bassStaff, double left)
		{
			double signLeft = left;
			foreach (Accidental accidental in accidentals)
			{
				signLeft
					= accidental.Show(score, trebleStaff, bassStaff, signLeft)
					+ Staff.spaceBetweenScaleSigns * score.Magnification;
				base.ExtendBounds(score, accidental.bounds);
			}

			double scaleRight = signLeft + Staff.spaceBetweenSigns;

			return scaleRight;
		}
Beispiel #4
0
		public override double Show(Score score, Staff trebleStaff, Staff bassStaff, double left)
		{
			double right = left;

			string glyphCode = "\x002e";
			foreach (Staff staff in new[] { trebleStaff, bassStaff })
			{
				double glyphTop = staff.StaffPositionToY(staffPosition);

				glyphTop -= 57 * score.Magnification;
				right = base.AddFetaGlyph(score, left, glyphTop, glyphCode);
			}

			return right;
		}
Beispiel #5
0
        public void Show(Score score, Staff trebleStaff, Staff bassStaff)
        {
            const double height = 7;

            // Czy trzeba coś dorysować?
            double y;
            double vertLineTop, verLineBottom;
            double textTop;
            string text;
            switch (howTo)
            {
                case HowTo.TwoOctaveHigher:
                    // Tak, trzeba dorysować znak 15ma
                    y = trebleStaff.StaffPositionToY(StaffPosition.ByLegerAbove(3));
                    vertLineTop = y;
                    verLineBottom = y + height;
                    textTop = trebleStaff.StaffPositionToY(StaffPosition.ByLegerAbove(5));
                    text = "15ma";
                    break;
                case HowTo.OneOctaveHigher:
                    // Tak, trzeba dorysować znak 8va.
                    y = trebleStaff.StaffPositionToY(StaffPosition.ByLegerAbove(6));
                    vertLineTop = y;
                    verLineBottom = y + height;
                    textTop = trebleStaff.StaffPositionToY(StaffPosition.ByLegerAbove(8));
                    text = "8va";
                    break;
                case HowTo.OneOctaveLower:
                    // Tak, trzeba dorysować znak 8vb.
                    y = bassStaff.StaffPositionToY(StaffPosition.ByLegerBelow(4));
                    vertLineTop = y - height;
                    verLineBottom = y;
                    textTop = bassStaff.StaffPositionToY(StaffPosition.ByLegerBelow(4));
                    text = "8vb";
                    break;
                case HowTo.AtPlace:
                default:
                    // Nie trzeba nic rysować.
                    return;
            }

            // Rysuję linię poziomą.
            double delta = Staff.spaceBetweenSigns / 4 * score.Magnification;
            Line horizontalLine = new Line
            {
                X1 = left - delta,
                X2 = right + delta,
                Y1 = y,
                Y2 = y,
                Stroke = Brushes.Black,
                StrokeDashArray = new DoubleCollection { 7, 7 },
                StrokeThickness = 0.5
            };
            base.AddElement(score, horizontalLine);

            // Rysuję linię pionową.
            Line verticalLine = new Line
            {
                X1 = right + delta,
                X2 = right + delta,
                Y1 = vertLineTop,
                Y2 = verLineBottom,
                Stroke = Brushes.Black,
                StrokeThickness = 0.5
            };
            base.AddElement(score, verticalLine);

            // Rysuję oznaczenie 8va, 8vb lub 15ma
            Label name = new Label
            {
                //name.FontFamily = new FontFamily(familyName),
                FontSize = 12 * score.Magnification,
                Content = text,
                Padding = new Thickness(0, 0, 0, 0),
                Margin = new Thickness(left - delta, textTop, 0, 0)
            };
            base.AddElement(score, name);
        }
Beispiel #6
0
		private double ShowStaffs(double left)
		{
			// Rysuję pięciolinię wiolinową.
			double trebleStaffTop = top + spaceAboveTrebleStaff;
			trebleStaff = new Staff(score, Staff.Type.Treble, left, trebleStaffTop);
			trebleStaff.Show();

			// Rysuję pięciolinię basową.
			double bassStaffTop
				= trebleStaffTop
				+ Staff.spaceBetweenLines * 4
				+ spaceBetweenTrebleAndBassStaff;
			bassStaff = new Staff(score, Staff.Type.Bass, left, bassStaffTop);
			bassStaff.Show();

			// Rysuję klucz wiolinowy i basowy.
			clef = new Clef();
			cursor = clef.Show(score, trebleStaff, bassStaff, left);

			// Rysuję znaki przykluczowe wynikające z tonacji.
			cursor = score.scale.Show(score, trebleStaff, bassStaff, cursor);

			// Wyznaczam dolną krawędź StaffGrand i zwracam ją.
			double bottom
				= bassStaffTop
				+ Staff.spaceBetweenLines * 4
				+ spaceBelowBassStaff;

			return bottom;
		}
Beispiel #7
0
		private void ShowPerform(Staff.Type staffType)
		{
			if (score.signs.Count == 0)
				return;

			Perform.HowTo performHowTo = Perform.HowTo.AtPlace;
			double performLeft = 0;
			double performRight = 0;

			int idxFirst = score.signs.FindIndex(sign => sign == firstSign);
			int idxLast = score.signs.FindIndex(sign => sign == lastSign);
			for (int idx = idxFirst; idx <= idxLast; idx++)
			{
				Sign sign = score.signs[idx];

				Perform.HowTo singPerformHowTo;
				double signLeft;
				double signRight;
				if (sign is Chord)
				{
					Chord chord = sign as Chord;
					singPerformHowTo = staffType
						== Staff.Type.Treble
						? chord.performHowToStaffTreble
						: chord.performHowToStaffBass;
					signLeft = chord.left;
					signRight = chord.right;
				}
				else if (sign is Note)
				{
					Note note = sign as Note;
					if (note.staffType != staffType)
						continue;
					singPerformHowTo = note.performHowTo;
					signLeft = note.left;
					signRight = note.right;
				}
				else
				{
					continue;
				}


				bool performChanged = singPerformHowTo != performHowTo;
				bool performNew = performChanged && singPerformHowTo != Perform.HowTo.AtPlace;
				bool performEnd = performChanged && performHowTo != Perform.HowTo.AtPlace;
				if (performEnd)
				{
					// Tu wystąpił koniec znaku zmiany wysokości. Rysuję go.
					// TODO: konstruktor+show() ?
					Perform perform = new Perform(performHowTo, performLeft, performRight);
					performs.Add(perform);
					perform.Show(score, trebleStaff, bassStaff);
					performHowTo = Perform.HowTo.AtPlace;
				}
				if (performNew)
				{
					// Tu wystąpił początek znaku zmiany wysokości. Zapamiętuję jego położnie i wysokość.
					performHowTo = singPerformHowTo;
					performLeft = signLeft;
				}
				performRight = signRight;
			}


			if (performHowTo != Perform.HowTo.AtPlace)
			{
				// Tu wystąpił koniec znaku zmiany wysokości. Rysuję go.
				// TODO: konstruktor+show() ?
				Perform perform = new Perform(performHowTo, performLeft, performRight);
				performs.Add(perform);
				perform.Show(score, trebleStaff, bassStaff);
				performHowTo = Perform.HowTo.AtPlace;
			}
		}
Beispiel #8
0
		public Rectangle AddHighlightRectangle(Score score, Staff trebleStaff, Staff bassStaff, int zindex)
		{

			double top = trebleStaff.StaffPositionToY(StaffPosition.ByLegerAbove(6));
			double bottom = bassStaff.StaffPositionToY(StaffPosition.ByLegerBelow(4));
			highlightRectangle = new Rectangle
			{
				Width = bounds.Width,
				Height = bottom - top,
				Margin = new Thickness(bounds.Left, top, 0, 0),
				Fill = Brushes.Transparent,
				Stroke = Brushes.Transparent,
				Tag = score // potrzebne w event handlerze
			};
			highlightRectangle.MouseEnter += HighlightRectangle_MouseEnter;
			highlightRectangle.MouseLeave += HightlightRectangle_MouseLeave;
			highlightRectangle.MouseDown += HighlightRectangle_MouseDown;
			AddElement(score, highlightRectangle, zindex);
			return highlightRectangle;
		}
Beispiel #9
0
		public virtual double Show(Score score, Staff trebleStaff, Staff bassStaff, double left)
		{
			return left;
		}