Ejemplo n.º 1
0
        void Handle_PaintSurface(object sender, SKPaintSurfaceEventArgs e)
        {
            if (e.Surface != null)
            {
                var surface       = e.Surface;
                var surfaceWidth  = e.Info.Width;
                var surfaceHeight = e.Info.Height;
                var canvas        = surface.Canvas;

                canvas.Clear(SKColors.Transparent);

                float scale = 1.5f;

                // 667 iphone 8, // 813 iphone x // 736 iphone 8 plus

                /*
                 * var max = (float)UIScreen.MainScreen.Bounds.Height;
                 *
                 * if (UIScreen.MainScreen.Scale > 2)
                 * {
                 *  scale *= 1.5f;
                 * }
                 */

                float y       = 0;
                float xOffset = 0f;

                /*
                 * if (max > 800)
                 * {
                 *  y -= 100f;
                 *  xOffset = 30f;
                 * }
                 */

                var x = 0 + 30f + xOffset;

                float closePositionX = x;
                float closePositionY = xOffset + closeButton.SvgTouched.Picture.CullRect.Height;
                closeButton.Draw(surface.Canvas, closePositionX, closePositionY, paint);

                float trashPositionX = e.Info.Width - xOffset - trashButton.SvgTouched.Picture.CullRect.Width;
                float trashPositionY = xOffset + trashButton.SvgTouched.Picture.CullRect.Height;
                trashButton.Draw(surface.Canvas, trashPositionX, trashPositionY, paint);

                float sendPositionX = e.Info.Width - xOffset - 65f - sendButton.SvgTouched.Picture.CullRect.Width * scale;
                float sendPoisitonY = e.Info.Height - 300 - (sendButton.SvgTouched.Picture.CullRect.Height * scale);
                sendButton.Draw(surface.Canvas, sendPositionX, sendPoisitonY, paint);

                canvas.Flush();
            }
        }
Ejemplo n.º 2
0
        void Handle_PaintSurface(object sender, SKPaintSurfaceEventArgs e)
        {
            if (e.Surface != null)
            {
                var surface       = e.Surface;
                var surfaceWidth  = e.Info.Width;
                var surfaceHeight = e.Info.Height;
                var canvas        = surface.Canvas;

                canvas.Clear(SKColors.Transparent);

                SKPaint paint = new SKPaint();
                paint.IsAntialias = true;

                float scale = 1.5f;

                // 667 iphone 8, // 813 iphone x // 736 iphone 8 plus

                /*
                 * var max = (float)UIScreen.MainScreen.Bounds.Height;
                 *
                 * if (UIScreen.MainScreen.Scale > 2)
                 * {
                 *  scale *= 1.5f;
                 * }
                 */

                var   x       = e.Info.Width / 2 - (takeButton.SvgDefault.Picture.CullRect.Width * scale) / 2;
                var   y       = e.Info.Height - 2 * takeButton.SvgDefault.Picture.CullRect.Height;
                float xOffset = 0f;

                /*
                 *
                 * if (max > 800)
                 * {
                 *  y -= 100f;
                 *  xOffset = 30f;
                 * }
                 */

                surface.Canvas.Translate(x, y);
                takeButton.Draw(surface.Canvas, x, y, paint);

                x = 0 + 30f + xOffset;

                float closePositionX = x;
                float closePositionY = xOffset + closeButton.SvgTouched.Picture.CullRect.Height;
                closeButton.Draw(surface.Canvas, closePositionX, closePositionY, paint);

                float galleryPositionX = x;
                float galleryPositionY = y + (galleryButton.SvgTouched.Picture.CullRect.Height * scale);
                galleryButton.Draw(surface.Canvas, galleryPositionX, galleryPositionY, paint);

                var paintText = new SKPaint
                {
                    Color       = SKColors.White,
                    IsAntialias = true,
                    StrokeWidth = 2f,
                    Style       = SKPaintStyle.Fill,
                    TextAlign   = SKTextAlign.Center,
                    TextSize    = 48
                };

                var textBounds = new SKRect();
                paintText.MeasureText(Counter.ToString(), ref textBounds);

                surface.Canvas.ResetMatrix();
                var halfButton       = (galleryButton.SvgDefault.Picture.CullRect.Width * 2.5f) / 2;
                var halfHeightButton = (galleryButton.SvgDefault.Picture.CullRect.Height * 2.5f) / 2;

                var coord = new SKPoint(galleryPositionX + textBounds.Left + halfButton,
                                        galleryPositionY + halfHeightButton + textBounds.Top * -1 - textBounds.Height / 2);

                canvas.DrawText(Counter.ToString(), coord, paintText);
                counterButton.Draw(surface.Canvas, galleryPositionX, galleryPositionY, paint);

                float cameraPositionX = e.Info.Width - xOffset - 65f - cameraButton.SvgTouched.Picture.CullRect.Width * scale;
                float cameraPoisitonY = y + (cameraButton.SvgTouched.Picture.CullRect.Height * scale);
                cameraButton.Draw(surface.Canvas, cameraPositionX, cameraPoisitonY, paint);

                float sendPositionX = e.Info.Width - xOffset - 65f - sendButton.SvgTouched.Picture.CullRect.Width * scale;
                float sendPoisitonY = y + (cameraButton.SvgTouched.Picture.CullRect.Height * scale);
                sendButton.Draw(surface.Canvas, sendPositionX, sendPoisitonY, paint);

                float flashPositionX = e.Info.Width - xOffset - flashButton.SvgTouched.Picture.CullRect.Width;
                float flashPositionY = xOffset + flashButton.SvgTouched.Picture.CullRect.Height;
                flashButton.Draw(surface.Canvas, flashPositionX, flashPositionY, paint);

                canvas.Flush();
            }
        }