void InputEvents_MouseLeftChanged(MouseData md) { if (Visible && Enabled) { //check mouse bool mouseOver = (md.X >= PositionAndSize.Left) && (md.X <= PositionAndSize.Right) && (md.Y >= PositionAndSize.Top) && (md.Y <= PositionAndSize.Bottom); bool mlbtnClicked = (md.Left != md.old_Left) && !md.Left; UIKeyPickerState oldState = State; switch(State) { case UIKeyPickerState.Normal: State = (mouseOver ? UIKeyPickerState.Hilite : UIKeyPickerState.Normal); break; case UIKeyPickerState.Hilite: State = (mouseOver ? (mlbtnClicked ? UIKeyPickerState.SelectingHilite : UIKeyPickerState.Hilite) : UIKeyPickerState.Normal); break; case UIKeyPickerState.Selecting: State = (mouseOver ? UIKeyPickerState.SelectingHilite : (mlbtnClicked ? UIKeyPickerState.Normal : UIKeyPickerState.Selecting)); break; case UIKeyPickerState.SelectingHilite: State = (mouseOver ? (mlbtnClicked ? UIKeyPickerState.Hilite : UIKeyPickerState.SelectingHilite) : UIKeyPickerState.Selecting); break; } if (((oldState == UIKeyPickerState.Selecting) || (oldState == UIKeyPickerState.SelectingHilite)) && ((State == UIKeyPickerState.Normal) || (State == UIKeyPickerState.Hilite))) { //key picking cancelled - refresh current key SelectedKey = SelectedKey; } if (((State == UIKeyPickerState.Selecting) || (State == UIKeyPickerState.SelectingHilite)) && ((oldState == UIKeyPickerState.Normal) || (oldState == UIKeyPickerState.Hilite))) { //key picking started - set request text base.Text = "Press a key"; } } }
void InputEvents_MouseMoved(MouseData md) { if (Visible && Enabled) { //check mouse bool mouseOver = (md.X >= PositionAndSize.Left) && (md.X <= PositionAndSize.Right) && (md.Y >= PositionAndSize.Top) && (md.Y <= PositionAndSize.Bottom); State = (mouseOver ? (((State == UIKeyPickerState.Selecting) || (State == UIKeyPickerState.SelectingHilite)) ? UIKeyPickerState.SelectingHilite : UIKeyPickerState.Hilite) : (((State == UIKeyPickerState.Selecting) || (State == UIKeyPickerState.SelectingHilite)) ? UIKeyPickerState.Selecting : UIKeyPickerState.Normal)); } }
void InputEvents_KeyPressed(Keys key, bool state, int modifiers) { if (Visible && Enabled && ((State == UIKeyPickerState.Selecting) || (State == UIKeyPickerState.SelectingHilite)) && state) { if (State == UIKeyPickerState.Selecting) State = UIKeyPickerState.Normal; else if (State == UIKeyPickerState.SelectingHilite) State = UIKeyPickerState.SelectingHilite; //filter out illegal keys as Keys.None switch(key) { case Keys.None: case Keys.Apps: case Keys.Attn: case Keys.BrowserBack: case Keys.BrowserFavorites: case Keys.BrowserForward: case Keys.BrowserHome: case Keys.BrowserRefresh: case Keys.BrowserSearch: case Keys.BrowserStop: case Keys.CapsLock: case Keys.NumLock: case Keys.Scroll: case Keys.ChatPadGreen: case Keys.ChatPadOrange: case Keys.Crsel: case Keys.Insert: case Keys.Delete: case Keys.Home: case Keys.End: case Keys.PageUp: case Keys.PageDown: case Keys.EraseEof: case Keys.Escape: case Keys.Execute: case Keys.Exsel: case Keys.ProcessKey: case Keys.F1: case Keys.F2: case Keys.F3: case Keys.F4: case Keys.F5: case Keys.F6: case Keys.F7: case Keys.F8: case Keys.F9: case Keys.F10: case Keys.F11: case Keys.F12: case Keys.F13: case Keys.F14: case Keys.F15: case Keys.F16: case Keys.F17: case Keys.F18: case Keys.F19: case Keys.F20: case Keys.F21: case Keys.F22: case Keys.F23: case Keys.F24: case Keys.Help: case Keys.ImeConvert: case Keys.ImeNoConvert: case Keys.Kana: case Keys.Kanji: case Keys.LaunchApplication1: case Keys.LaunchApplication2: case Keys.LaunchMail: case Keys.LeftAlt: case Keys.LeftControl: case Keys.LeftShift: case Keys.LeftWindows: case Keys.RightWindows: case Keys.MediaNextTrack: case Keys.MediaPlayPause: case Keys.MediaPreviousTrack: case Keys.MediaStop: case Keys.Select: case Keys.SelectMedia: case Keys.Oem8: case Keys.OemAuto: case Keys.OemClear: case Keys.OemCopy: case Keys.OemEnlW: case Keys.Pa1: case Keys.Pause: case Keys.Play: case Keys.Print: case Keys.PrintScreen: case Keys.RightAlt: case Keys.RightControl: case Keys.RightShift: case Keys.Separator: case Keys.Sleep: case Keys.VolumeDown: case Keys.VolumeMute: case Keys.VolumeUp: case Keys.Zoom: key = Keys.None; break; } SelectedKey = key; } }