Beispiel #1
0
        private async void SKCanvasView_OnPaintSurface(object sender, SKPaintSurfaceEventArgs e)
        {
            var canvas = e.Surface.Canvas;

            canvas.Clear(SKColors.Black);
            var point = _complex.ToPoint(time, this.Width / 2 + 100, this.Height / 2);

            _path.Insert(0, point);

            canvas.DrawPoints(SKPointMode.Polygon, _path.ToArray(), new SKPaint()
            {
                Color       = SKColors.White,
                StrokeWidth = 5,

                StrokeJoin           = SKStrokeJoin.Round,
                FilterQuality        = SKFilterQuality.High,
                StrokeCap            = SKStrokeCap.Round,
                IsAntialias          = true,
                HintingLevel         = SKPaintHinting.NoHinting,
                Style                = SKPaintStyle.Fill,
                DeviceKerningEnabled = true
            });



            time += (2f * Math.PI) / Count;
            if (time > 2f * Math.PI)
            {
                time = 0;
                _path.Clear();
            }
            await Task.Delay(1);

            SkCanvasView.InvalidateSurface();
        }
        private void SkCanvasView_OnTouch(object sender, SKTouchEventArgs e)
        {
            // to fix the UWP touch bevaior
            if (Device.RuntimePlatform == Device.UWP)
            {
                // avoid mouse over touch events
                if (!e.InContact)
                {
                    return;
                }
            }

            _lastTouchPoint = e.Location;

            var canvasSize = SkCanvasView.CanvasSize;

            // Check for each touch point XY position to be inside Canvas
            // Ignore any Touch event ocurred outside the Canvas region
            if ((e.Location.X > 0 && e.Location.X < canvasSize.Width) &&
                (e.Location.Y > 0 && e.Location.Y < canvasSize.Height))
            {
                e.Handled = true;

                // update the Canvas as you wish
                SkCanvasView.InvalidateSurface();
            }
        }
Beispiel #3
0
        private async void PickImageEffectButton_Clicked(object sender, EventArgs e)
        {
            var selection = await DisplayActionSheet("Pick an Image Effect", null, "Cancel", imageEffectsList.ToArray());

            if (selection != null && selection != "Cancel")
            {
                selectedImageEffect  = selection;
                EffectNameLabel.Text = $"{selectedImageEffect}";
                SkCanvasView.InvalidateSurface();
            }
        }
        private async void PickShapeToDrawButton_Clicked(object sender, EventArgs e)
        {
            var selection = await DisplayActionSheet("Pick a Shape", null, "Cancel", shapesList.ToArray());

            if (selection != null && selection != "Cancel")
            {
                selectedShape = selection;
                DrawingShapeNameLabel.Text = $"Drawing {selectedShape}";
                SkCanvasView.InvalidateSurface();
            }
        }
Beispiel #5
0
        private void SetPointerRingPosition(double xPositionUnits, double yPositionUnits)
        {
            var xPosition = SkCanvasView.CanvasSize.Width
                            * xPositionUnits; // Calculate actual X Position
            var yPosition = SkCanvasView.CanvasSize.Height
                            * yPositionUnits; // Calculate actual Y Position

            // Update as last touch Position on Canvas
            _lastTouchPoint = new SKPoint(Convert.ToSingle(xPosition), Convert.ToSingle(yPosition));
            SkCanvasView.InvalidateSurface();
        }
        private void SkCanvasView_Touch(object sender, SkiaSharp.Views.Forms.SKTouchEventArgs e)
        {
            if (e.ActionType == SkiaSharp.Views.Forms.SKTouchAction.Pressed)
            {
                _lastTouchPoint = e.Location;
                e.Handled       = true;
            }

            _lastTouchPoint = e.Location;

            SkCanvasView.InvalidateSurface();
        }
        protected override void OnAppearing()
        {
            if (!start)
            {
                StartThreads();

                XplatUIMine.GetInstance().Keyboard = new Keyboard(Entry);
                start = true;
            }

            SkCanvasView.InvalidateSurface();

            base.OnAppearing();
        }
Beispiel #8
0
        /// <summary>
        /// Draw the boarder
        /// </summary>
        /// <returns></returns>
        private async Task PlaceholderToTitleAsync()
        {
            _strokeDashStart = new DashedStroke(
                intervals: new float[] { 0, new SKPathMeasure(_borderPath).Length },
                phase: -0);

            _strokeDashEnd = new DashedStroke(
                intervals: new float[] { new SKPathMeasure(_borderPath).Length, new SKPathMeasure(_borderPath).Length },
                phase: -0);

            var anim = new DashedStrokeAnimation(
                from: _strokeDashStart,
                to: _strokeDashEnd,
                duration: ANIMATION_DURATION);

            await anim.Start((strokeDashToDraw) => SkCanvasView.InvalidateSurface());
        }
Beispiel #9
0
        private void SkCanvasView_OnTouch(object sender, SKTouchEventArgs e)
        {
            _lastTouchPoint = e.Location;

            var canvasSize = SkCanvasView.CanvasSize;

            // Check for each touch point XY position to be inside Canvas
            // Ignore any Touch event ocurred outside the Canvas region
            if ((e.Location.X > 0 && e.Location.X < canvasSize.Width) &&
                (e.Location.Y > 0 && e.Location.Y < canvasSize.Height))
            {
                e.Handled = true;

                // update the Canvas as you wish
                SkCanvasView.InvalidateSurface();
            }
        }
        const double cycleTime = 1000; // in milliseconds

        private void InitAnimation()
        {
            pageIsActive = true;
            stopwatch.Start();

            Device.StartTimer(TimeSpan.FromMilliseconds(33), () =>
            {
                // calculate t for current tick with regards to cycletime
                t = (float)(stopwatch.Elapsed.TotalMilliseconds % cycleTime / cycleTime);
                SkCanvasView.InvalidateSurface();

                if (!pageIsActive)
                {
                    stopwatch.Stop();
                }
                return(pageIsActive);
            });
        }