Table of Contents

Class Inspector

Namespace
Northwoods.Go.Extensions
Assembly
DataInspectorWinForms.dll

This class implements an inspector for model data objects.

public class Inspector
Inheritance
Inspector
Inherited Members

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.

public Inspector(IInspector inspector, Diagram diagram, Inspector.Options options)

Parameters

inspector IInspector

a reference to the inspector element/control

diagram Diagram

a reference to a Diagram

options Inspector.Options

an optional object describing options for the inspector

Properties

Diagram

Gets or sets the Diagram associated with this Inspector.

public Diagram Diagram { get; set; }

Property Value

Diagram

IncludesOwnProperties

Gets or sets whether the Inspector includes all properties currently on the inspected object.

public bool IncludesOwnProperties { get; set; }

Property Value

bool

Remarks

The default value is true.

InspectSelection

Gets or sets whether the Inspector automatically inspects the associated Diagram's selection.

public bool InspectSelection { get; set; }

Property Value

bool

Remarks

When set to false, the Inspector won't show anything until InspectObject(object) is called.

The default value is true.

InspectedObject

This read-only property returns the object currently being inspected.

public object InspectedObject { get; }

Property Value

object

Remarks

To set the inspected object, call InspectObject(object).

Properties

Gets or sets the properties that the Inspector will inspect, maybe setting options for those properties.

public Dictionary<string, Inspector.PropertyOptions> Properties { get; set; }

Property Value

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.

public Action<string, object, Inspector> PropertyModified { get; set; }

Property Value

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.

public IList<Inspector.Row> Rows { get; }

Property Value

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.

public bool CanEditProperty(string propertyName, Inspector.PropertyOptions opts, object inspectedObject)

Parameters

propertyName string

the property name

opts Inspector.PropertyOptions

the property options

inspectedObject object

the data object

Returns

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.

public bool CanShowProperty(string propertyName, Inspector.PropertyOptions opts, object inspectedObject)

Parameters

propertyName string

the property name

opts Inspector.PropertyOptions

the property options

inspectedObject object

the data object

Returns

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.

public void InspectObject(object obj = null)

Parameters

obj object

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.

public static bool ShowIfGroup(object part, string _)

Parameters

part object

the Part being inspected

_ string

unused

Returns

bool

This predicate function can be used as a value for Show. When used, the property will only be shown when inspecting a Link.

public static bool ShowIfLink(object part, string _)

Parameters

part object

the Part being inspected

_ string

unused

Returns

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.

public static bool ShowIfNode(object part, string _)

Parameters

part object

the Part being inspected

_ string

unused

Returns

bool