public override void Initialize(object owner, object value)
        {
            base.Initialize(owner, value);

            PropertyGridItemElement element = owner as PropertyGridItemElement;
            PropertyGridItem        item    = element.Data as PropertyGridItem;

            if (item == null)
            {
                return;
            }

            if (item.PropertyType.IsEnum)
            {
                BaseDropDownListEditorElement editorElement = this.editorElement as BaseDropDownListEditorElement;
                editorElement.ListElement.BindingContext = item.PropertyGridTableElement.BindingContext;
                editorElement.DataSource    = Enum.GetValues(item.PropertyType);
                editorElement.SelectedValue = item.Value;
            }
            else if (item.PropertyType == typeof(bool))
            {
                BaseDropDownListEditorElement editorElement = this.editorElement as BaseDropDownListEditorElement;
                editorElement.ListElement.BindingContext = item.PropertyGridTableElement.BindingContext;

                RadListDataItem trueItem  = new RadListDataItem(bool.TrueString, true);
                RadListDataItem falseItem = new RadListDataItem(bool.FalseString, false);
                editorElement.Items.Add(trueItem);
                editorElement.Items.Add(falseItem);

                editorElement.SelectedValue = item.Value;
            }
        }
        protected override void OnKeyDown(KeyEventArgs e)
        {
            BaseDropDownListEditorElement editorElement = this.EditorElement as BaseDropDownListEditorElement;

            this.selectionStart = editorElement.SelectionStart;

            PropertyGridItemElement visualItem = this.OwnerElement as PropertyGridItemElement;

            if (visualItem != null)
            {
                if (e.KeyCode == Keys.Enter && e.Modifiers != Keys.Control)
                {
                    visualItem.PropertyTableElement.EndEdit();
                }
                else if (e.KeyCode == Keys.Escape)
                {
                    visualItem.PropertyTableElement.CancelEdit();
                    e.Handled = true;
                }
                else if (e.KeyCode == Keys.Left || e.KeyCode == Keys.Right)
                {
                    e.Handled = true;
                }
                else if (e.KeyCode == Keys.Down && e.Modifiers == Keys.Alt)
                {
                    ((RadDropDownListElement)this.EditorElement).ShowPopup();
                    e.Handled = true;
                }
            }
        }
Пример #3
0
        protected override SizeF ArrangeOverride(SizeF finalSize)
        {
            RectangleF clientRect = GetClientRectangle(finalSize);
            PropertyGridItemElement itemElement = this.VisualItem as PropertyGridItemElement;
            BaseInputEditor         editor      = null;

            if (itemElement != null && itemElement.Editor != null)
            {
                editor = itemElement.Editor as BaseInputEditor;
            }
            this.layoutManagerPart.Arrange(clientRect);

            foreach (RadElement element in this.Children)
            {
                if (editor != null && editor.EditorElement == element)
                {
                    float editorHeight = element.DesiredSize.Height;
                    if (element.StretchVertically)
                    {
                        editorHeight = clientRect.Height;
                    }
                    editorHeight = Math.Min(editorHeight, clientRect.Height);
                    RectangleF editorRect = new RectangleF(clientRect.X,
                                                           clientRect.Y + (clientRect.Height - editorHeight) / 2, clientRect.Width, editorHeight);
                    element.Arrange(editorRect);
                    continue;
                }
                element.Arrange(new RectangleF(clientRect.X, clientRect.Y, clientRect.Width, clientRect.Height));
            }

            return(finalSize);
        }
Пример #4
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            BaseSpinEditorElement editorElement = this.EditorElement as BaseSpinEditorElement;

            PropertyGridItemElement visualItem = this.OwnerElement as PropertyGridItemElement;

            if (visualItem != null)
            {
                switch (e.KeyCode)
                {
                case Keys.Return:
                    if (e.Modifiers != Keys.Control)
                    {
                        editorElement.Validate();
                        visualItem.PropertyTableElement.EndEdit();
                    }
                    break;

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

                case Keys.Delete:
                    if (selectionLength == editorElement.TextBoxItem.TextLength)
                    {
                        editorElement.Text = null;
                    }
                    break;
                }
            }
        }
        protected override void OnKeyDown(KeyEventArgs e)
        {
            PropertyGridItemElement visualItem = this.OwnerElement as PropertyGridItemElement;

            if (visualItem != null)
            {
                switch (e.KeyCode)
                {
                case Keys.Escape:
                    visualItem.PropertyTableElement.CancelEdit();
                    break;

                case Keys.Enter:
                    visualItem.PropertyTableElement.EndEdit();
                    break;

                case Keys.Up:
                    if (!this.Multiline || (selectionLength == 0 && isAtFirstLine))
                    {
                        visualItem.PropertyTableElement.EndEdit();
                        visualItem.PropertyTableElement.ProcessKeyDown(e);
                    }
                    break;

                case Keys.Down:
                    if (!this.Multiline || (selectionLength == 0 && isAtLastLine))
                    {
                        visualItem.PropertyTableElement.EndEdit();
                        visualItem.PropertyTableElement.ProcessKeyDown(e);
                    }
                    break;
                }
            }
        }
