Ejemplo n.º 1
0
        public override void DrawString(string text, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Color color, MusicalSymbol owner)
        {
            if (!EnsureProperPage(owner))
            {
                return;
            }
            if (Settings.RenderingMode != ScoreRenderingModes.Panorama)
            {
                location = location.Translate(CurrentScore.DefaultPageSettings);
            }

            TextBlock textBlock = new TextBlock();
            Typeface  typeface  = TypedSettings.GetFont(fontStyle);

            textBlock.FontSize    = TypedSettings.GetFontSize(fontStyle);
            textBlock.FontFamily  = typeface.FontFamily;
            textBlock.FontStretch = typeface.Stretch;
            textBlock.FontStyle   = typeface.Style;
            textBlock.FontWeight  = typeface.Weight;
            textBlock.Text        = text;
            textBlock.Foreground  = new SolidColorBrush(ConvertColor(color));
            textBlock.Visibility  = BoolToVisibility(owner.IsVisible);

            var baseline = typeface.FontFamily.Baseline * textBlock.FontSize;

            Canvas.SetLeft(textBlock, location.X);
            Canvas.SetTop(textBlock, location.Y - baseline);
            Canvas.Children.Add(textBlock);

            OwnershipDictionary.Add(textBlock, owner);
        }
Ejemplo n.º 2
0
        public override void DrawCharacterInBounds(char character, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Size size, Primitives.Color color, MusicalSymbol owner)
        {
            if (!EnsureProperPage(owner))
            {
                return;
            }
            if (Settings.RenderingMode != ScoreRenderingModes.Panorama)
            {
                location = location.Translate(CurrentScore.DefaultPageSettings);
            }

            var font = TypedSettings.GetFont(fontStyle);
            var path = new GraphicsPath();

            path.AddString(character.ToString(), font.FontFamily, (int)font.Style, Canvas.DpiY * font.Size / 72, new Point(0, 0), new StringFormat());
            var matrix     = new Matrix();
            var matrix2    = new Matrix();
            var pathBounds = path.GetBounds();
            var scaleX     = (float)size.Width / pathBounds.Width;
            var scaleY     = (float)size.Height / pathBounds.Height;

            matrix2.Translate((float)location.X - (float)LinespacesToPixels(2.5), (float)location.Y - (float)LinespacesToPixels(2.5));  //TODO: Sprawdzić czemu się źle przesuwa i usunąć linespacestopixels
            matrix.Scale(scaleX, scaleY);
            path.Transform(matrix);
            path.Transform(matrix2);
            Canvas.DrawPath(new Pen(ConvertColor(color)), path);
            Canvas.FillPath(new SolidBrush(ConvertColor(color)), path);
        }
        public override void DrawCharacterInBounds(char character, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Size size, Primitives.Color color, MusicalSymbol owner)
        {
            if (!EnsureProperPage(owner))
            {
                return;
            }
            if (Settings.RenderingMode != ScoreRenderingModes.Panorama)
            {
                location = location.Translate(CurrentScore.DefaultPageSettings);
            }

            /*var path = GetPathFromCharacter(character, fontStyle);
             *
             * path.Stroke = new SolidColorBrush(ConvertColor(color));
             * path.Fill = new SolidColorBrush(ConvertColor(color));
             * path.Visibility = BoolToVisibility(owner.IsVisible);
             * path.Stretch = Stretch.Fill;
             *
             * var viewBox = new Viewbox();
             * viewBox.Child = path;
             * viewBox.Width = size.Width;
             * viewBox.Height = size.Height;
             * viewBox.Stretch = Stretch.Fill;
             * Canvas.SetLeft(viewBox, location.X);
             * Canvas.SetTop(viewBox, location.Y);
             * Canvas.Children.Add(viewBox);
             *
             * OwnershipDictionary.Add(path, owner);*/
        }
        public override void DrawBezier(Primitives.Point p1, Primitives.Point p2, Primitives.Point p3, Primitives.Point p4, Primitives.Pen pen, MusicalSymbol owner)
        {
            if (!EnsureProperPage(owner))
            {
                return;
            }
            if (Settings.RenderingMode != ScoreRenderingModes.Panorama)
            {
                p1 = p1.Translate(CurrentScore.DefaultPageSettings);
                p2 = p2.Translate(CurrentScore.DefaultPageSettings);
                p3 = p3.Translate(CurrentScore.DefaultPageSettings);
                p4 = p4.Translate(CurrentScore.DefaultPageSettings);
            }

            var bezierCurve = new BezierCurve();

            bezierCurve.Thickness    = pen.Thickness;
            bezierCurve.Color        = pen.Color;
            bezierCurve.TranslationX = p1.X;
            bezierCurve.TranslationY = p1.Y;
            bezierCurve.X2           = p2.X;
            bezierCurve.Y2           = p2.Y;
            bezierCurve.X3           = p3.X;
            bezierCurve.Y3           = p3.Y;
            bezierCurve.X4           = p4.X;
            bezierCurve.Y4           = p4.Y;

            Canvas.Children.Add(bezierCurve);
            OwnershipDictionary.Add(bezierCurve, owner);
        }
        public override void DrawBezier(Primitives.Point p1, Primitives.Point p2, Primitives.Point p3, Primitives.Point p4, Primitives.Pen pen, MusicalSymbol owner)
        {
            p1 = p1.Translate(CurrentScore.DefaultPageSettings);
            p2 = p2.Translate(CurrentScore.DefaultPageSettings);
            p3 = p3.Translate(CurrentScore.DefaultPageSettings);
            p4 = p4.Translate(CurrentScore.DefaultPageSettings);

            PathGeometry pathGeom = new PathGeometry();
            PathFigure   pf       = new PathFigure();

            pf.StartPoint = new Point(p1.X, p1.Y);
            BezierSegment bezierSegment = new BezierSegment();

            bezierSegment.Point1 = ConvertPoint(p2);
            bezierSegment.Point2 = ConvertPoint(p3);
            bezierSegment.Point3 = ConvertPoint(p4);
            pf.Segments.Add(bezierSegment);
            pathGeom.Figures.Add(pf);

            Path path = new Path();

            path.Stroke          = new SolidColorBrush(ConvertColor(pen.Color));
            path.StrokeThickness = pen.Thickness;
            path.Data            = pathGeom;
            path.Visibility      = BoolToVisibility(owner.IsVisible);
            Windows.UI.Xaml.Controls.Canvas.SetZIndex(path, (int)pen.ZIndex);
            Canvas.Children.Add(path);

            OwnershipDictionary.Add(path, owner);
        }
