Example #1
0
        protected override void OnAttached()
        {
            // Get the Android View corresponding to the Element that the effect is attached to
            _view = Control == null ? Container : Control;

            // Get access to the TouchEffect class in the .NET Standard library
            XamarinTV.Effects.TouchEffect touchEffect =
                (XamarinTV.Effects.TouchEffect)Element.Effects.
                FirstOrDefault(e => e is XamarinTV.Effects.TouchEffect);

            if (touchEffect != null && _view != null)
            {
                viewDictionary.Add(_view, this);

                _formsElement = Element;

                _libTouchEffect = touchEffect;

                // Save fromPixels function
                _fromPixels = _view.Context.FromPixels;

                // Set event handler on View
                _view.Touch += OnTouch;
            }
        }
Example #2
0
        protected override void OnAttached()
        {
            // Get the Windows FrameworkElement corresponding to the Element that the effect is attached to
            _frameworkElement = Control == null ? Container : Control;

            // Get access to the TouchEffect class in the .NET Standard library
            _effect = (XamarinTV.Effects.TouchEffect)Element.Effects.
                      FirstOrDefault(e => e is XamarinTV.Effects.TouchEffect);

            if (_effect != null && _frameworkElement != null)
            {
                // Save the method to call on touch events
                _onTouchAction = _effect.OnTouchAction;

                // Set event handlers on FrameworkElement
                _frameworkElement.PointerEntered  += OnPointerEntered;
                _frameworkElement.PointerPressed  += OnPointerPressed;
                _frameworkElement.PointerMoved    += OnPointerMoved;
                _frameworkElement.PointerReleased += OnPointerReleased;
                _frameworkElement.PointerExited   += OnPointerExited;
                _frameworkElement.PointerCanceled += OnPointerCancelled;
            }
        }