Пример #6
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            RadTimePickerElement editorElement = this.EditorElement as RadTimePickerElement;

            if (editorElement == null || !editorElement.IsInValidState(true))
            {
                return;
            }
            PropertyGridItemElement ownerElement = this.OwnerElement as PropertyGridItemElement;

            if (ownerElement == null)
            {
                return;
            }
            if (e.KeyCode == Keys.Return)
            {
                ownerElement.PropertyTableElement.EndEdit();
            }
            else if (e.KeyCode == Keys.Escape)
            {
                ownerElement.PropertyTableElement.CancelEdit();
            }
            else
            {
                base.OnKeyDown(e);
            }
        }
Пример #7
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            BaseBrowseEditorElement editorElement = this.EditorElement as BaseBrowseEditorElement;

            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.FilePathTextBox.TextBoxItem.SelectionLength == editorElement.FilePathTextBox.TextBoxItem.TextLength)
                    {
                        editorElement.Text = String.Empty;
                    }
                    break;
                }
            }
        }
Пример #8
0
        public virtual void Synchronize()
        {
            PropertyGridItemBase data = this.VisualItem.Data;

            this.IsExpanded = data.Expanded;
            this.IsSelected = data.Selected;
            if (data.Expandable)
            {
                this.expanderItem.Visibility = ElementVisibility.Visible;
            }
            else
            {
                this.expanderItem.Visibility = ElementVisibility.Hidden;
            }
            PropertyGridItemElement visualItem = this.VisualItem as PropertyGridItemElement;

            if (visualItem == null)
            {
                return;
            }
            bool flag = visualItem.IsInEditMode;

            if (flag && data.Level == 0 && data.GridItems.Count > 0)
            {
                flag = false;
            }
            int num = (int)this.SetValue(PropertyGridExpanderElement.IsInEditModeProperty, (object)flag);
        }
        protected override SizeF MeasureOverride(SizeF availableSize)
        {
            SizeF desiredSize = Size.Empty;
            PropertyGridItemElement  visualItem = this.VisualItem as PropertyGridItemElement;
            PropertyGridTableElement propertyGridTableElement = this.PropertyGridTableElement;

            if (propertyGridTableElement != null && visualItem != null)
            {
                PropertyGridItem dataItem = visualItem.Data as PropertyGridItem;
                if (dataItem != null)
                {
                    desiredSize.Width = propertyGridTableElement.ItemIndent * dataItem.Level;
                    if (float.IsPositiveInfinity(availableSize.Height))
                    {
                        desiredSize.Height = propertyGridTableElement.ItemHeight;
                    }
                    else
                    {
                        desiredSize.Height = availableSize.Height;
                    }
                }
            }

            return(desiredSize);
        }
Пример #10
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;
            }
        }
Пример #11
0
        protected override void OnKeyUp(KeyEventArgs e)
        {
            BaseSpinEditorElement editorElement = this.EditorElement as BaseSpinEditorElement;

            PropertyGridItemElement visualItem = this.OwnerElement as PropertyGridItemElement;

            if (visualItem != null)
            {
                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;
                }
            }
        }
Пример #12
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            BaseSpinEditorElement   editorElement = this.EditorElement as BaseSpinEditorElement;
            PropertyGridItemElement ownerElement  = this.OwnerElement as PropertyGridItemElement;

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

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

            case Keys.Delete:
                if (this.selectionLength != editorElement.TextBoxItem.TextLength)
                {
                    break;
                }
                editorElement.Text = (string)null;
                break;
            }
        }