Ejemplo n.º 6
0
        protected override void DrawPlaybackCursor(PlaybackCursorPosition position, Primitives.Point start, Primitives.Point end)
        {
            if (Settings.RenderingMode != ScoreRenderingModes.Panorama)
            {
                start = start.Translate(CurrentScore.DefaultPageSettings);
                end   = end.Translate(CurrentScore.DefaultPageSettings);
            }

            if (playbackCursor == null)
            {
                playbackCursor = new Line();
                playbackCursor.RenderTransform = playbackCursorTransform;

                playbackCursor.Stroke          = new SolidColorBrush(Colors.Magenta);
                playbackCursor.X1              = 0;
                playbackCursor.X2              = 0;
                playbackCursor.Y1              = 0;
                playbackCursor.Y2              = end.Y - start.Y;
                playbackCursor.Visibility      = BoolToVisibility(position.IsValid);
                playbackCursor.StrokeThickness = 1;
                Canvas.Children.Add(playbackCursor);
            }

            playbackCursorTransform.X = start.X;
            playbackCursorTransform.Y = start.Y;
        }
Ejemplo n.º 7
0
        public override void DrawLine(Primitives.Point startPoint, Primitives.Point endPoint, Primitives.Pen pen, MusicalSymbol owner)
        {
            if (!EnsureProperPage(owner))
            {
                return;
            }
            if (Settings.RenderingMode != ScoreRenderingModes.Panorama)
            {
                startPoint = startPoint.Translate(CurrentScore.DefaultPageSettings);
                endPoint   = endPoint.Translate(CurrentScore.DefaultPageSettings);
            }

            var line = new Line();

            line.Stroke          = new SolidColorBrush(ConvertColor(pen.Color));
            line.X1              = startPoint.X;
            line.X2              = endPoint.X;
            line.Y1              = startPoint.Y;
            line.Y2              = endPoint.Y;
            line.StrokeThickness = pen.Thickness;
            line.Visibility      = BoolToVisibility(owner.IsVisible);
            Canvas.Children.Add(line);

            OwnershipDictionary.Add(line, owner);
        }
        public override void DrawStringInBounds(string text, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Size size, Primitives.Color color, MusicalSymbol owner)
        {
            location = location.Translate(CurrentScore.DefaultPageSettings);

            TextBlock textBlock = new TextBlock();

            textBlock.FontFamily = Fonts.Get(fontStyle);
            textBlock.FontSize   = 200;
            textBlock.Text       = text;
            textBlock.Margin     = new Thickness(0, -25, 0, 0);
            textBlock.Foreground = new SolidColorBrush(ConvertColor(color));
            textBlock.Visibility = BoolToVisibility(owner.IsVisible);

            var viewBox = new Viewbox();

            viewBox.Child           = textBlock;
            viewBox.Width           = size.Width;
            viewBox.Height          = size.Height;
            viewBox.Stretch         = Stretch.Fill;
            viewBox.RenderTransform = new ScaleTransform()
            {
                ScaleX = 1, ScaleY = 1.9
            };
            Windows.UI.Xaml.Controls.Canvas.SetLeft(viewBox, location.X + 3d);
            Windows.UI.Xaml.Controls.Canvas.SetTop(viewBox, location.Y);
            Canvas.Children.Add(viewBox);

            OwnershipDictionary.Add(textBlock, owner);
        }
