Exemple #1
0
        /// <summary>
        /// Utility method that creates a new EditorAttribute for the specified
        /// CategoryEditor
        /// </summary>
        /// <param name="editor">CategoryEditor instance for which to create
        /// the new EditorAttribute</param>
        /// <returns>New EditorAttribute for the specified CategoryEditor</returns>
        public static EditorAttribute CreateEditorAttribute(CategoryEditor editor)
        {
            if (editor == null)
            {
                throw FxTrace.Exception.ArgumentNull("editor");
            }

            return(CreateEditorAttribute(editor.GetType()));
        }
        /// <summary>
        /// Utility method that creates a new EditorAttribute for the specified
        /// CategoryEditor
        /// </summary>
        /// <param name="editor">CategoryEditor instance for which to create
        /// the new EditorAttribute</param>
        /// <returns>New EditorAttribute for the specified CategoryEditor</returns>
        public static EditorAttribute CreateEditorAttribute(CategoryEditor editor) {
            if (editor == null)
                throw FxTrace.Exception.ArgumentNull("editor");

            return CreateEditorAttribute(editor.GetType());
        }
        // <summary>
        // Attempts to look up the corresponding UI representation of the specified CategoryEditor
        // </summary>
        // <param name="editor">Editor to look up</param>
        // <param name="pendingGeneration">Set to true if the specified editor may have a container
        // but the visual does not exist yet and should be requested later.</param>
        // <returns>UI representation of the specified CategoryEditor, if found, null otherwise.</returns>
        public UIElement ContainerFromEditor(CategoryEditor editor, out bool pendingGeneration) 
        {
            pendingGeneration = false;
            if (editor == null)
            {
                return null;
            }

            if (this.BasicCategoryEditorsContainer != null) 
            {
                UIElement categoryEditor = this.BasicCategoryEditorsContainer.ItemContainerGenerator.ContainerFromItem(editor) as UIElement;
                if (categoryEditor != null)
                {
                    return categoryEditor;
                }
            }

            if (this.AdvancedCategoryEditorsContainer != null) 
            {
                UIElement categoryEditor = this.AdvancedCategoryEditorsContainer.ItemContainerGenerator.ContainerFromItem(editor) as UIElement;
                if (categoryEditor != null)
                {
                    return categoryEditor;
                }
            }

            if (!_UIHooksInitialized)
            {
                pendingGeneration = true;
            }

            return null;
        }
 private void UpdateUnconsumedProperties(CategoryEditor newEditor, ObservableCollection<PropertyEntry> unconsumedProperties)
 {
     for (int i = unconsumedProperties.Count - 1; i >= 0; i--)
     {
         if (newEditor.ConsumesProperty(unconsumedProperties[i]))
         {
             unconsumedProperties.RemoveAt(i);
         }
     }
 }
 private bool IsAdvanced(CategoryEditor editor)
 {
     AttributeCollection attributes = null;
     try
     {
         attributes = TypeDescriptor.GetAttributes(editor);
     }
     catch (Exception)
     {
     }
     if (attributes != null)
     {
         foreach (Attribute attribute in attributes)
         {
             EditorBrowsableAttribute browsable = attribute as EditorBrowsableAttribute;
             if (browsable != null)
             {
                 return browsable.State == EditorBrowsableState.Advanced;
             }
         }
     }
     return false;
 }