Bindable Property destroying SkiaSharp Rectangle

I have a very strange issue. In the following code at 261 in the TouchActioNTypeCancelled i want to call a Method which should set the CroppingRect.Rect to my bindable Property testImage. The Strange thing: When testIamge is a normal Property, not bindable, everything works fine. I can move the croppign rectangle with all corners in the view. If i now change the Proeprty to a bindable property when i start movign the rectangle on one corner in the app i can move the rectangle only from the opposite corners again and if i press the opposite corner, the rectangle buggs back into its original position. I don't understand how this can happen. I did not yet consume the Property in the view since i wanted to check first if it works without consuming it.

This is the way it works with a npormal property. In fact, this is, how i want it to work with a bindable proeprty as well: Workign example(only with normal property)

This, however, is how it works with the bindable property currently: Not working example(Bindable property)

public static readonly BindableProperty testImageProperty =
            BindableProperty.Create(nameof(testImage), typeof(SKRect), typeof(SKRect));

        public SKRect testImage
        {
            get
            {
                return (SKRect)GetValue(testImageProperty);
            }
            set
            {
                SetValue(testImageProperty, value);
            }

        }

//public SKRect testImage { get; set; }

void OnTouchEffectTouchAction(object sender, TouchActionEventArgs args)
        {
            int i = 0;
            SKPoint pixelLocation = ConvertToPixel(args.Location);
            SKPoint bitmapLocation = inverseBitmapMatrix.MapPoint(pixelLocation);

            switch (args.Type)
            {
                case TouchActionType.Pressed:
                    // Convert radius to bitmap/cropping scale
                    float radius = inverseBitmapMatrix.ScaleX * RADIUS;

                    // Find corner that the finger is touching
                    int cornerIndex = croppingRect.HitTest(bitmapLocation, radius);

                    if (cornerIndex != -1 && !touchPoints.ContainsKey(args.Id))
                    {
                        TouchPoint touchPoint = new TouchPoint
                        {
                            CornerIndex = cornerIndex,
                            Offset = bitmapLocation - croppingRect.Corners[cornerIndex]
                        };

                        touchPoints.Add(args.Id, touchPoint);
                    }
                    break;

                case TouchActionType.Moved:
                    if (touchPoints.ContainsKey(args.Id))
                    {
                        TouchPoint touchPoint = touchPoints[args.Id];
                        croppingRect.MoveCorner(touchPoint.CornerIndex, 
                                                bitmapLocation - touchPoint.Offset);
                        InvalidateSurface();
                    }
                    break;
                      
                case TouchActionType.Released:
                case TouchActionType.Cancelled:
                    if (touchPoints.ContainsKey(args.Id))
                    {
                        SetMap();
                        touchPoints.Remove(args.Id);
                    }
                    break;
            }
            
        }

        private void SetMap()
        {
            testImage = croppingRect.Rect;
            Console.WriteLine("test");
            
        }


Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)