コード例 #1
0
ファイル: SkiaGumCanvasView.cs プロジェクト: coldacid/Gum
 private void DarkenElement(BindableGraphicalUiElement elementPushed)
 {
     if (elementPushed is ColoredCircleRuntime circleRuntime)
     {
         circleRuntime.IsDimmed = true;
         InvalidateSurface();
     }
 }
コード例 #2
0
ファイル: SkiaGumCanvasView.cs プロジェクト: coldacid/Gum
        private async void HandleTouch(object sender, SKTouchEventArgs args)
        {
            // Maybe we need to adjust this for other devices?
            float threshold = (float)20;

            // SkiaSharp views return
            // whether they handle touches
            // through args.Handled. If the
            // value is false, then control passes
            // from this view to underlying views. Once
            // it is passed, it does not return to this view
            // until a new touch is initiated.
            switch (args.ActionType)
            {
            case SKTouchAction.Pressed:
                yPushed = args.Location.Y;

                isWithinThreshold = true;

                if (customClickEventToRaise != null)
                {
                    var canProceed = await ExclusiveUiInteractionSemaphor.WaitAsync(0);

                    if (canProceed)
                    {
                        try
                        {
                            await customClickEventToRaise();
                        }
                        finally
                        {
                            ExclusiveUiInteractionSemaphor.Release(1);
                        }
                    }
                }
                else
                {
                    var canProceed = await ExclusiveUiInteractionSemaphor.WaitAsync(0);

                    if (canProceed)
                    {
                        elementPushed = FindClickableElement(args.Location.X, args.Location.Y, GumElementsInternal);
                        if (elementPushed != null)
                        {
                            DarkenElement(elementPushed);
                        }
                        ExclusiveUiInteractionSemaphor.Release(1);
                    }
                }

                args.Handled = true;
                break;

            case SKTouchAction.Moved:
                if (isWithinThreshold)
                {
                    if (System.Math.Abs(args.Location.Y - yPushed) > threshold)
                    {
                        isWithinThreshold = false;
                        var whatToLighten = elementPushed;
                        if (whatToLighten != null)
                        {
                            LightenElement(whatToLighten);
                        }
                    }
                }

                args.Handled = isWithinThreshold;
                break;

            case SKTouchAction.Released:
            {
                var whatToLighten = elementPushed;
                if (whatToLighten != null)
                {
                    LightenElement(whatToLighten);
                }
                if (customTouchEvent != null)
                {
                    var canProceed = await ExclusiveUiInteractionSemaphor.WaitAsync(0);

                    if (canProceed)
                    {
                        try
                        {
                            await customTouchEvent(args.Location.X, args.Location.Y);
                        }
                        finally
                        {
                            ExclusiveUiInteractionSemaphor.Release(1);
                        }
                    }
                }

                await TryClickOnContainedGumObjects(args.Location.X, args.Location.Y);
            }


            break;
            }
        }
コード例 #3
0
ファイル: SkiaGumCanvasView.cs プロジェクト: coldacid/Gum
 public void Add(BindableGraphicalUiElement toAdd)
 {
     GumElementsInternal.Add(toAdd);
 }