Пример #13
0
        protected override SizeF ArrangeOverride(SizeF finalSize)
        {
            RectangleF clientRectangle              = this.GetClientRectangle(finalSize);
            PropertyGridItemElement visualItem      = this.VisualItem as PropertyGridItemElement;
            BaseInputEditor         baseInputEditor = (BaseInputEditor)null;

            if (visualItem != null && visualItem.Editor != null)
            {
                baseInputEditor = visualItem.Editor as BaseInputEditor;
            }
            this.Layout.Arrange(clientRectangle);
            foreach (RadElement child in this.Children)
            {
                if (baseInputEditor != null && baseInputEditor.EditorElement == child)
                {
                    float height1 = child.DesiredSize.Height;
                    if (child.StretchVertically)
                    {
                        height1 = clientRectangle.Height;
                    }
                    float      height2   = Math.Min(height1, clientRectangle.Height);
                    RectangleF finalRect = new RectangleF(clientRectangle.X, clientRectangle.Y + (float)(((double)clientRectangle.Height - (double)height2) / 2.0), clientRectangle.Width, height2);
                    child.Arrange(finalRect);
                }
                else
                {
                    child.Arrange(new RectangleF(clientRectangle.X, clientRectangle.Y, clientRectangle.Width, clientRectangle.Height));
                }
            }
            return(finalSize);
        }
Пример #14
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            RadDateTimePickerElement dateTimePickerElement = this.EditorElement as RadDateTimePickerElement;

            if (dateTimePickerElement == null || !dateTimePickerElement.IsInValidState(true))
            {
                return;
            }

            PropertyGridItemElement visualItem = this.OwnerElement as PropertyGridItemElement;

            if (visualItem != null)
            {
                if (e.KeyCode == Keys.Enter)
                {
                    visualItem.PropertyTableElement.EndEdit();
                }
                else if (e.KeyCode == Keys.Escape)
                {
                    visualItem.PropertyTableElement.CancelEdit();
                }
                else
                {
                    base.OnKeyDown(e);
                }
            }
        }
Пример #15
0
        public override void OnLostFocus()
        {
            PropertyGridItemElement visualItem = this.OwnerElement as PropertyGridItemElement;

            if (visualItem != null && visualItem.IsInValidState(true) && !visualItem.ElementTree.Control.Focused)
            {
                visualItem.PropertyTableElement.EndEdit();
            }
        }
Пример #16
0
        void PropertyGridBrowseEditor_DialogClosed(object sender, DialogClosedEventArgs e)
        {
            PropertyGridItemElement visualItem = this.OwnerElement as PropertyGridItemElement;

            if (visualItem != null && visualItem.IsInValidState(true))
            {
                visualItem.PropertyTableElement.EndEdit();
            }
        }
Пример #17
0
        public virtual void Synchronize()
        {
            if (this.VisualItem is PropertyGridItemElement)
            {
                PropertyGridItemElement visualItem = VisualItem as PropertyGridItemElement;

                if (visualItem != null)
                {
                    this.IsExpanded = visualItem.Data.Expanded;
                    this.IsSelected = visualItem.IsSelected;

                    PropertyGridItem dataItem = visualItem.Data as PropertyGridItem;

                    if (dataItem.Expandable)
                    {
                        this.expanderItem.Visibility = ElementVisibility.Visible;
                    }
                    else
                    {
                        this.expanderItem.Visibility = ElementVisibility.Hidden;
                    }
                }

                bool isInEditMode = visualItem.IsInEditMode;
                if (isInEditMode && visualItem.Data.Level == 0 && visualItem.Data.GridItems.Count > 0)
                {
                    isInEditMode = false;
                }

                this.SetValue(IsInEditModeProperty, isInEditMode);
            }

            if (this.VisualItem is PropertyGridGroupElement)
            {
                PropertyGridGroupElement visualItem = VisualItem as PropertyGridGroupElement;

                if (visualItem != null)
                {
                    this.IsExpanded = visualItem.Data.Expanded;
                    this.IsSelected = visualItem.IsSelected;

                    PropertyGridGroupItem dataItem = visualItem.Data as PropertyGridGroupItem;

                    if (dataItem.GridItems.Count == 0)
                    {
                        this.expanderItem.Visibility = ElementVisibility.Hidden;
                    }
                    else
                    {
                        this.expanderItem.Visibility = ElementVisibility.Visible;
                    }
                }
            }

            this.UpdateSignImage();
        }
