protected override void OnMouseDown(MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (e.Clicks == 2) { Graphics graphics = CreateGraphics(); if (GetButtonRect(graphics).Contains(new Point(e.X, e.Y)) == false) { ScrollValueOnDoubleClick(!(ModifierKeys == Keys.Shift), ScrollValueOnDoubleClickSource.FromInPlaceCtrl, false); } } else { if (RealtimeChange) { PropertyValue.ValueValidationResult changed = CommitChanges(false); if (PropertyValue.IsErrorCode(changed) && (_ownerPropertyEnum.Property.ParentGrid.ValueNotValidBehaviorMode == PropertyGrid.ValueNotValidBehaviorModes.KeepFocus)) { _edit.Focus(); _edit.SelectAll(); return; } } Graphics graphics = CreateGraphics(); if (GetButtonRect(graphics).Contains(new Point(e.X, e.Y))) { _pushed = true; _mouseOver = true; Capture = true; } graphics.Dispose(); _dontTransferFocus = true; Focus(); _dontTransferFocus = false; Invalidate(false); Update(); } } base.OnMouseDown(e); }
protected override void OnMouseUp(MouseEventArgs e) { if (_pushed && (e.Button == MouseButtons.Left)) { Capture = false; _pushed = false; _mouseOver = false; Invalidate(false); using (Graphics graphics = CreateGraphics()) { if (GetButtonRect(graphics).Contains(new Point(e.X, e.Y))) { // Maybe the user typed something in the editbox that has not been validated yet if (mEdit != null) { if (!PropertyValue.IsErrorCode(mEdit.CommitChanges(false))) { RunButton(); } else { mEdit.SelectAll(); mEdit.Focus(); } } else { RunButton(); } } } } base.OnMouseUp(e); }
protected override void OnMouseDown(MouseEventArgs e) { if (!ReadOnly) { if (e.X > ClientRectangle.Width - SystemInformation.VerticalScrollBarWidth) { // Maybe the user typed something in the editbox that has not been validated yet // if (_realtimeChange && (_edit != null)) // _edit.CommitChanges(); if (e.Button == MouseButtons.Left) { BeginButtonPress(e); } base.OnMouseDown(e); if (_edit != null) { _edit.Focus(); _edit.SelectAll(); } } else { if (e.Clicks == 2) { ScrollValueOnDoubleClick(!(ModifierKeys == Keys.Shift), ScrollValueOnDoubleClickSource.FromInPlaceCtrl, false); } base.OnMouseDown(e); } if (_edit == null) { Focus(); } } }
protected override bool ProcessDialogKey(Keys keyData) { Keys key = (keyData & Keys.KeyCode); if (key == Keys.Return) { _pushed = false; _mouseOver = false; PropertyValue.ValueValidationResult changed = CommitChanges(true); if (PropertyValue.IsErrorCode(changed) && (_ownerPropertyEnum.Property.ParentGrid.ValueNotValidBehaviorMode == PropertyGrid.ValueNotValidBehaviorModes.KeepFocus)) { if (_edit != null) { _edit.SelectAll(); return(true); } } } else if (key == Keys.Escape) { _pushed = false; _mouseOver = false; // Restore the old string in the edit box Text = _initialValue; _ownerPropertyEnum.Property.Value.ImageIndex = _oldImageListIndex; CommitChanges(true); } else if ((key == Keys.F4) || ((key == Keys.Down) && ((keyData & Keys.Alt) != Keys.None))) { _pushed = false; _mouseOver = false; if ((_edit != null) && _edit.Focused) { PropertyValue.ValueValidationResult changed = CommitChanges(false); if (!PropertyValue.IsErrorCode(changed) || (_ownerPropertyEnum.Property.ParentGrid.ValueNotValidBehaviorMode == PropertyGrid.ValueNotValidBehaviorModes.IgnoreAndRestore)) { OnF4(); } else { _edit.SelectAll(); } } else { OnF4(); } return(true); } else if (key == Keys.Tab) { bool forward = ((keyData & Keys.Shift) == Keys.None); bool final = (_edit == null) || (!forward && _edit.Focused); PropertyValue.ValueValidationResult changed = CommitChanges(final); if (PropertyValue.IsErrorCode(changed) && (_ownerPropertyEnum.Property.ParentGrid.ValueNotValidBehaviorMode == PropertyGrid.ValueNotValidBehaviorModes.KeepFocus)) { if (_edit != null) { _edit.SelectAll(); } return(true); } if (_edit != null) { if (forward && _edit.Focused) { if ((_ownerPropertyEnum.Property.ParentGrid.NavigationKeyMode == PropertyGrid.NavigationKeyModes.ArrowKeys) || ((_ownerPropertyEnum.Property.ParentGrid.TabKeyNavigationMode & PropertyGrid.TabKeyNavigationModes.TabKeyInSubControls) != 0)) { // CommitChanges(false); _dontTransferFocus = true; Focus(); Invalidate(false); _dontTransferFocus = false; return(true); } } else if (!forward && _edit.Focused) { if (_ownerPropertyEnum.Property.ParentGrid.NavigationKeyMode == PropertyGrid.NavigationKeyModes.ArrowKeys) { // CommitChanges(true); Parent.Focus(); return(true); } } else if (!forward && Focused) { _edit.Focus(); _edit.SelectAll(); Invalidate(false); return(true); } } } if (ContainsFocus) { return(base.ProcessDialogKey(keyData)); } else { return(true); } }
protected override bool ProcessDialogKey(Keys keyData) { Keys key = (keyData & Keys.KeyCode); if (key == Keys.Return) { if ((_trackbar != null) && _trackbar.Focused) { CommitChanges(true); } else { PropertyValue.ValueValidationResult changed = CommitChanges(true); if (PropertyValue.IsErrorCode(changed) && (_ownerPropertyEnum.Property.ParentGrid.ValueNotValidBehaviorMode == PropertyGrid.ValueNotValidBehaviorModes.KeepFocus)) { if (_edit != null) { _edit.SelectAll(); return(true); } } } } else if (key == Keys.Tab) { PropertyValue.ValueValidationResult changed = CommitChanges(_trackbar.Focused); if (PropertyValue.IsErrorCode(changed) && (_ownerPropertyEnum.Property.ParentGrid.ValueNotValidBehaviorMode == PropertyGrid.ValueNotValidBehaviorModes.KeepFocus)) { if (_edit != null) { _edit.SelectAll(); } return(true); } if (_edit != null) { bool forward = ((keyData & Keys.Shift) == Keys.None); if (forward && _edit.Focused) { if ((_parentGrid.NavigationKeyMode == PropertyGrid.NavigationKeyModes.ArrowKeys) || ((_parentGrid.TabKeyNavigationMode & PropertyGrid.TabKeyNavigationModes.TabKeyInSubControls) != 0)) { _trackbar.Focus(); return(true); } } else if (forward && _trackbar.Focused) { if (_realtimeChange == false) { CommitChanges(true); } } else if (!forward && _trackbar.Focused) { _edit.Focus(); _edit.SelectAll(); Invalidate(false); return(true); } } } else if (key == Keys.Escape) { // Restore the old value in the textbox _trackbar.Value = _initialValue; Text = _trackbar.Value.ToString(); CommitChanges(true); } if (ContainsFocus) { return(base.ProcessDialogKey(keyData)); } else { return(true); } }