Ejemplo n.º 9
0
        public override void DrawLine(Primitives.Point startPoint, Primitives.Point endPoint, Primitives.Pen pen, MusicalSymbol owner)
        {
            if (!EnsureProperPage(owner))
            {
                return;
            }
            if (Settings.RenderingMode != ScoreRenderingModes.Panorama)
            {
                startPoint = startPoint.Translate(CurrentScore.DefaultPageSettings);
                endPoint   = endPoint.Translate(CurrentScore.DefaultPageSettings);
            }

            Canvas.DrawLine(ConvertPen(pen), new PointF((float)startPoint.X, (float)startPoint.Y), new PointF((float)endPoint.X, (float)endPoint.Y));
        }
Ejemplo n.º 10
0
        public override void DrawBezier(Primitives.Point p1, Primitives.Point p2, Primitives.Point p3, Primitives.Point p4, Primitives.Pen pen, MusicalSymbol owner)
        {
            if (!EnsureProperPage(owner))
            {
                return;
            }
            if (Settings.RenderingMode != ScoreRenderingModes.Panorama)
            {
                p1 = p1.Translate(CurrentScore.DefaultPageSettings);
                p2 = p2.Translate(CurrentScore.DefaultPageSettings);
                p3 = p3.Translate(CurrentScore.DefaultPageSettings);
                p4 = p4.Translate(CurrentScore.DefaultPageSettings);
            }

            Canvas.DrawBezier(ConvertPen(pen), new PointF((float)p1.X, (float)p1.Y), new PointF((float)p2.X, (float)p2.Y), new PointF((float)p3.X, (float)p3.Y), new PointF((float)p4.X, (float)p4.Y));
        }