Пример #18
0
        private void PropertyGridColorEditor_DialogClosed(object sender, DialogClosedEventArgs e)
        {
            PropertyGridItemElement ownerElement = this.OwnerElement as PropertyGridItemElement;

            if (ownerElement == null || !ownerElement.IsInValidState(true))
            {
                return;
            }
            ownerElement.PropertyTableElement.EndEdit();
        }
        protected virtual object GetValue()
        {
            PropertyGridItem        propertyGridItem = (PropertyGridItem)null;
            PropertyGridItemElement ancestor         = this.FindAncestor <PropertyGridItemElement>();

            if (ancestor != null)
            {
                propertyGridItem = ancestor.Data as PropertyGridItem;
            }
            return(this.Converter.ConvertFromString((ITypeDescriptorContext)propertyGridItem, Thread.CurrentThread.CurrentCulture, this.Text));
        }
        protected override void OnLostFocus()
        {
            base.OnLostFocus();
            PropertyGridItemElement ownerElement = this.OwnerElement as PropertyGridItemElement;

            if (ownerElement == null || !ownerElement.IsInValidState(true) || (ownerElement.ElementTree.Control.Focused || ownerElement.ElementTree.Control.ContainsFocus))
            {
                return;
            }
            ownerElement.PropertyTableElement.EndEdit();
        }
Пример #21
0
        protected override SizeF MeasureOverride(SizeF availableSize)
        {
            SizeF empty = (SizeF)Size.Empty;
            PropertyGridItemElement  visualItem       = this.VisualItem as PropertyGridItemElement;
            PropertyGridTableElement gridTableElement = this.PropertyGridTableElement;

            if (gridTableElement != null && visualItem != null && visualItem.Data is PropertyGridItem)
            {
                empty.Width  = (float)gridTableElement.ItemIndent;
                empty.Height = !float.IsPositiveInfinity(availableSize.Height) ? availableSize.Height : (float)gridTableElement.ItemHeight;
            }
            return(empty);
        }
        public override void OnValueChanging(ValueChangingEventArgs e)
        {
            PropertyGridItemElement ownerElement = this.OwnerElement as PropertyGridItemElement;

            if (ownerElement.PropertyTableElement.isChanging)
            {
                return;
            }
            ownerElement.PropertyTableElement.isChanging = true;
            base.OnValueChanging(e);
            ownerElement?.PropertyTableElement.OnValueChanging((object)this, e);
            ownerElement.PropertyTableElement.isChanging = false;
        }
Пример #23
0
        protected virtual void OnKeyPress(KeyPressEventArgs e)
        {
            if (e.KeyChar != '\r')
            {
                return;
            }
            PropertyGridItemElement ownerElement = this.OwnerElement as PropertyGridItemElement;

            if (ownerElement == null || !ownerElement.IsInValidState(true) || ownerElement.ElementTree.Control.Focused)
            {
                return;
            }
            ownerElement.PropertyTableElement.EndEdit();
        }
Пример #24
0
        public override void Initialize(object owner, object value)
        {
            PropertyGridItemElement element = owner as PropertyGridItemElement;
            Type editedType = ((PropertyGridItem)element.Data).PropertyType;

            if (editedType == typeof(decimal) || editedType == typeof(double) || editedType == typeof(float))
            {
                ((BaseSpinEditorElement)this.editorElement).DecimalPlaces = 2;
            }
            else
            {
                ((BaseSpinEditorElement)this.editorElement).DecimalPlaces = 0;
            }

            base.Initialize(owner, value);
        }
        public virtual void Synchronize()
        {
            PropertyGridItemElement visualItem = this.VisualItem as PropertyGridItemElement;

            if (visualItem == null)
            {
                return;
            }
            if ((visualItem.Data as PropertyGridItem).Level > 0)
            {
                this.Visibility = ElementVisibility.Visible;
            }
            else
            {
                this.Visibility = ElementVisibility.Hidden;
            }
        }
Пример #26
0
        public virtual void Synchronize()
        {
            PropertyGridItemElement visualItem = VisualItem as PropertyGridItemElement;

            if (visualItem != null)
            {
                PropertyGridItem dataItem = visualItem.Data as PropertyGridItem;
                bool             indented = dataItem.Level > 0;
                if (indented)
                {
                    this.Visibility = ElementVisibility.Visible;
                }
                else
                {
                    this.Visibility = ElementVisibility.Hidden;
                }
            }
        }
