/// <summary> /// Sets the way the keyboard will be shown when controls receive focus. If the control is a Form, /// all controls on the Form will support this way of displaying the touch keyboard. /// </summary> /// <param name="extendee">The control for which this value is specified.</param> /// <param name="value">A TouchKeyboardStyle value defining the way the keyboard appears.</param> public void SetShowTouchKeyboard(Control extendee, TouchKeyboardStyle value) { if (extendee is Form) { if (value != TouchKeyboardStyle.No) { foreach (Control c in extendee.Controls) { AttachTo(c); } // If other controls are added to the form, attach to those controls also. extendee.ControlAdded += new ControlEventHandler(form_ControlAdded); // If controls are removed from the form, dettach from them, we don't want to keep a reference to them. extendee.ControlRemoved += new ControlEventHandler(form_ControlRemoved); } } if (!_ExtendedControls.ContainsKey(extendee)) _ExtendedControls.Add(extendee, value); else _ExtendedControls[extendee] = value; if (value == TouchKeyboardStyle.No) DetachFrom(extendee); else AttachTo(extendee); }
/// <summary> /// Initializes a new instance of the CancelKeyboardEventArgs class. /// </summary> /// <param name="targetControl"></param> /// <param name="style"></param> public CancelKeyboardEventArgs(Control targetControl, TouchKeyboardStyle style) { TargetControl = targetControl; Style = style; }
public void ShowKeyboard(Control control, TouchKeyboardStyle style) { CancelKeyboardEventArgs ce = new CancelKeyboardEventArgs(control, style); OnKeyboardOpening(ce); if (ce.Cancel) return; _CurrentTarget = ce.TargetControl; style = ce.Style; _PopupKeyboard.CurrentControl = _CurrentTarget; if (_CurrentTarget != null) { if (style == TouchKeyboardStyle.Floating) { try { _ShowingFloatingKeyboard = true; _PopupKeyboard.Owner = _CurrentTarget.FindForm(); _PopupKeyboard.Controls.Add(_VirtualKeyboard); _VirtualKeyboard.Dock = DockStyle.Fill; _VirtualKeyboard.Visible = true; _PopupKeyboard.Show(); // When floating, don't show the top bar. The information on the top bar are on the window's title bar. _VirtualKeyboard.IsTopBarVisible = false; } finally { _ShowingFloatingKeyboard = false; } } else if (style == TouchKeyboardStyle.Inline) { Form owner = _CurrentTarget.FindForm(); _VirtualKeyboard.Dock = Dock; owner.Controls.Add(_VirtualKeyboard); _VirtualKeyboard.BringToFront(); _VirtualKeyboard.Visible = true; // When inline, show the top bar. _VirtualKeyboard.IsTopBarVisible = true; } } OnKeyboardOpened(EventArgs.Empty); }