Beispiel #1
0
 public TouchEventArgs(long id, TouchEventType type, float x, float y, bool isInContact)
 {
     Id          = id;
     Type        = type;
     MyPoint     = new Point(x, y);
     IsInContact = isInContact;
 }
Beispiel #2
0
 public TouchEventArgs(long id, TouchEventType type, Point point, bool isInContact)
 {
     Id          = id;
     Type        = type;
     MyPoint     = point;
     IsInContact = isInContact;
 }
        /// <summary>
        /// Handles a <see cref="E:Stylus" /> event.
        /// </summary>
        /// <param name="e">The <see cref="StylusEventArgs"/> instance containing the event data.</param>
        /// <param name="touchEventType">The <see cref="TouchEventType"/> event type</param>
        private void OnStylus(StylusEventArgs e, TouchEventType touchEventType)
        {
            var browser = GetBrowser();

            var stylusPoints = e.GetStylusPoints(this);

            if (!e.Handled && browser != null && e.StylusDevice != null && e.StylusDevice.TabletDevice.Type == TabletDeviceType.Stylus && stylusPoints.Count > 0)
            {
                var modifiers   = WpfExtensions.GetModifierKeys();
                var pressure    = stylusPoints[0].PressureFactor;
                var pointerType = e.StylusDevice.Inverted ? PointerType.Eraser : PointerType.Pen;

                var touchEvent = new TouchEvent()
                {
                    Id          = e.StylusDevice.Id,
                    X           = (float)stylusPoints[0].X,
                    Y           = (float)stylusPoints[0].Y,
                    PointerType = pointerType,
                    Pressure    = pressure,
                    Type        = touchEventType,
                    Modifiers   = modifiers,
                };

                browser.GetHost().SendTouchEvent(touchEvent);

                e.Handled = true;
            }
        }
        private void OnTryMoveOrSkill(TriggerParamTouch param, TouchEventType type)
        {
            this.targetCom.ClearTarget();
            this.targetCom.UpdateTarget(param.Pos);
            Vector3 groundPoint = this.targetCom.GroundPoint;
            Units   units       = this.targetCom.TargetUnit;
            bool    forceSend   = type != TouchEventType.press;

            if (units != null && !units.CanBeSelected)
            {
                units = null;
            }
            if (!this.self.CanManualControl())
            {
                return;
            }
            if (units == null)
            {
                if (!this.targetCom.ValidGroudPoint)
                {
                    return;
                }
                this.DisableAIAutoAttackMove();
                this.targetCom.DrawMoveFlag();
                this.self.mCmdCacheController.EnqueueMoveCmd(groundPoint, forceSend);
                this.lastTarget = null;
            }
            else if (type == TouchEventType.down || (type != TouchEventType.down && this.lastTarget != units))
            {
                this.lastTarget = units;
                this.DisableAIAutoAttackMove();
                this.targetCom.ClearMoveFlag();
                this.self.mCmdCacheController.EnqueueSkillCmd(this.self.attacks[0], groundPoint, units, true, true);
            }
        }
        override public Gesture UpdateGestureFromTouches(NSSet touches, TouchEventType touchType)
        {
            base.UpdateGestureFromTouches(touches, touchType);

            // Take action based on the number of touches
            switch (currentTouches.Count)
            {
            case 0:
                // Nothing to process
                return(this);

            case 2:
                // Update this gesture
                UpdateGesture(null);
                return(this);

            default:
                // Finish this two finger gesture and switch to no gesture -> The user
                // will have to release all other fingers and touch the screen again
                // to start a new gesture.
                FinishGesture();
                this.refreshTimer?.Dispose();
                // Erase reference to timer in case callback fires one last time
                this.refreshTimer = null;
                return(null);
            }
        }