Ejemplo n.º 11
0
        public override void DrawString(string text, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Color color, MusicalSymbol owner)
        {
            if (!EnsureProperPage(owner))
            {
                return;
            }
            if (Settings.RenderingMode != ScoreRenderingModes.Panorama)
            {
                location = location.Translate(CurrentScore.DefaultPageSettings);
            }

            var font = TypedSettings.GetFont(fontStyle);
            var baselineDesignUnits = font.FontFamily.GetCellAscent(font.Style);
            var baselinePixels      = (baselineDesignUnits * font.Size) / font.FontFamily.GetEmHeight(font.Style);

            Canvas.DrawString(text, font, new SolidBrush(ConvertColor(color)), new PointF((float)location.X - 4, (float)location.Y - baselinePixels));
        }
Ejemplo n.º 12
0
        public override void DrawCharacterInBounds(char character, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Size size, Primitives.Color color, MusicalSymbol owner)
        {
            if (!EnsureProperPage(owner))
            {
                return;
            }
            if (Settings.RenderingMode != ScoreRenderingModes.Panorama)
            {
                location = location.Translate(CurrentScore.DefaultPageSettings);
            }

            Typeface typeface = TypedSettings.GetFont(fontStyle);

            GlyphTypeface glyphTypeface;

            if (!typeface.TryGetGlyphTypeface(out glyphTypeface))
            {
                return;
            }

            var glyphMap = glyphTypeface.CharacterToGlyphMap;
            var outline  = glyphTypeface.GetGlyphOutline(glyphMap[character], 1000, 100);
            var path     = new Path();

            path.Data = outline;

            path.Stroke     = new SolidColorBrush(ConvertColor(color));
            path.Fill       = new SolidColorBrush(ConvertColor(color));
            path.Visibility = BoolToVisibility(owner.IsVisible);
            path.Stretch    = Stretch.Fill;

            var viewBox = new Viewbox();

            viewBox.Child   = path;
            viewBox.Width   = size.Width;
            viewBox.Height  = size.Height;
            viewBox.Stretch = Stretch.Fill;
            Canvas.SetLeft(viewBox, location.X);
            Canvas.SetTop(viewBox, location.Y);
            Canvas.Children.Add(viewBox);

            OwnershipDictionary.Add(path, owner);
        }
        public override void DrawLine(Primitives.Point startPoint, Primitives.Point endPoint, Primitives.Pen pen, MusicalSymbol owner)
        {
            if (Settings.RenderingMode != ScoreRenderingModes.Panorama)
            {
                startPoint = startPoint.Translate(CurrentScore.DefaultPageSettings);
                endPoint   = endPoint.Translate(CurrentScore.DefaultPageSettings);
            }

            var line = new Line();

            line.TranslationX = startPoint.X;
            line.TranslationY = startPoint.Y;
            line.EndX         = endPoint.X;
            line.EndY         = endPoint.Y;
            line.Color        = pen.Color;
            line.Thickness    = pen.Thickness;

            Canvas.Children.Add(line);
            OwnershipDictionary.Add(line, owner);
        }
