1 namespace System.Activities.Presentation.PropertyEditing {
2 using System.ComponentModel;
3 using System.Diagnostics;
4 using System.Collections.Generic;
5 using System.Collections.ObjectModel;
6 using System.Activities.Presentation;
10 /// The CategoryEntry class is a part of the property editing object model. It models a
11 /// Category which has a localized name along with a collection of properties.
13 public abstract class CategoryEntry : INotifyPropertyChanged, IPropertyFilterTarget {
16 private bool _matchesFilter;
19 /// Creates a new CategoryEntry. For host Infrastructure use
21 /// <param name="name">The localized name of the corresponding Category as defined by the
22 /// CategoryAttribute</param>
23 /// <exception cref="ArgumentNullException">When name is either empty or null.</exception>
24 protected CategoryEntry(string name) {
25 if (string.IsNullOrEmpty(name))
26 throw FxTrace.Exception.ArgumentNull("name");
32 /// Returns the localized Category name
34 public string CategoryName {
39 /// Returns an IEnumerable collection of all of the properties in the category.
41 public abstract IEnumerable<PropertyEntry> Properties { get; }
44 /// Indexer that returns a Property instance given the property name.
46 /// <param name="propertyName">The string property name to return a Property instance for.</param>
47 /// <returns>Property corresponding to the passed in propertyName if it exists, otherwise null</returns>
48 public abstract PropertyEntry this[string propertyName] { get; }
50 // INotifyPropertyChanged Members
53 /// INotifyPropertyChanged event
55 public event PropertyChangedEventHandler PropertyChanged;
58 /// Raises the INotifyPropertyChanged.PropertyChanged event
60 /// <param name="propertyName">the name of the property that is changing</param>
61 /// <exception cref="ArgumentNullException">When propertyName is null</exception>
62 protected virtual void OnPropertyChanged(string propertyName) {
63 if (propertyName == null)
64 throw FxTrace.Exception.ArgumentNull("propertyName");
66 if (PropertyChanged != null) {
67 PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
72 // IPropertyFilterTarget Members
75 /// IPropertyFilterTarget event
77 public event EventHandler<PropertyFilterAppliedEventArgs> FilterApplied;
80 /// Raises the IPropertyFilterTarget.FilterApplied event
82 /// <param name="filter">The PropertyFilter being applied</param>
83 protected virtual void OnFilterApplied(PropertyFilter filter) {
84 if (FilterApplied != null) {
85 FilterApplied(this, new PropertyFilterAppliedEventArgs(filter));
90 /// IPropertyFilterTarget method
92 /// <param name="filter"></param>
93 public virtual void ApplyFilter(PropertyFilter filter) {
94 this.MatchesFilter = filter == null ? true : filter.Match(this);
95 OnFilterApplied(filter);
99 /// IPropertyFilterTarget property
101 public virtual bool MatchesFilter {
102 get { return _matchesFilter; }
104 if (_matchesFilter != value) {
105 _matchesFilter = value;
106 this.OnPropertyChanged("MatchesFilter");
112 /// IPropertyFilterTarget method
114 /// <param name="predicate">The PropertyFilterPredicate to match against</param>
115 /// <returns>true if there is a match, otherwise false</returns>
116 public abstract bool MatchesPredicate(PropertyFilterPredicate predicate);