Beispiel #6
0
        public override void AnimateTouch(TouchEventType touch)
        {
            if (_selectedColor != null)
            {
                switch (touch)
                {
                case TouchEventType.Begin:
                    _view.BackgroundColor = _selectedColor;
                    break;

                case TouchEventType.Cancel:
                case TouchEventType.End:
                    UIView.BeginAnimations(null);
                    UIView.SetAnimationDuration(0.1);
                    _view.BackgroundColor = _backgroundColor;
                    UIView.CommitAnimations();
                    break;
                }
            }

            foreach (var control in _controls)
            {
                control.AnimateTouch(touch);
            }
        }
        /// <summary>
        /// Handles a <see cref="E:Stylus" /> event.
        /// </summary>
        /// <param name="e">The <see cref="StylusEventArgs"/> instance containing the event data.</param>
        /// <param name="touchEventType">The <see cref="TouchEventType"/> event type</param>
        private void OnStylus(StylusEventArgs e, TouchEventType touchEventType)
        {
            var browser = GetBrowser();

            if (!e.Handled && browser != null)
            {
                var modifiers   = WpfExtensions.GetModifierKeys();
                var pointerType = e.StylusDevice.Inverted ? PointerType.Eraser : PointerType.Pen;
                //Send all points to host
                foreach (var stylusPoint in e.GetStylusPoints(this))
                {
                    var touchEvent = new TouchEvent()
                    {
                        Id          = e.StylusDevice.Id,
                        X           = (float)stylusPoint.X,
                        Y           = (float)stylusPoint.Y,
                        PointerType = pointerType,
                        Pressure    = stylusPoint.PressureFactor,
                        Type        = touchEventType,
                        Modifiers   = modifiers,
                    };

                    browser.GetHost().SendTouchEvent(touchEvent);
                }
                e.Handled = true;
            }
        }
        public static string GetJavaScriptEventName(this TouchEventType eventType)
        {
            switch (eventType)
            {
            case TouchEventType.Start:
                return("topTouchStart");

            case TouchEventType.End:
                return("topTouchEnd");

            case TouchEventType.Move:
                return("topTouchMove");

            case TouchEventType.Cancel:
                return("topTouchCancel");

            case TouchEventType.Entered:
                return("topMouseOver");

            case TouchEventType.Exited:
                return("topMouseOut");

            case TouchEventType.PointerMove:
                return("topMouseMoveCustom");    // Using a non-clashing name until this one propagates: https://github.com/facebook/react/commit/e96dc140599363029bd05565d58bcd4a432db370

            default:
                throw new NotSupportedException("Unsupported touch event type.");
            }
        }
Beispiel #9
0
        public static string GetJavaScriptEventName(this TouchEventType eventType)
        {
            switch (eventType)
            {
            case TouchEventType.Start:
                return("topTouchStart");

            case TouchEventType.End:
                return("topTouchEnd");

            case TouchEventType.Move:
                return("topTouchMove");

            case TouchEventType.Cancel:
                return("topTouchCancel");

            case TouchEventType.Entered:
                return("topMouseOver");

            case TouchEventType.Exited:
                return("topMouseOut");

            default:
                throw new NotSupportedException("Unsupported touch event type.");
            }
        }
 public TouchEventData(TimeSpan time, int frame, InputFlags flags, TouchEventType eventType, GestureSample gesture)
 {
     Time      = time;
     Frame     = frame;
     Flags     = flags;
     EventType = eventType;
     payload   = new GestureOrTouchLocation(gesture);
 }
 public PointerEnterExitEvent(TouchEventType touchEventType, int viewTag, ReactPointer pointer, bool sendDirect, bool sendBubbled)
     : base(viewTag)
 {
     _touchEventType = touchEventType;
     _pointer        = pointer;
     _sendDirect     = sendDirect;
     _sendBubbled    = sendBubbled;
 }
Beispiel #12
0
 public TouchEvent(TouchEventType touchEventType, JArray touches, JArray changedIndices, uint coalescingKey)
     : base(-1)
 {
     _touchEventType = touchEventType;
     _touches = touches;
     _changedIndices = changedIndices;
     _coalescingKey = coalescingKey;
 }
Beispiel #13
0
 public TouchEvent(TouchEventType touchEventType, JArray touches, JArray changedIndices, uint coalescingKey)
     : base(-1, TimeSpan.FromTicks(Environment.TickCount))
 {
     _touchEventType = touchEventType;
     _touches        = touches;
     _changedIndices = changedIndices;
     _coalescingKey  = coalescingKey;
 }