Ejemplo n.º 14
0
        public override void DrawString(string text, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Color color, MusicalSymbol owner)
        {
            if (Settings.RenderingMode != ScoreRenderingModes.Panorama)
            {
                location = location.Translate(CurrentScore.DefaultPageSettings);
            }

            TextBlock textBlock = new TextBlock();

            textBlock.FontSize   = Fonts.GetSize(fontStyle);
            textBlock.FontFamily = Fonts.Get(fontStyle);
            textBlock.Text       = text;
            textBlock.Foreground = new SolidColorBrush(ConvertColor(color));
            textBlock.Visibility = BoolToVisibility(owner.IsVisible);
            System.Windows.Controls.Canvas.SetLeft(textBlock, location.X + 3d);
            System.Windows.Controls.Canvas.SetTop(textBlock, location.Y);
            Canvas.Children.Add(textBlock);

            OwnershipDictionary.Add(textBlock, owner);
        }
        public override void DrawString(string text, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Color color, MusicalSymbol owner)
        {
            if (Settings.RenderingMode != ScoreRenderingModes.Panorama)
            {
                location = location.Translate(CurrentScore.DefaultPageSettings);
            }

            var label = new Text();

            label.TranslationX   = location.X;
            label.TranslationY   = location.Y;
            label.Text           = text;
            label.FontFamily     = Fonts.Get(fontStyle).FontFamily;
            label.FontAttributes = Fonts.Get(fontStyle).Attributes;
            label.FontSize       = Fonts.Get(fontStyle).FontSize;
            label.TextColor      = X.Color.Black;
            label.FontStyle      = fontStyle;

            Canvas.Children.Add(label);
            OwnershipDictionary.Add(label, owner);
        }
        public override void DrawString(string text, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Color color, MusicalSymbol owner)
        {
            location = location.Translate(CurrentScore.DefaultPageSettings);

            TextBlock textBlock = new TextBlock();

            textBlock.FontSize          = Fonts.GetSize(fontStyle);
            textBlock.FontFamily        = Fonts.Get(fontStyle);
            textBlock.Text              = text;
            textBlock.Foreground        = new SolidColorBrush(ConvertColor(color));
            textBlock.UseLayoutRounding = true;
            textBlock.Visibility        = BoolToVisibility(owner.IsVisible);

            var baseline = textBlock.BaselineOffset * textBlock.FontSize;

            Canvas.SetLeft(textBlock, location.X);
            Canvas.SetTop(textBlock, location.Y - baseline);
            Canvas.Children.Add(textBlock);

            OwnershipDictionary.Add(textBlock, owner);
        }
        public override void DrawLine(Primitives.Point startPoint, Primitives.Point endPoint, Primitives.Pen pen, MusicalSymbol owner)
        {
            startPoint = startPoint.Translate(CurrentScore.DefaultPageSettings);
            endPoint   = endPoint.Translate(CurrentScore.DefaultPageSettings);

            var line = new Line();

            line.Stroke            = new SolidColorBrush(ConvertColor(pen.Color));
            line.UseLayoutRounding = true;
            line.X1 = startPoint.X;
            line.X2 = endPoint.X;
            line.Y1 = startPoint.Y;
            line.Y2 = endPoint.Y;
            Canvas.SetZIndex(line, (int)pen.ZIndex);
            line.StrokeThickness = pen.Thickness;
            line.Visibility      = BoolToVisibility(owner.IsVisible);

            Canvas.Children.Add(line);

            OwnershipDictionary.Add(line, owner);
        }
        public override void DrawString(string text, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Color color, MusicalSymbol owner)
        {
            location = location.Translate(CurrentScore.DefaultPageSettings);

            var       font      = TypedSettings.Fonts[fontStyle];
            TextBlock textBlock = new TextBlock();

            textBlock.FontSize          = font.Size;
            textBlock.FontFamily        = font.Family;
            textBlock.Text              = text;
            textBlock.Foreground        = new SolidColorBrush(ConvertColor(color));
            textBlock.UseLayoutRounding = true;
            textBlock.Visibility        = BoolToVisibility(owner.IsVisible);

            //var compatibleFont = TypedSettings.GetCompatibleFont(fontStyle);
            //var baselineDesignUnits = compatibleFont.FontFamily.GetCellAscent(compatibleFont.Style);
            var baselinePixels = font.CellAscent; // (baselineDesignUnits * compatibleFont.Size) / compatibleFont.FontFamily.GetEmHeight(compatibleFont.Style);

            Canvas.SetLeft(textBlock, location.X);
            Canvas.SetTop(textBlock, location.Y - baselinePixels);
            Canvas.Children.Add(textBlock);

            OwnershipDictionary.Add(textBlock, owner);
        }