internal static FrameworkElement GetTypeEditor(PropertyItem propertyItem
                                                       , EditorDefinitionCollection editorDefinitions
                                                       )
        {
            FrameworkElement editor = null;

            //first check for an attribute editor
            if (editor == null)
            {
                editor = PropertyGridUtilities.GetAttibuteEditor(propertyItem);
            }

            //now look for a custom editor based on editor definitions
            if (editor == null)
            {
                editor = PropertyGridUtilities.GetCustomEditor(propertyItem, editorDefinitions);
            }

            //guess we have to use the default editor
            if (editor == null)
            {
                editor = PropertyGridUtilities.CreateDefaultEditor(propertyItem);
            }

            return(editor);
        }
        internal FrameworkElement GenerateChildrenEditorElement(PropertyItem propertyItem)
        {
            FrameworkElement editorElement      = null;
            DescriptorPropertyDefinitionBase pd = propertyItem.DescriptorDefinition;
            object      definitionKey           = null;
            Type        definitionKeyAsType     = definitionKey as Type;
            ITypeEditor editor = null;

            if (editor == null)
            {
                editor = pd.CreateAttributeEditor();
            }

            if (editor != null)
            {
                editorElement = editor.ResolveEditor(propertyItem);
            }


            if (editorElement == null && definitionKey == null)
            {
                editorElement = this.GenerateCustomEditingElement(propertyItem.PropertyDescriptor.Name, propertyItem);
            }

            if (editorElement == null && definitionKeyAsType == null)
            {
                editorElement = this.GenerateCustomEditingElement(propertyItem.PropertyType, propertyItem);
            }

            foreach (var edef in this.PropertyContainer.EditorDefinitions.Where(x => x.HasAttribute != null))
            {
                if (propertyItem.PropertyDescriptor.Attributes.Cast <Attribute>().Any(x => x.GetType() == edef.HasAttribute))
                {
                    return(edef.GenerateEditingElementInternal(propertyItem));
                }
            }

            if (editorElement == null)
            {
                if (pd.IsReadOnly)
                {
                    editor = new TextBlockEditor();
                }

                // Fallback: Use a default type editor.
                if (editor == null)
                {
                    editor = (definitionKeyAsType != null)
          ? PropertyGridUtilities.CreateDefaultEditor(definitionKeyAsType, null)
          : pd.CreateDefaultEditor();
                }

                Debug.Assert(editor != null);

                editorElement = editor.ResolveEditor(propertyItem);
            }

            return(editorElement);
        }
        internal FrameworkElement GenerateChildrenEditorElement(PropertyItem propertyItem)
        {
            FrameworkElement editorElement      = null;
            DescriptorPropertyDefinitionBase pd = propertyItem.DescriptorDefinition;
            object      definitionKey           = null;
            Type        definitionKeyAsType     = definitionKey as Type;
            ITypeEditor editor = null;

            if (editor == null)
            {
                editor = pd.CreateAttributeEditor();
            }

            if (editor != null)
            {
                editorElement = editor.ResolveEditor(propertyItem);
            }


            if ((editorElement == null) && (definitionKey == null) && (propertyItem.PropertyDescriptor != null))
            {
                editorElement = this.GenerateCustomEditingElement(propertyItem.PropertyDescriptor.Name, propertyItem);
            }

            if (editorElement == null && definitionKeyAsType == null)
            {
                editorElement = this.GenerateCustomEditingElement(propertyItem.PropertyType, propertyItem);
            }

            if (editorElement == null)
            {
                if (propertyItem.IsReadOnly &&
                    !ListUtilities.IsListOfItems(propertyItem.PropertyType) &&
                    !ListUtilities.IsCollectionOfItems(propertyItem.PropertyType) &&
                    !ListUtilities.IsDictionaryOfItems(propertyItem.PropertyType))
                {
                    editor = new TextBlockEditor((propertyItem.PropertyDescriptor != null) ? propertyItem.PropertyDescriptor.Converter : null);
                }

                // Fallback: Use a default type editor.
                if (editor == null)
                {
                    editor = (definitionKeyAsType != null)
          ? PropertyGridUtilities.CreateDefaultEditor(definitionKeyAsType, null, propertyItem)
          : pd.CreateDefaultEditor(propertyItem);
                }

                Debug.Assert(editor != null);

                editorElement = editor.ResolveEditor(propertyItem);
            }

            return(editorElement);
        }
Пример #4
0
        private FrameworkElement GenerateChildrenEditorElement(PropertyItem propertyItem)
        {
            FrameworkElement editorElement      = null;
            DescriptorPropertyDefinitionBase pd = propertyItem.DescriptorDefinition;
            object      definitionKey           = null;
            Type        definitionKeyAsType     = definitionKey as Type;
            ITypeEditor editor = null;

            if (pd.IsReadOnly)
            {
                editor = new TextBlockEditor();
            }

            if (editor == null)
            {
                editor = pd.CreateAttributeEditor();
            }

            if (editor != null)
            {
                editorElement = editor.ResolveEditor(propertyItem);
            }


            if (editorElement == null && definitionKey == null)
            {
                editorElement = this.GenerateCustomEditingElement(propertyItem.PropertyDescriptor.Name, propertyItem);
            }

            if (editorElement == null && definitionKeyAsType == null)
            {
                editorElement = this.GenerateCustomEditingElement(propertyItem.PropertyType, propertyItem);
            }

            if (editorElement == null)
            {
                // Fallback: Use a default type editor.
                if (editor == null)
                {
                    editor = (definitionKeyAsType != null)
          ? PropertyGridUtilities.CreateDefaultEditor(definitionKeyAsType, null)
          : pd.CreateDefaultEditor();
                }

                Debug.Assert(editor != null);

                editorElement = editor.ResolveEditor(propertyItem);
            }

            return(editorElement);
        }
Пример #5
0
 internal override ITypeEditor CreateDefaultEditor(PropertyItem propertyItem)
 {
     return(PropertyGridUtilities.CreateDefaultEditor(PropertyDescriptor.PropertyType, PropertyDescriptor.Converter, propertyItem));
 }
 protected override ITypeEditor CreateDefaultEditor()
 {
     return(PropertyGridUtilities.CreateDefaultEditor(PropertyDescriptor.PropertyType, PropertyDescriptor.Converter));
 }