Beispiel #14
0
        virtual public Gesture UpdateGestureFromTouches(NSSet touches, TouchEventType touchType)
        {
            if (touches.Count() == 0)
            {
                // No touches, do nothing
                return(null);
            }

            // Update the set of current touches
            switch (touchType)
            {
            case TouchEventType.TouchBegan:
            case TouchEventType.TouchMoved:
                var touchesUnion = currentTouches.Union(touches);
                var touchesArray = new UITouch[touchesUnion.Count()];
                int i            = 0;
                foreach (UITouch touch in touchesUnion)
                {
                    touchesArray[i] = touch;
                    i++;
                }
                currentTouches = new NSSet(touchesArray);
                break;

            case TouchEventType.TouchCanceled:
            case TouchEventType.TouchEnded:
                var notInTouches = NSPredicate.FromExpression(new NSPredicateEvaluator((evaluatedObject, bindings) => !touches.Contains(evaluatedObject)));
                currentTouches = currentTouches.FilterUsingPredicate(notInTouches);
                break;
            }


            var expectedTouchCount = (this is SingleFingerGesture) ? 1 : 2;

            if (currentTouches.Count() == expectedTouchCount)
            {
                this.UpdateGesture(null);
                return(this);
            }
            else
            {
                this.FinishGesture();
                this.refreshTimer?.Dispose();
                // Erase reference to timer in case callback fires one last time
                this.refreshTimer = null;

                // Switch to two-finger gesture if was single-finger. If was two-finger, return null
                return((this is SingleFingerGesture)
                                        ? Gesture.StartGestureFromTouches(currentTouches, this.SceneView, LastUsedObject, manager)
                                         : null);
            }
        }
Beispiel #15
0
        public override void AnimateTouch(TouchEventType touch)
        {
            Console.WriteLine(touch);
            switch (_textFormat)
            {
            case TextFormat.Format.Text:
                if (_selectedColor != null)
                {
                    switch (touch)
                    {
                    case TouchEventType.Begin:
                        _view.TextColor = _selectedColor;
                        break;

                    case TouchEventType.Cancel:
                    case TouchEventType.End:
                        UIView.BeginAnimations(null);
                        UIView.SetAnimationDuration(0.1);
                        _view.TextColor = _textColor;
                        UIView.CommitAnimations();
                        break;
                    }
                }
                break;

            case TextFormat.Format.Html:
                if (_selectedHtmlSpan != null)
                {
                    switch (touch)
                    {
                    case TouchEventType.Begin:
                        SetSpannedText(_selectedHtmlSpan);
                        break;

                    case TouchEventType.Cancel:
                    case TouchEventType.End:
                        UIView.BeginAnimations(null);
                        UIView.SetAnimationDuration(0.1);
                        SetSpannedText(_textHtmlSpan);
                        UIView.CommitAnimations();
                        break;
                    }
                }
                break;

            default:
                throw new NotImplementedException("Text format not found: " + _textFormat);
            }
        }
        private void OnPointerEnteredExited(TouchEventType eventType, UIElement view, PointerPoint rootPoint, PointerRoutedEventArgs e, bool sendDirect, bool sendBubbled)
        {
            var pointer = CreateReactPointer(view, rootPoint, e, false);

            view.GetReactContext()?
            .GetNativeModule <UIManagerModule>()
            .EventDispatcher
            .DispatchEvent(
                new PointerEnterExitEvent(eventType, view.GetTag(), pointer, sendDirect, sendBubbled));
            // Keeps resetting the identifier if no other non-moving pointer is present
            if (_pointers.Count == 0)
            {
                _pointerIDs = 0;
            }
        }
Beispiel #17
0
		public override void AnimateTouch (TouchEventType touch)
		{
			if (_selectedImage != null) {
				switch (touch) {
				case TouchEventType.Begin:
					_view.Image = _selectedImage;
					break;
				case TouchEventType.Cancel:
				case TouchEventType.End:
					UIView.BeginAnimations (null);
					UIView.SetAnimationDuration (0.1);
					_view.Image = _backgroungImageCache;
					UIView.CommitAnimations ();
					break;
				}
			}
		}
