private Paint GetPaint(Primitives.Color color, MusicFontStyles fontStyle)
        {
            var paint = new Paint(PaintFlags.AntiAlias);

            paint.Color = new global::Android.Graphics.Color(color.R, color.G, color.B, color.A);
            paint.SetTypeface(typefaces[fontStyle]);
            paint.TextSize = fontSizes[fontStyle];
            return(paint);
        }
Exemple #2
0
 public ArcRenderable(WPos a, WPos b, int zOffset, WAngle angle, Primitives.Color color, WDist width, int segments)
 {
     this.a        = a;
     this.b        = b;
     this.angle    = angle;
     this.color    = color;
     this.zOffset  = zOffset;
     this.width    = width;
     this.segments = segments;
 }
Exemple #3
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 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);
        }
Exemple #5
0
 private System.Drawing.Color ToDrawingColor(Primitives.Color color)
 {
     return(System.Drawing.Color.FromArgb(color.R, color.G, color.B));
 }
        public override void DrawCharacterInBounds(char character, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Size size, Primitives.Color color, MusicalSymbol owner)
        {
            renderingQueue.Enqueue(() => base.DrawCharacterInBounds(character, fontStyle, location, size, color, owner));

            if (renderingQueue.Count > BufferSize)
            {
                FlushBuffer();
            }
        }
Exemple #7
0
 private Color ConvertColor(Primitives.Color color)
 {
     return(Color.FromArgb(color.A, color.R, color.G, color.B));
 }
 public X.Color ConvertColor(Primitives.Color color)
 {
     return(X.Color.FromRgba(color.R, color.G, color.B, color.A));
 }
 public override void DrawCharacterInBounds(char character, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Size size, Primitives.Color color, MusicalSymbol owner)
 {
 }
        /// <summary>
        /// Adds a string to HTML canvas
        /// </summary>
        /// <param name="text"></param>
        /// <param name="fontStyle"></param>
        /// <param name="location"></param>
        /// <param name="color"></param>
        /// <param name="owner"></param>
        public override void DrawString(string text, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Color color, Model.MusicalSymbol owner)
        {
            if (!TypedSettings.Fonts.ContainsKey(fontStyle))
            {
                return;                                                //Nie ma takiego fontu zdefiniowanego. Nie rysuj.
            }
            location = TranslateTextLocation(location, fontStyle);

            Canvas.AppendLine(string.Format("context.font = '{0}pt {1}';", TypedSettings.Fonts[fontStyle].Size.ToStringInvariant(), TypedSettings.Fonts[fontStyle].Name));
            Canvas.AppendLine(string.Format("context.fillText('{0}', {1}, {2});", text, location.X.ToStringInvariant(), location.Y.ToStringInvariant()));

            if (location.X > ActualWidth)
            {
                ActualWidth = location.X;
            }
            if (location.Y > ActualHeight)
            {
                ActualHeight = location.Y;
            }
        }
 public Windows.UI.Color ConvertColor(Primitives.Color color)
 {
     return(Windows.UI.Color.FromArgb(color.A, color.R, color.G, color.B));
 }
 public static Color ToAndroidColor(this Primitives.Color color)
 {
     return(new Color(color.R, color.G, color.B, color.A));
 }
Exemple #13
0
 public override void DrawStringInBounds(string text, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Size size, Primitives.Color color, MusicalSymbol owner)
 {
 }
Exemple #14
0
        public override void DrawString(string text, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Color color, MusicalSymbol owner)
        {
            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);

            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, Model.MusicalSymbol owner)
 {
     using (var paint = GetPaint(color, fontStyle))
     {
         Canvas.DrawText(text, (float)location.X, (float)location.Y, paint);
     }
 }
Exemple #16
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);
        }
Exemple #17
0
 public override void DrawString(string text, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Color color, MusicalSymbol owner)
 {
     Canvas.DrawText(new FormattedText(text, Thread.CurrentThread.CurrentUICulture, FlowDirection.LeftToRight,
                                       TypedSettings.GetFont(fontStyle), TypedSettings.GetFontSize(fontStyle), new SolidColorBrush(ConvertColor(color))),
                     new System.Windows.Point(location.X + 3d, location.Y));
 }
        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 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);

            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);
        }
Exemple #21
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));
        }
Exemple #22
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);
        }
Exemple #23
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 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 DrawString(string text, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Color color, MusicalSymbol owner)
        {
            renderingQueue.Enqueue(() => base.DrawString(text, fontStyle, location, color, owner));

            if (renderingQueue.Count > BufferSize)
            {
                FlushBuffer();
            }
        }
Exemple #26
0
 public static Color ToColor(this Primitives.Color color)
 {
     return(Color.FromArgb(color.A, color.R, color.G, color.B));
 }