Class Inspector
This class implements an inspector for model data objects.
Namespace: Northwoods.Go.Extensions
Assembly: DataInspectorAvalonia.dll
Syntax
public class Inspector
Remarks
Example usage of Inspector:
var inspector = new Inspector(inspectorControl1, myDiagram, new Inspector.Options {
IncludesOwnProperties = false,
Properties = new Dictionary<string, Inspector.PropertyOptions> {
{ "Key", new Inspector.PropertyOptions { ReadOnly = true } },
{ "Comments", new Inspector.PropertyOptions { Show = Inspector.ShowIfNode } },
{ "Chosen", new Inspector.PropertyOptions { Type = "checkbox" } },
{ "State", new Inspector.PropertyOptions { Type = "select", Choices = new int[] { 1, 2, 3, 4 } } }
}
});
Constructors
Inspector(IInspector, Diagram, Options)
Constructs an Inspector and sets up properties based on the options provided. Also sets up change listeners on the Diagram so the Inspector stays up-to-date.
Declaration
public Inspector(IInspector inspector, Diagram diagram, Inspector.Options options)
Parameters
Type | Name | Description |
---|---|---|
IInspector | inspector | a reference to the inspector element/control |
Diagram | diagram | a reference to a Diagram |
Inspector.Options | options | an optional object describing options for the inspector |
Properties
Diagram
Gets or sets the Diagram associated with this Inspector.
Declaration
public Diagram Diagram { get; set; }
Property Value
Type | Description |
---|---|
Diagram |
IncludesOwnProperties
Gets or sets whether the Inspector includes all properties currently on the inspected object.
Declaration
public bool IncludesOwnProperties { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
The default value is true.
InspectedObject
This read-only property returns the object currently being inspected.
Declaration
public object InspectedObject { get; }
Property Value
Type | Description |
---|---|
object |
Remarks
To set the inspected object, call InspectObject(object).
InspectSelection
Gets or sets whether the Inspector automatically inspects the associated Diagram's selection.
Declaration
public bool InspectSelection { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
When set to false, the Inspector won't show anything until InspectObject(object) is called.
The default value is true.
Properties
Gets or sets the properties that the Inspector will inspect, maybe setting options for those properties.
Declaration
public Dictionary<string, Inspector.PropertyOptions> Properties { get; set; }
Property Value
Type | Description |
---|---|
Dictionary<string, Inspector.PropertyOptions> |
Remarks
The dictionary should contain string: Object pairs representing propertyName: propertyOptions. Can be used to include or exclude additional properties.
The default value is null.
PropertyModified
Gets or sets the function to be called when a property is modified by the Inspector.
Declaration
public Action<string, object, Inspector> PropertyModified { get; set; }
Property Value
Type | Description |
---|---|
Action<string, object, Inspector> |
Remarks
The first parameter will be the property name, the second will be the new value, and the third will be a reference to this Inspector.
The default value is null, meaning nothing will be done.
Rows
Gets the rows of properties and their options to be displayed.
Declaration
public IList<Inspector.Row> Rows { get; }
Property Value
Type | Description |
---|---|
IList<Inspector.Row> |
Methods
CanEditProperty(string, PropertyOptions, object)
This predicate should be false if the given property should not be editable by the user. Normally it only checks the value of ReadOnly.
Declaration
public bool CanEditProperty(string propertyName, Inspector.PropertyOptions opts, object inspectedObject)
Parameters
Type | Name | Description |
---|---|---|
string | propertyName | the property name |
Inspector.PropertyOptions | opts | the property options |
object | inspectedObject | the data object |
Returns
Type | Description |
---|---|
bool | whether a particular property should be shown in this Inspector |
Remarks
The default value is true.
CanShowProperty(string, PropertyOptions, object)
This predicate should be false if the given property should not be shown. Normally it only checks the value of Show.
Declaration
public bool CanShowProperty(string propertyName, Inspector.PropertyOptions opts, object inspectedObject)
Parameters
Type | Name | Description |
---|---|---|
string | propertyName | the property name |
Inspector.PropertyOptions | opts | the property options |
object | inspectedObject | the data object |
Returns
Type | Description |
---|---|
bool | whether a particular property should be shown in this Inspector |
Remarks
The default value is true.
InspectObject(object)
Update the UI state of this Inspector with the given object.
Declaration
public void InspectObject(object obj = null)
Parameters
Type | Name | Description |
---|---|---|
object | obj |
Remarks
If passed an object, the Inspector will inspect that object. If no parameter is supplied, the InspectedObject will be set based on the value of InspectSelection.
ShowIfGroup(object, string)
This predicate function can be used as a value for Show. When used, the property will only be shown when inspecting a Group.
Declaration
public static bool ShowIfGroup(object part, string _)
Parameters
Type | Name | Description |
---|---|---|
object | part | the Part being inspected |
string | _ | unused |
Returns
Type | Description |
---|---|
bool |
ShowIfLink(object, string)
This predicate function can be used as a value for Show. When used, the property will only be shown when inspecting a Link.
Declaration
public static bool ShowIfLink(object part, string _)
Parameters
Type | Name | Description |
---|---|---|
object | part | the Part being inspected |
string | _ | unused |
Returns
Type | Description |
---|---|
bool |
ShowIfNode(object, string)
This predicate function can be used as a value for Show. When used, the property will only be shown when inspecting a Node.
Declaration
public static bool ShowIfNode(object part, string _)
Parameters
Type | Name | Description |
---|---|---|
object | part | the Part being inspected |
string | _ | unused |
Returns
Type | Description |
---|---|
bool |