Beispiel #18
0
        private void OnTouchConcluded(TouchEventType touchEventType, TouchEventArgs e)
        {
            if (_pointers != null && _pointers.Count > 0)
            {
                var pointer = _pointers[0];
                UpdatePointerForEvent(pointer, e);
                DispatchTouchEvent(touchEventType, _pointers, 0);

                _pointers.RemoveAt(0);

                if (_pointers.Count == 0)
                {
                    _pointerIDs = 0;
                }

                _view.ReleaseAllTouchCaptures();
            }
        }
Beispiel #19
0
        private void OnPointerConcluded(TouchEventType touchEventType, MouseButtonEventArgs e)
        {
            var pointerIndex = IndexOfPointerWithId((uint)e.Device.GetHashCode());
            if (_pointers != null && pointerIndex >= 0)
            {
                var pointer = _pointers[pointerIndex];
                UpdatePointerForEvent(pointer, e);
                DispatchTouchEvent(touchEventType, _pointers, pointerIndex);

                _pointers.RemoveAt(pointerIndex);

                if (_pointers.Count == 0)
                {
                    _pointerIDs = 0;
                }

                _view.ReleaseMouseCapture();
            }
        }
Beispiel #20
0
        private void DispatchTouchEvent(TouchEventType touchEventType, List<ReactPointer> activePointers, int pointerIndex)
        {
            var touches = new JArray();
            foreach (var pointer in activePointers)
            {
                touches.Add(JObject.FromObject(pointer));
            }

            var changedIndices = new JArray();
            changedIndices.Add(JToken.FromObject(pointerIndex));

            var coalescingKey = activePointers[pointerIndex].PointerId;

            var touchEvent = new TouchEvent(touchEventType, touches, changedIndices, coalescingKey);

            _view.GetReactContext()
                .GetNativeModule<UIManagerModule>()
                .EventDispatcher
                .DispatchEvent(touchEvent);
        }
        private void OnPointerConcluded(TouchEventType touchEventType, PointerRoutedEventArgs e)
        {
            var pointerIndex = IndexOfPointerWithId(e.Pointer.PointerId);

            if (pointerIndex != -1)
            {
                var pointer = _pointers[pointerIndex];
                UpdatePointerForEvent(pointer, e);
                DispatchTouchEvent(touchEventType, _pointers, pointerIndex);

                _pointers.RemoveAt(pointerIndex);

                if (_pointers.Count == 0)
                {
                    _pointerIDs = 0;
                }

                _view.ReleasePointerCapture(e.Pointer);
            }
        }
Beispiel #22
0
        private void OnPointerConcluded(TouchEventType touchEventType, MouseButtonEventArgs e)
        {
            var pointerIndex = 1;

            if (pointerIndex != -1)
            {
                var pointer = _pointers[pointerIndex];
                UpdatePointerForEvent(pointer, e);
                DispatchTouchEvent(touchEventType, _pointers, pointerIndex);

                _pointers.RemoveAt(pointerIndex);

                if (_pointers.Count == 0)
                {
                    _pointerIDs = 0;
                }

                _view.ReleaseMouseCapture();
            }
        }
Beispiel #23
0
        public override void AnimateTouch(TouchEventType touch)
        {
            switch (touch)
            {
            case TouchEventType.Begin:

                if (_selectedImage != null)
                {
                    DrawBackgroundImage(_selectedImage);
                }
                else if (_selectedColor != null)
                {
                    _view.BackgroundColor = _selectedColor;
                }

                break;

            case TouchEventType.Cancel:
            case TouchEventType.End:

                if (_selectedImage != null)
                {
                    DrawBackgroundImage(_backgroundImage);
                }
                else if (_selectedColor != null)
                {
                    UIView.BeginAnimations(null);
                    UIView.SetAnimationDuration(0.1);
                    _view.BackgroundColor = _backgroundColor;
                    UIView.CommitAnimations();
                }
                break;
            }

            foreach (Control control in ContainerBehaviour.Childrens)
            {
                control.AnimateTouch(touch);
            }
        }
        private void MoveIfNecessary(NSSet touches, UIEvent evt, TouchEventType evtType)
        {
            if (VirtualObjects.Count() == 0)
            {
                return;
            }
            currentGesture = currentGesture?.UpdateGestureFromTouches(touches, evtType);
            var newObj = currentGesture?.LastUsedObject;

            if (newObj != null)
            {
                lastUsedObject = newObj;
            }

            var gesture    = currentGesture;
            var touchedObj = gesture?.LastUsedObject;

            if (gesture != null && touchedObj != null)
            {
                Delegate?.TransformDidChangeFor(this, touchedObj);
            }
        }
