[amd64/tramp] hide interpreter specific trampoline behind ifdef
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / Base / Core / PropertyEditing / CategoryEditor.cs
1 namespace System.Activities.Presentation.PropertyEditing {
2     using System;
3     using System.Collections.Generic;
4     using System.ComponentModel;
5     using System.Globalization;
6     using System.Text;
7     using System.Windows;
8     using System.Windows.Media;
9     using System.Activities.Presentation.Internal.Properties;
10     using System.Activities.Presentation;
11
12     /// <summary>
13     /// Derive this class to provide a custom CategoryEditor for a set of Properties in a property
14     /// browser host.
15     /// </summary>
16     public abstract class CategoryEditor {
17
18         /// <summary>
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.
22         /// </summary>
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);
26
27         /// <summary>
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.
30         /// </summary>
31         public abstract string TargetCategory { get; }
32
33         /// <summary>
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.
36         /// </summary>
37         public abstract DataTemplate EditorTemplate { get; }
38
39         /// <summary>
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.
43         /// </summary>
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);
47
48         /// <summary>
49         /// Utility method that creates a new EditorAttribute for the specified
50         /// CategoryEditor
51         /// </summary>
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) {
56             if (editor == null)
57                 throw FxTrace.Exception.ArgumentNull("editor");
58
59             return CreateEditorAttribute(editor.GetType());
60         }
61
62         /// <summary>
63         /// Utility method that creates a new EditorAttribute for the specified
64         /// CategoryEditor type
65         /// </summary>
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");
72
73             if (!typeof(CategoryEditor).IsAssignableFrom(categoryEditorType))
74                 throw FxTrace.Exception.AsError(new ArgumentException(
75                     string.Format(
76                         CultureInfo.CurrentCulture,
77                         Resources.Error_ArgIncorrectType,
78                         "categoryEditorType",
79                         typeof(CategoryEditor).Name)));
80
81             return new EditorAttribute(categoryEditorType, categoryEditorType);
82         }
83     }
84 }