Пример #27
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            PropertyGridItemElement ownerElement = this.OwnerElement as PropertyGridItemElement;

            if (ownerElement == null)
            {
                return;
            }
            switch (e.KeyCode)
            {
            case Keys.Return:
                if (e.Modifiers == Keys.Control && this.Multiline)
                {
                    break;
                }
                ownerElement.PropertyTableElement.EndEdit();
                break;

            case Keys.Escape:
                ownerElement.PropertyTableElement.CancelEdit();
                break;

            case Keys.Up:
                if (this.Multiline && (this.selectionLength != 0 || !this.isAtFirstLine))
                {
                    break;
                }
                ownerElement.PropertyTableElement.EndEdit();
                ownerElement.PropertyTableElement.ProcessKeyDown(e);
                break;

            case Keys.Down:
                if (this.Multiline && (this.selectionLength != 0 || !this.isAtLastLine))
                {
                    break;
                }
                ownerElement.PropertyTableElement.EndEdit();
                ownerElement.PropertyTableElement.ProcessKeyDown(e);
                break;
            }
        }
        protected override void OnKeyDown(KeyEventArgs e)
        {
            BaseDropDownListEditorElement editorElement = this.EditorElement as BaseDropDownListEditorElement;

            this.selectionStart = editorElement.SelectionStart;
            PropertyGridItemElement ownerElement = this.OwnerElement as PropertyGridItemElement;

            if (ownerElement == null)
            {
                return;
            }
            if (e.KeyCode == Keys.Return && e.Modifiers != Keys.Control)
            {
                ownerElement.PropertyTableElement.EndEdit();
            }
            else if (e.KeyCode == Keys.Escape)
            {
                ownerElement.PropertyTableElement.CancelEdit();
                e.Handled = true;
            }
            else if (e.KeyCode == Keys.Left || e.KeyCode == Keys.Right)
            {
                if (editorElement.DropDownStyle != RadDropDownStyle.DropDownList)
                {
                    return;
                }
                e.Handled = true;
            }
            else
            {
                if (e.KeyCode != Keys.Down || e.Modifiers != Keys.Alt)
                {
                    return;
                }
                ((PopupEditorBaseElement)this.EditorElement).ShowPopup();
                e.Handled = true;
            }
        }
        protected virtual void DropEditor()
        {
            UITypeEditor editor = this.Editor;

            if (editor == null)
            {
                return;
            }
            try
            {
                PropertyGridItemElement ancestor1 = this.FindAncestor <PropertyGridItemElement>();
                if (ancestor1 == null)
                {
                    return;
                }
                PropertyGridItem data = ancestor1.Data as PropertyGridItem;
                if (data == null)
                {
                    return;
                }
                this.currentValue = !this.Validate() ? data.Value : this.Converter.ConvertFromString((ITypeDescriptorContext)data, Thread.CurrentThread.CurrentCulture, this.Text);
                object obj      = editor.EditValue((ITypeDescriptorContext)data, (IServiceProvider)this.editorService, this.currentValue);
                bool   expanded = data.Expanded;
                PropertyGridTableElement ancestor2 = this.FindAncestor <PropertyGridTableElement>();
                if (data.Expandable)
                {
                    data.Collapse();
                    ancestor1.UpdateLayout();
                }
                this.Value = obj;
                this.Text  = this.Converter.ConvertToString((ITypeDescriptorContext)data, Thread.CurrentThread.CurrentCulture, obj);
                ancestor2?.EndEdit();
                data.Expanded = expanded;
            }
            catch (Exception ex)
            {
            }
        }
        public virtual void Synchronize()
        {
            PropertyGridItem item = VisualItem.Data as PropertyGridItem;

            if (item != null)
            {
                if (item.Level == 0)
                {
                    this.Visibility = ElementVisibility.Collapsed;
                }
                else
                {
                    this.Visibility = ElementVisibility.Visible;
                }
            }
            PropertyGridItemElement visualItem = VisualItem as PropertyGridItemElement;

            if (visualItem != null)
            {
                this.SetValue(IsRootItemWithChildrenProperty, visualItem.Data.GridItems.Count > 0 && visualItem.Data.Level == 0);
                this.SetValue(IsInEditModeProperty, visualItem.GetValue(PropertyGridItemElement.IsInEditModeProperty));
            }
        }