Beispiel #25
0
        private TouchEvent ConvertFromPointerRoutedEventArgs(PointerRoutedEventArgs args, TouchEventType eventType)
        {
            var fingerEvent = new TouchEvent
            {
                Type     = eventType,
                Id       = args.Pointer.PointerId,
                Position = args.GetCurrentPoint(this.referenceVisual).Position.ToVector2()
            };

            return(fingerEvent);
        }
Beispiel #26
0
 public PointerEnterExitEvent(TouchEventType touchEventType, int viewTag)
     : base(viewTag)
 {
     _touchEventType = touchEventType;
 }
Beispiel #27
0
 public void Remove(HtmlElement target, TouchEventType touchEventType, TouchEventCallback listener, bool useCapture = false) { }
Beispiel #28
0
 public void Add(Document target, TouchEventType touchEventType, TouchEventCallback listener, bool useCapture = false) { }
Beispiel #29
0
 public TouchEvent(CustomTouch argTouch, TouchEventType argType)
 {
     touch = argTouch;
     type  = argType;
 }
Beispiel #30
0
        public override void AnimateTouch(TouchEventType touch)
        {
            switch (_textFormat)
            {
            case TextFormatValues.Text:
                if (_selectedColor != null)
                {
                    switch (touch)
                    {
                    case TouchEventType.Begin:
                        BackgroundAnimationDown();
                        _view.TextColor = _selectedColor;
                        break;

                    case TouchEventType.Cancel:
                    case TouchEventType.End:
                        BackgroundAnimationUp();

                        UIView.BeginAnimations(null);
                        UIView.SetAnimationDuration(0.1);

                        _view.TextColor = _textColor;

                        UIView.CommitAnimations();
                        break;
                    }
                }
                break;

            case TextFormatValues.Html:
            {
                switch (touch)
                {
                case TouchEventType.Begin:
                    BackgroundAnimationDown();

                    if (_selectedHtmlSpan != null)
                    {
                        ThreadPool.QueueUserWorkItem(state =>
                            {
                                CurrentContext.InvokeOnMainThread(
                                    () => SetSpannedText(_selectedHtmlSpan, false));
                                Thread.Sleep(500);
                                CurrentContext.InvokeOnMainThread(() => SetSpannedText(_textHtmlSpan));
                            });
                    }

                    break;

                case TouchEventType.Cancel:
                case TouchEventType.End:
                    BackgroundAnimationUp();

                    UIView.BeginAnimations(null);
                    UIView.SetAnimationDuration(0.1);

                    if (_selectedHtmlSpan != null)
                    {
                        SetSpannedText(_textHtmlSpan);
                    }

                    UIView.CommitAnimations();
                    break;
                }
            }
            break;

            default:
                throw new NotImplementedException("Text format not found: " + _textFormat);
            }
        }
Beispiel #31
0
 public virtual void AnimateTouch(TouchEventType touch)
 {
 }
 public PointerEnterExitEvent(TouchEventType touchEventType, int viewTag)
     : base(viewTag, TimeSpan.FromTicks(Environment.TickCount))
 {
     _touchEventType = touchEventType;
 }
 /// <summary>
 /// Parameterized class constructor that creates a TouchTargetEvent.
 /// </summary>
 /// <param name="eventType">Event types include touch Added, Changed, Removed, 
 /// Enter and Leave.</param>
 /// <param name="touch">The subject touch of this TouchTargetEvent</param>
 internal TouchTargetEvent(TouchEventType eventType, TouchPoint touch)
 {
     this.EventType = eventType;
     this.touch = touch;
 }
Beispiel #34
0
 public void Remove(Window target, TouchEventType touchEventType, TouchEventCallback listener, bool useCapture = false) { }