Exemplo n.º 1
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            RadColorBoxElement      editorElement = this.EditorElement as RadColorBoxElement;
            PropertyGridItemElement ownerElement  = this.OwnerElement as PropertyGridItemElement;

            if (ownerElement == null)
            {
                return;
            }
            switch (e.KeyCode)
            {
            case Keys.Return:
                if (!this.Validate())
                {
                    break;
                }
                ownerElement.PropertyTableElement.EndEdit();
                break;

            case Keys.Escape:
                ownerElement.Data.PropertyGridTableElement.CancelEdit();
                break;

            case Keys.Delete:
                if (editorElement.TextBoxItem.SelectionLength != editorElement.TextBoxItem.TextLength)
                {
                    break;
                }
                editorElement.Text = string.Empty;
                break;
            }
        }
Exemplo n.º 2
0
        protected override void OnKeyUp(KeyEventArgs e)
        {
            RadColorBoxElement editorElement = this.EditorElement as RadColorBoxElement;

            if (!(this.OwnerElement is PropertyGridItemElement))
            {
                return;
            }
            int selectionStart  = editorElement.TextBoxItem.SelectionStart;
            int selectionLength = editorElement.TextBoxItem.SelectionLength;

            switch (e.KeyCode)
            {
            case Keys.Left:
                if ((!this.RightToLeft || selectionStart != editorElement.Text.Length) && (this.RightToLeft || selectionStart != 0 || selectionLength != 0))
                {
                    break;
                }
                editorElement.Validate();
                break;

            case Keys.Right:
                if ((!this.RightToLeft || selectionStart != 0) && (this.RightToLeft || selectionStart != editorElement.Text.Length))
                {
                    break;
                }
                editorElement.Validate();
                break;
            }
        }
Exemplo n.º 3
0
        private Color GetEditorValue()
        {
            RadColorBoxElement editorElement = this.EditorElement as RadColorBoxElement;

            editorElement.Validate();
            return(editorElement.Value);
        }
Exemplo n.º 4
0
        public override bool EndEdit()
        {
            base.EndEdit();
            RadColorBoxElement editorElement = this.EditorElement as RadColorBoxElement;

            editorElement.ValueChanging -= new ValueChangingEventHandler(this.editorElement_ValueChanging);
            editorElement.ValueChanged  -= new EventHandler(this.editorElement_ValueChanged);
            editorElement.KeyDown       -= new KeyEventHandler(this.editorElement_KeyDown);
            editorElement.KeyUp         -= new KeyEventHandler(this.editorElement_KeyUp);
            editorElement.TextBoxItem.HostedControl.LostFocus -= new EventHandler(this.HostedControl_LostFocus);
            return(true);
        }
Exemplo n.º 5
0
        public override void BeginEdit()
        {
            base.BeginEdit();
            RadColorBoxElement editorElement = this.EditorElement as RadColorBoxElement;

            editorElement.ValueChanging += new ValueChangingEventHandler(this.editorElement_ValueChanging);
            editorElement.ValueChanged  += new EventHandler(this.editorElement_ValueChanged);
            editorElement.KeyDown       += new KeyEventHandler(this.editorElement_KeyDown);
            editorElement.KeyUp         += new KeyEventHandler(this.editorElement_KeyUp);
            editorElement.TextBoxItem.SelectAll();
            editorElement.TextBoxItem.TextBoxControl.Focus();
            editorElement.RightToLeft = this.RightToLeft;
            editorElement.TextBoxItem.HostedControl.LostFocus += new EventHandler(this.HostedControl_LostFocus);
        }
Exemplo n.º 6
0
        private void SetEditorValue(object value)
        {
            RadColorBoxElement editorElement = this.EditorElement as RadColorBoxElement;
            TypeConverter      converter     = TypeDescriptor.GetConverter(typeof(Color));

            if (value is Color)
            {
                editorElement.Value = (Color)value;
            }
            else
            {
                object obj = converter.ConvertFromString((ITypeDescriptorContext)null, Thread.CurrentThread.CurrentCulture, value.ToString());
                if (obj == null)
                {
                    editorElement.Value = Color.Empty;
                }
                else
                {
                    editorElement.Value = (Color)obj;
                }
            }
        }
Exemplo n.º 7
0
 protected override void CreateChildItems(RadElement parent)
 {
     base.CreateChildItems(parent);
     this.colorBoxElement = this.CreateColorBoxElement();
     parent.Children.Add((RadElement)this.colorBoxElement);
 }