Class Filter
- Namespace
- CADability.Attribute
- Assembly
- CADability.dll
This class filters IGeoObjects according to their attributes or other properties. A Project contains a FilterList which contains Filters. The task of a filter is to decide, whether a IGeoObject is accepted by this filter or not. The FilterList is used by the SelectObjectsAction to decide, whether an object may be selected or not. Filters may also be used for other purposes. In this standard implementation the attributes of a IGeoObject and the type of the object are used to accept or reject an object. You may derive a class from this Filter class and handle the static Constructor delegate by constructing your own filter. In your derived class you can use any criteria of a IGeoObject for filtering, e.g. the contents of UserData.
public class Filter : IShowPropertyImpl, IShowProperty, IPropertyEntry, ISerializable, ICommandHandler
- Inheritance
-
Filter
- Implements
- Inherited Members
Constructors
Filter()
Constructs an empty filter which accepts everything
protected Filter()
Filter(SerializationInfo, StreamingContext)
Constructor required by deserialization
protected Filter(SerializationInfo info, StreamingContext context)
Parameters
infoSerializationInfoSerializationInfo
contextStreamingContextStreamingContext
Fields
Constructor
Set this static delegate to your own method which creates your Filter-derived class.
public static Filter.ConstructionDelegate Constructor
Field Value
Properties
ContextMenu
Implementation of ContextMenu: the default returns null. An entry whose LabelType contains ContextMenu must override it.
public override MenuWithHandler[] ContextMenu { get; }
Property Value
EntryType
Overrides EntryType, returns GroupTitle.
public override ShowPropertyEntryType EntryType { get; }
Property Value
IsActive
Gets or sets the active flag. Only active filters in a FilterList are used for filtering.
public bool IsActive { get; set; }
Property Value
LabelText
Implementation of LabelText, returns either labelTextInternal (if not null) or GetString(string)(resourceId+".Label") Whe set, labelTextInternal is set.
public override string LabelText { get; set; }
Property Value
LabelType
How the label of this entry behaves (see ShowPropertyLabelFlags): whether it can be selected or edited, is bold or has a context menu. The default implementation returns Selectable.
public override ShowPropertyLabelFlags LabelType { get; }
Property Value
Name
Name of the Filter
public string Name { get; set; }
Property Value
SubEntries
The sub entries shown below this entry when it is opened in the property page. The default implementation has none and returns an empty array.
public override IShowProperty[] SubEntries { get; }
Property Value
SubEntriesCount
The number of SubEntries, 0 for an entry that cannot be opened. The default implementation returns 0.
public override int SubEntriesCount { get; }
Property Value
Methods
Accept(IGeoObject)
Checks whether an IGeoObject is accepted by this filter. To realize custom filters, override this method.
public virtual bool Accept(IGeoObject go)
Parameters
goIGeoObjectThe object being tested
Returns
- bool
true if accepted, false otherwise
AcceptType(Type, bool)
Adds or removes the provided type to or from the list of accepted types. The type must be derived from IGeoObject.
public virtual void AcceptType(Type type, bool doAccept)
Parameters
Add(INamedAttribute)
Adds the provided attribute to the list of accepted attributes. CADability knows the following attributes: Layer, Layer, ColorDef, LineWidth, LinePattern, DimensionStyle, HatchStyle. If you have your own attributes which are unknown to CADability, you need to override this method to handle those attributes.
public virtual bool Add(INamedAttribute atr)
Parameters
atrINamedAttributeAttribute to be accepted
Returns
- bool
true, if attribute was known, false otherwise
Added(IPropertyPage)
Implementation of Added(IPropertyPage): memorizes the property page in propertyPage. Unlike Added(IPropertyTreeView) it does not raise the state changed event. Override it to subscribe to events while the entry is displayed, and call the base implementation.
public override void Added(IPropertyPage propertyTreeView)
Parameters
propertyTreeViewIPropertyPage
Construct()
Constructs a ne Filter or Filter-derived object
public static Filter Construct()
Returns
- Filter
The newly constructed Filter
Contains(INamedAttribute)
Checks whether the provided attribute would be accepted
public virtual bool Contains(INamedAttribute atr)
Parameters
atrINamedAttributeThe attribute to check
Returns
- bool
true, if objects with this attribute would be accepted by this filter, false otherwise
EndEdit(bool, bool, string)
Implementation of EndEdit(bool, bool, string): does nothing. An entry with an editable value or label overrides it to take over (or, when aborted, discard) the text that was entered.
public override void EndEdit(bool aborted, bool modified, string newValue)
Parameters
abortedbooltrue: the edit was aborted (Escape), false: it ended normally
modifiedbooltrue: the text was changed while editing
newValuestringthe text as it was when editing ended
GetObjectData(SerializationInfo, StreamingContext)
Writes the data of this object for the legacy binary serialization (ISerializable). Files are written in the JSON format (IJsonSerialize) now; the binary format is still read.
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
infoSerializationInforeceives the data
contextStreamingContextthe destination of the serialization
LabelChanged(string)
Implementation of LabelChanged(string). Override if LabelType is Editable.
public override void LabelChanged(string NewText)
Parameters
NewTextstringthe new text
Remove(INamedAttribute)
Removes this attribute from the list of accepted attributes. For custom attributes see Accept(IGeoObject)
public virtual bool Remove(INamedAttribute atr)
Parameters
atrINamedAttributeAttribute to be removed
Returns
- bool
true, if attribute was known, false otherwise
StartEdit(bool)
Implementation of StartEdit(bool): does nothing. Override it when the entry has to prepare for an edit, e.g. remember the value before the edit.
public override void StartEdit(bool editValue)
Parameters
editValuebooltrue: the value is edited, false: the label is edited