Ejemplo n.º 1
0
        private void InputManager_PointerEntered(object sender, IPointer e)
        {
            SketchPointer sketchPointer = new SketchPointer(this, e);

            lock (_SketchPointersReadyToEnterLock)
            {
                _SketchPointersReadyToEnter.Add(sketchPointer);
            }
            PointerInfoCache cache = new PointerInfoCache(sketchPointer, -1, PointerInfoCacheEvent.Entered);

            lock (_PointerInfoCachesLock)
            {
                _PointerInfoCaches.Enqueue(cache);
            }
            SketchEngine.RegisterForNextUpdate(this);
        }
Ejemplo n.º 2
0
        private void InputManager_PointerExited(object sender, IPointer e)
        {
            SketchPointer sketchPointer = null;

            lock (_SketchPointersListLock)
            {
                sketchPointer = SketchPointersList.Find((obj) =>
                {
                    if (obj.Pointer == e)
                    {
                        return(true);
                    }
                    return(false);
                });
            }
            if (sketchPointer == null)
            {
                lock (_SketchPointersReadyToEnterLock)
                {
                    sketchPointer = _SketchPointersReadyToEnter.Find((obj) =>
                    {
                        if (obj.Pointer == e)
                        {
                            return(true);
                        }
                        return(false);
                    });
                }
            }
            if (sketchPointer != null)
            {
                lock (_SketchPointersReadyToExitLock)
                {
                    _SketchPointersReadyToExit.Add(sketchPointer);
                }
                var cache = new PointerInfoCache(sketchPointer, sketchPointer.LatestPointerInfoCache.HitLayer, PointerInfoCacheEvent.Exited);
                lock (_PointerInfoCachesLock)
                {
                    _PointerInfoCaches.Enqueue(cache);
                }
            }
            SketchEngine.RegisterForNextUpdate(this);
        }
Ejemplo n.º 3
0
        private void InputManager_PointerPressed(object sender, IPointer e)
        {
            SketchPointer sketchPointer = null;

            lock (_SketchPointersListLock)
            {
                sketchPointer = SketchPointersList.Find((obj) =>
                {
                    if (obj.Pointer == e)
                    {
                        return(true);
                    }
                    return(false);
                });
            }
            if (sketchPointer == null)
            {
                lock (_SketchPointersReadyToEnterLock)
                {
                    sketchPointer = _SketchPointersReadyToEnter.Find((obj) =>
                    {
                        if (obj.Pointer == e)
                        {
                            return(true);
                        }
                        return(false);
                    });
                }
            }

            if (sketchPointer != null)
            {
                var cache = new PointerInfoCache(sketchPointer, 0, PointerInfoCacheEvent.Pressed);
                //throw new NotImplementedException("Do Remember implement Hit test and get layer");


                lock (_PointerInfoCachesLock)
                {
                    _PointerInfoCaches.Enqueue(cache);
                }
            }
            SketchEngine.RegisterForNextUpdate(this);
        }
Ejemplo n.º 4
0
        protected override void Update()
        {
            base.Update();
            lock (_SketchPointersReadyToEnterLock)
            {
                SketchPointersList.AddRange(_SketchPointersReadyToEnter);
                _SketchPointersReadyToEnter.Clear();
            }
            Queue <PointerInfoCache> cacheQueue;

            lock (_PointerInfoCachesLock)
            {
                cacheQueue = new Queue <PointerInfoCache>(_PointerInfoCaches);
                _PointerInfoCaches.Clear();
            }
            while (cacheQueue.Count != 0)
            {
                PointerInfoCache cache = cacheQueue.Dequeue();
                if (cache.CacheEvent == PointerInfoCacheEvent.Moved)
                {
                    cache.HitLayer = cache.SketchPointer.LatestPointerInfoCache.HitLayer;
                }
                cache.SketchPointer.LatestPointerInfoCache = cache;
                if (cache.CacheEvent == PointerInfoCacheEvent.Pressed)
                {
                    foreach (var sketchObject in SketchEngine.SketchObjectList)
                    {
                        if (sketchObject is IInputComponent)
                        {
                            if ((sketchObject as IInputComponent).StartRegion.IsOverlapPoint(cache.SketchPointer.Point))
                            {
                                cache.HitLayer = (sketchObject as IInputComponent).Level;
                                break;
                            }
                        }
                    }
                    cache.SketchPointer.LatestPointerInfoCache = cache;
                }
                switch (cache.CacheEvent)
                {
                case PointerInfoCacheEvent.Entered:
                    PointerEntered?.Invoke(this, cache.SketchPointer);
                    break;

                case PointerInfoCacheEvent.Pressed:
                    PointerPressed?.Invoke(this, cache.SketchPointer);
                    break;

                case PointerInfoCacheEvent.Moved:
                    PointerMoved?.Invoke(this, cache.SketchPointer);
                    break;

                case PointerInfoCacheEvent.Released:
                    PointerReleased?.Invoke(this, cache.SketchPointer);
                    break;

                case PointerInfoCacheEvent.Exited:
                    PointerExited?.Invoke(this, cache.SketchPointer);
                    break;
                }
            }

            lock (_SketchPointersReadyToExitLock)
            {
                foreach (var readyToExtiPointer in _SketchPointersReadyToExit)
                {
                    SketchPointersList.Remove(readyToExtiPointer);
                }
                _SketchPointersReadyToExit.Clear();
            }
        }