Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
 protected virtual void DoDispatch(KeyPointAction action, KeyData data)
 {
     if (action != null)
     {
         action(data);
     }
 }
Ejemplo n.º 3
0
        public KeyHandler BindKeyAction(UserInputKey key, KeyPointAction pointAction)
        {
            var            data = new KeyData(key);
            KeyPointAction actionAss;

            if (binding.TryGetValue(data, out actionAss))
            {
                actionAss += pointAction;
            }
            else
            {
                binding[data] = pointAction;
            }
            return(this);
        }
Ejemplo n.º 4
0
        public PointerKeyHandler BindPointAction(UserInputKey key, KeyPointAction action)
        {
            var            data = new PointerData(key);
            KeyPointAction pointActions;

            if (binding.TryGetValue(data, out pointActions))
            {
                pointActions += action;
            }
            else
            {
                binding[data] = action;
            }
            return(this);
        }