Ejemplo n.º 1
0
        public void Draw(SKCanvas canvas, SKSize dimension, SKSize view)
        {
            (var scalex, var scaley) = SmartDPI.GetScale(canvas, dimension, view);
            if (ShowTick)
            {
                (var start_x, var start_y, var end_x, var end_y) = TickLine(dimension);
                var temp_paint = MajorPaint(scaley);
                canvas.DrawLine(start_x, start_y, end_x, end_y, temp_paint);

                if (IsMajorTick)
                {
                    if (ShowMajorLabel)
                    {
                        //Handles different DPI
                        (var txt, var pth) = LabelPath(scaley, dimension);
                        canvas.DrawTextOnPath(txt, pth, 0, 0, temp_paint);
                    }
                }
            }
            if (ShowGridline)
            {
                (var x1, var y1, var x2, var y2) = GridLine(dimension);
                canvas.DrawLine(x1, y1, x2, y2, GridPaint(scaley));
            }
        }
        public void Draw(SKCanvas canvas, SKSize dimension, SKSize view)
        {
            float x = 0, y = 0;

            //Handles different DPI
            (var scalex, var scaley) = SmartDPI.GetScale(canvas, dimension, view);
            var temp_paint = MajorPaint(scaley);

            (var dx, var dy) = MeasureText(Title, temp_paint);

            switch (Position)
            {
            case LabelPosition.TopLeft:
                x = Padding.LeftPosition(dimension.Width) + dy;
                y = Padding.TopPosition(dimension.Height) + dy;
                break;

            case LabelPosition.TopRight:
                x = Padding.RightPosition(dimension.Width) - dy - dx;
                y = Padding.TopPosition(dimension.Height) + dy;
                break;

            case LabelPosition.BottomLeft:
                x = Padding.LeftPosition(dimension.Width) + dy;
                y = Padding.BottomPosition(dimension.Height) - dy;
                break;

            case LabelPosition.BottomRight:
                x = Padding.RightPosition(dimension.Width) - dy - dx;
                y = Padding.BottomPosition(dimension.Height) - dy;
                break;
            }
            ;

            canvas.DrawText(Title, x, y, temp_paint);
        }