Ejemplo n.º 1
0
        protected void PrerollChildren(PrerollContext context, SKMatrix child_matrix, ref SKRect child_paint_bounds)
        {
            foreach (var layer in layers_)
            {
                PrerollContext child_context = context;
                layer.Preroll(child_context, child_matrix);

                if (layer.needs_system_composite())
                {
                    set_needs_system_composite(true);
                }
                child_paint_bounds.Union(layer.paint_bounds());
            }
        }
Ejemplo n.º 2
0
        protected void PrerollChildren(PrerollContext context, SKMatrix child_matrix, SKRect child_paint_bounds)
        {
            foreach (var layer in layers_)
            {
                //C++ TO C# CONVERTER TODO TASK: The following line was determined to contain a copy constructor call - this should be verified and a copy constructor should be created:
                //ORIGINAL LINE: PrerollContext child_context = *context;
                PrerollContext child_context = context;
                layer.Preroll(child_context, child_matrix);

                if (layer.needs_system_composite())
                {
                    set_needs_system_composite(true);
                }
                child_paint_bounds.Union(layer.paint_bounds());
            }
        }
Ejemplo n.º 3
0
 protected virtual void CreateTransformedBounds()
 {
     foreach (var drawable in ChildrenDrawables)
     {
         if (TransformedBounds.IsEmpty)
         {
             TransformedBounds = drawable.TransformedBounds;
         }
         else
         {
             if (!drawable.TransformedBounds.IsEmpty)
             {
                 TransformedBounds = SKRect.Union(TransformedBounds, drawable.TransformedBounds);
             }
         }
     }
 }
Ejemplo n.º 4
0
        public static void DrawCaptionLabels(this SKCanvas canvas, string label, SKColor labelColor, TextDirection textDirection, float labelTextSpacing, string value, SKColor valueColor, float textSize, SKPoint point, SKTextAlign horizontalAlignment, SKTypeface typeface, out SKRect totalBounds)
        {
            var hasLabel      = !string.IsNullOrEmpty(label);
            var hasValueLabel = !string.IsNullOrEmpty(value);

            totalBounds = new SKRect();

            if (hasLabel || hasValueLabel)
            {
                var hasOffset     = hasLabel && hasValueLabel;
                var captionMargin = textSize * 0.60f;
                var space         = hasOffset ? captionMargin : 0;

                if (hasLabel)
                {
                    using (var paint = new SKPaint
                    {
                        TextSize = textSize,
                        IsAntialias = true,
                        Color = labelColor,
                        IsStroke = false,
                        TextAlign = horizontalAlignment,
                        Typeface = typeface
                    })
                    {
                        var bounds = new SKRect();
                        var text   = label;
                        paint.MeasureText(text, ref bounds);

                        var y = point.Y - ((bounds.Top + bounds.Bottom) / 2) - space;

                        RichString rs;

                        if (typeface != null)
                        {
                            rs = new RichString()
                                 .FontFamily(typeface.FamilyName)
                                 .FontSize(textSize)
                                 .LetterSpacing(labelTextSpacing)
                                 .TextColor(labelColor)
                                 .TextDirection(textDirection)
                                 .Add(text);
                        }
                        else
                        {
                            rs = new RichString()
                                 .FontSize(textSize)
                                 .LetterSpacing(labelTextSpacing)
                                 .TextColor(labelColor)
                                 .TextDirection(textDirection)
                                 .Add(text);
                        }

                        rs.Paint(canvas, new SKPoint(point.X, y), new TextPaintOptions
                        {
                            IsAntialias   = true,
                            LcdRenderText = true
                        });

                        var labelBounds = GetAbsolutePositionRect(point.X, y, bounds, horizontalAlignment);
                        totalBounds = labelBounds.Standardized;
                    }
                }

                if (hasValueLabel)
                {
                    using (var paint = new SKPaint()
                    {
                        TextSize = textSize,
                        IsAntialias = true,
                        FakeBoldText = true,
                        Color = valueColor,
                        IsStroke = false,
                        TextAlign = horizontalAlignment,
                        Typeface = typeface
                    })
                    {
                        var bounds = new SKRect();
                        var text   = value;
                        paint.MeasureText(text, ref bounds);

                        var y = point.Y - ((bounds.Top + bounds.Bottom) / 2) + space;

                        canvas.DrawText(text, point.X, y, paint);

                        var valueBounds = GetAbsolutePositionRect(point.X, y, bounds, horizontalAlignment);

                        if (totalBounds.IsEmpty)
                        {
                            totalBounds = valueBounds;
                        }
                        else
                        {
                            totalBounds.Union(valueBounds);
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public static void DrawCaptionLabels(this SKCanvas canvas, string label, SKColor labelColor, string value, SKColor valueColor, float textSize, SKPoint point, SKTextAlign horizontalAlignment, SKTypeface typeface, out SKRect totalBounds)
        {
            var hasLabel      = !string.IsNullOrEmpty(label);
            var hasValueLabel = !string.IsNullOrEmpty(value);

            totalBounds = new SKRect();

            if (hasLabel || hasValueLabel)
            {
                var hasOffset     = hasLabel && hasValueLabel;
                var captionMargin = textSize * 0.60f;
                var space         = hasOffset ? captionMargin : 0;

                if (hasLabel)
                {
                    using (var paint = new SKPaint
                    {
                        TextSize = textSize,
                        IsAntialias = true,
                        Color = labelColor,
                        IsStroke = false,
                        TextAlign = horizontalAlignment,
                        Typeface = typeface
                    })
                    {
                        var bounds = new SKRect();
                        var text   = label;
                        paint.MeasureText(text, ref bounds);

                        var y = point.Y - ((bounds.Top + bounds.Bottom) / 2) - space;

                        canvas.DrawText(text, point.X, y, paint);

                        var labelBounds = GetAbsolutePositionRect(point.X, y, bounds, horizontalAlignment);
                        totalBounds = labelBounds.Standardized;
                    }
                }

                if (hasValueLabel)
                {
                    using (var paint = new SKPaint()
                    {
                        TextSize = textSize,
                        IsAntialias = true,
                        FakeBoldText = true,
                        Color = valueColor,
                        IsStroke = false,
                        TextAlign = horizontalAlignment,
                        Typeface = typeface
                    })
                    {
                        var bounds = new SKRect();
                        var text   = value;
                        paint.MeasureText(text, ref bounds);

                        var y = point.Y - ((bounds.Top + bounds.Bottom) / 2) + space;

                        canvas.DrawText(text, point.X, y, paint);

                        var valueBounds = GetAbsolutePositionRect(point.X, y, bounds, horizontalAlignment);

                        if (totalBounds.IsEmpty)
                        {
                            totalBounds = valueBounds.Standardized;
                        }
                        else
                        {
                            totalBounds.Union(valueBounds.Standardized);
                        }
                    }
                }
            }
        }