示例#1
0
        public override bool HandleKeyUp(KeyEventArgs e)
        {
            HidButton button = FindMatchingButton(e);

            if (null != button)
            {
                button.IsSelected = false;
                e.Handled         = true;
            }

            return(e.Handled);
        }
示例#2
0
        private static HidButton FindMatchingButton(ControlCollection controls, KeyEventArgs e)
        {
            foreach (Control c in controls)
            {
                if (c is HidButton)
                {
                    HidButton button = (HidButton)c;
                    if (button.CatchKey == (Classes.HidKeys)e.KeyCode)
                    {
                        return(button);
                    }
                }
                else if (c is ContainerPanel)
                {
                    HidButton button = FindMatchingButton(((ContainerPanel)c).Controls, e);

                    if (null != button)
                    {
                        return(button);
                    }
                }
            }
            return(null);
        }
示例#3
0
        public static void ParseChildren(CustomInputControl parent, List <Classes.CustomInput.CustomInputControl> controls, ControlCollection controlContainer)
        {
            Bitmap image_down = Properties.Resources.Custom_Button_Down;
            Bitmap image_up   = Properties.Resources.Custom_Button_Up;

            foreach (Classes.CustomInput.CustomInputControl controlDesc in controls)
            {
                HidButton imageButton = null;
                Control   control     = imageButton;

                switch (controlDesc.InputType)
                {
                case Classes.CustomInputType.Container:
                {
                    control = new ContainerPanel(parent, controlDesc);
                }
                break;

                case Classes.CustomInputType.KeyCombination:
                case Classes.CustomInputType.VirtualKey:
                case Classes.CustomInputType.ScanCode:
                {
                    control = imageButton = new KeyboardHidButton(parent, controlDesc);

                    if (!string.IsNullOrEmpty(controlDesc.Image))
                    {
                        imageButton.Image = GetBitmap(controlDesc.Image);
                    }
                    else
                    {
                        imageButton.Image = BuildCustomBitmap(image_up, controlDesc.InputDisplay, parent.Font, Color.Black);
                    }
                    if (!string.IsNullOrEmpty(controlDesc.DownImage))
                    {
                        imageButton.DownImage = GetBitmap(controlDesc.DownImage);
                    }
                    else
                    {
                        imageButton.DownImage = BuildCustomBitmap(image_down, controlDesc.InputDisplay, parent.Font, Color.White);
                    }
                    imageButton.SelectedImage         = imageButton.DownImage;
                    imageButton.TransparentBackground = controlDesc.TransparentBackground;
                    imageButton.BackColor             = parent.BackColor;
                    imageButton.CanHold = false;
                }
                break;

                case Classes.CustomInputType.ShiftKey:
                case Classes.CustomInputType.AltKey:
                case Classes.CustomInputType.WinKey:
                {
                }
                break;

                case Classes.CustomInputType.LeftMouseButton:
                {
                    imageButton = new MouseButtonHidButton(parent, controlDesc);
                }
                break;

                case Classes.CustomInputType.RightMouseButton:
                {
                    imageButton = new MouseButtonHidButton(parent, controlDesc);
                }
                break;

                case Classes.CustomInputType.MouseDPad:
                {
                    // add a control here to map dpad to mouse
                }
                break;

                case Classes.CustomInputType.Accelerometer:
                {
                    // add a control here to map accelerometer to mouse
                }
                break;

                case Classes.CustomInputType.TouchPad:
                case Classes.CustomInputType.TouchPadWithScroll:
                {
                    control = new TouchControl();
                    ((TouchControl)control).HidWriter = parent.HidWriter;
                }
                break;

                default:
                {
                    // why are we here?
                }
                break;
                }
                control.Width  = controlDesc.Width;
                control.Height = controlDesc.Height;
                control.Left   = controlDesc.Left;
                control.Top    = controlDesc.Top;
                control.Tag    = controlDesc;

                if (!(control is ContainerPanel))
                {
                    control.Anchor = controlDesc.Anchor;
                    control.Dock   = controlDesc.Dock;
                }

                controlContainer.Add(control);
            }
        }