private Color GetEditorValue() { BaseColorEditorElement editorElement = this.EditorElement as BaseColorEditorElement; editorElement.Validate(); return(editorElement.Value); }
protected override void OnKeyUp(KeyEventArgs e) { BaseColorEditorElement editorElement = this.EditorElement as BaseColorEditorElement; PropertyGridItemElement visualItem = this.OwnerElement as PropertyGridItemElement; if (visualItem != null) { int selectionStart = editorElement.ColorTextBox.TextBoxItem.SelectionStart; int selectionLength = editorElement.ColorTextBox.TextBoxItem.SelectionLength; switch (e.KeyCode) { case Keys.Right: if ((RightToLeft && selectionStart == 0) || (!RightToLeft && selectionStart == editorElement.Text.Length)) { editorElement.Validate(); } break; case Keys.Left: if ((RightToLeft && selectionStart == editorElement.Text.Length) || (!RightToLeft && selectionStart == 0 && selectionLength == 0)) { editorElement.Validate(); } break; } } }
protected override void OnKeyDown(KeyEventArgs e) { BaseColorEditorElement editorElement = this.EditorElement as BaseColorEditorElement; PropertyGridItemElement visualItem = this.OwnerElement as PropertyGridItemElement; if (visualItem != null) { switch (e.KeyCode) { case Keys.Enter: if (this.Validate()) { visualItem.PropertyTableElement.EndEdit(); } break; case Keys.Escape: visualItem.Data.PropertyGridTableElement.CancelEdit(); break; case Keys.Delete: if (editorElement.ColorTextBox.TextBoxItem.SelectionLength == editorElement.ColorTextBox.TextBoxItem.TextLength) { editorElement.Text = String.Empty; } break; } } }
public override bool EndEdit() { base.EndEdit(); BaseColorEditorElement editorElement = this.EditorElement as BaseColorEditorElement; editorElement.ValueChanging -= editorElement_ValueChanging; editorElement.ValueChanged -= editorElement_ValueChanged; editorElement.KeyDown -= editorElement_KeyDown; editorElement.KeyUp -= editorElement_KeyUp; editorElement.ColorTextBox.TextBoxItem.HostedControl.LostFocus -= new EventHandler(HostedControl_LostFocus); return(true); }
private void SetEditorValue(Object value) { BaseColorEditorElement editorElement = this.EditorElement as BaseColorEditorElement; TypeConverter colorConverter = TypeDescriptor.GetConverter(typeof(Color)); if (!colorConverter.IsValid(value)) { editorElement.Value = Color.Empty; } else { editorElement.Value = (Color)colorConverter.ConvertFromString(value.ToString()); } }
public override void BeginEdit() { base.BeginEdit(); BaseColorEditorElement editorElement = this.EditorElement as BaseColorEditorElement; editorElement.ValueChanging += new ValueChangingEventHandler(editorElement_ValueChanging); editorElement.ValueChanged += new EventHandler(editorElement_ValueChanged); editorElement.KeyDown += new KeyEventHandler(editorElement_KeyDown); editorElement.KeyUp += new KeyEventHandler(editorElement_KeyUp); editorElement.ColorTextBox.TextBoxItem.SelectAll(); editorElement.ColorTextBox.TextBoxItem.TextBoxControl.Focus(); editorElement.RightToLeft = this.RightToLeft; editorElement.ColorTextBox.TextBoxItem.HostedControl.LostFocus += new EventHandler(HostedControl_LostFocus); }