Beispiel #1
0
        public Panelhandler(Lib.UserInputManager manager, UserInputKey key, KeyPointAction onOpen, KeyPointAction onClose,
                            bool blockEnv = true)
        {
            var openhandler      = new KeyHandler(Layer.Ui, BlockType.None);
            var closehandler     = new KeyHandler(Layer.Ui, BlockType.All);
            var openBlockhandler = blockEnv ? new PointerKeyHandler(Layer.Ui, BlockType.All) : null;

            openhandler.BindKeyAction(key, (data) =>
            {
                manager.RegisterKeyhandler(closehandler);
                manager.RegisterPointerhandler(openBlockhandler);
                manager.UnregisterKeyhandler(openhandler);
            });

            if (null != onOpen)
            {
                openhandler.BindKeyAction(key, onOpen);
            }

            closehandler.BindKeyAction(key, (data) =>
            {
                manager.RegisterKeyhandler(openhandler);
                manager.UnregisterKeyhandler(closehandler);
                manager.UnregisterPointerhandler(openBlockhandler);
            });
            if (null != onClose)
            {
                closehandler.BindKeyAction(key, onClose);
            }

            manager.RegisterKeyhandler(openhandler);
        }
        public int BlockPointer(Layer layer)
        {
            int id = 0;

            if (_avaliablePointers.Count > 0)
            {
                var item = _avaliablePointers.Dequeue();
                _manager.RegisterPointerhandler(item.KeyHandler);
                id = item.Id;
            }
            else
            {
                var item = new PointerhandlerItem
                {
                    Id         = NextPointerId,
                    KeyHandler = new PointerKeyHandler(layer, BlockType.All),
                };
                _manager.RegisterPointerhandler(item.KeyHandler);
                _pointerDic[item.Id] = item;
                id = item.Id;
            };
            return(id);
        }