1 namespace System.Activities.Presentation.PropertyEditing {
3 using System.Collections.Generic;
4 using System.ComponentModel;
5 using System.Globalization;
8 using System.Windows.Media;
9 using System.Activities.Presentation.Internal.Properties;
10 using System.Activities.Presentation;
13 /// Derive this class to provide a custom CategoryEditor for a set of Properties in a property
16 public abstract class CategoryEditor {
19 /// This method is called once for each property in the category to determine which properties
20 /// are edited by this CategoryEditor. When a property is consumed by a CategoryEditor, it does
21 /// not show up as a separate row in that category.
23 /// <param name="propertyEntry">The PropertyEntry to check to see if its edited by this CategoryEditor</param>
24 /// <returns>true if this editor edits that property, otherwise false</returns>
25 public abstract bool ConsumesProperty(PropertyEntry propertyEntry);
28 /// Returns a localized string that indicates which category this editor belongs to. CategoryEditors are
29 /// defined on types and, thus, at load time they need to indicate the actual category they belong to.
31 public abstract string TargetCategory { get; }
34 /// Returns a DataTemplate that is hosted by the PropertyInspector as the UI for a CategoryEditor.
35 /// The DataSource of this DataTemplate is set to a CategoryEntry.
37 public abstract DataTemplate EditorTemplate { get; }
40 /// Returns an object that the host can place into a ContentControl in order to display it.
41 /// This icon may be used to adorn the editor for this category in
42 /// a collapsed mode, should it support one.
44 /// <param name="desiredSize">The desired size of the image to return. This method should make
45 /// the best attempt in matching the requested size, but it doesn't guarantee it.</param>
46 public abstract object GetImage(Size desiredSize);
49 /// Utility method that creates a new EditorAttribute for the specified
52 /// <param name="editor">CategoryEditor instance for which to create
53 /// the new EditorAttribute</param>
54 /// <returns>New EditorAttribute for the specified CategoryEditor</returns>
55 public static EditorAttribute CreateEditorAttribute(CategoryEditor editor) {
57 throw FxTrace.Exception.ArgumentNull("editor");
59 return CreateEditorAttribute(editor.GetType());
63 /// Utility method that creates a new EditorAttribute for the specified
64 /// CategoryEditor type
66 /// <param name="categoryEditorType">CategoryEditor type for which to create
67 /// the new EditorAttribute</param>
68 /// <returns>New EditorAttribute for the specified CategoryEditor type</returns>
69 public static EditorAttribute CreateEditorAttribute(Type categoryEditorType) {
70 if (categoryEditorType == null)
71 throw FxTrace.Exception.ArgumentNull("categoryEditorType");
73 if (!typeof(CategoryEditor).IsAssignableFrom(categoryEditorType))
74 throw FxTrace.Exception.AsError(new ArgumentException(
76 CultureInfo.CurrentCulture,
77 Resources.Error_ArgIncorrectType,
79 typeof(CategoryEditor).Name)));
81 return new EditorAttribute(categoryEditorType, categoryEditorType);