h2. Exercise outline
The goal of this exercise is to visualize information about created volume models in the _Properties_ window.
h2. Create a new object properties class
Add to the plugin project a new folder named _ObjectProperties_. In this folder, create a new class named _VolumeModelObjectProperties.cs_ and adapt the contents as shown below:
{code}
using System.ComponentModel;
using DelftTools.Shell.Gui;
namespace DeltaShell.Plugins.VolumeModel.ObjectProperties
{
[DisplayName("Volume model information")]
public class VolumeModelProperties : ObjectProperties<Models.VolumeModel>
{
[Category("General")]
[DisplayName("Name")]
[Description("Name of this volume model")]
public string Name
{
get { return data.Name; }
set { data.Name = value; }
}
[Category("Input")]
[DisplayName("Number of catchments")]
[Description("Number of catchments in the basin")]
public int NumberOfCatchments
{
get { return data.Basin.Catchments.Count; }
}
[Category("Input")]
[DisplayName("Number of time steps")]
[Description("Number of time steps in the precipitation time series")]
public int NumberOfPrecipitationTimeSteps
{
get { return data.Precipitation.Time.Values.Count; }
}
}
}
{code}
{info}
The object properties class is derived from the _ObjectProperties_ base class so that it can be registered in the gui plugin (see the next step).
The _\[DisplayName\]_, _\[Category\]_ and _\[Description\]_ aspects are used for categorizing and decorating the object properties (see the results of the exercise).
{info}
h2. Register the object properties in the gui plugin class
Register the object properties in the gui plugin by adding the following code to _VolumeModelGuiPlugin.cs_:
{code}
using System.Collections.Generic;
using DeltaShell.Plugins.VolumeModel.ObjectProperties;
{code}
and
{code}
public override IEnumerable<PropertyInfo> GetPropertyInfos()
{
yield return new PropertyInfo<Models.VolumeModel, VolumeModelProperties>();
}
{code}
Delta Shell should now be able to find matching object properties after selecting a volume model in the _Project_ window.
h2. Exercise results
Set up a volume model as described in the results of the previous exercise (see [TOOLS:Create a simple hydrological model]).
Then, select the created volume model in the _Project_ window and inspect the _Properties_ window; a properties grid should be visible as shown in the following image:
!PropertiesVolumeModel.png|border=1!\\
\\ {color:#000000}Make sure that editing the{color} {color:#000000}{_}Name{_}{color} {color:#000000}property actually results in a change of the name of the volume model in the{color} {color:#000000}{_}Project{_}{color} {color:#000000}window.{color}
{info}
Clicking on other items in the _Project_ window results in showing their respective property grid in the _Properties_ window too; Delta Shell already defines object properties for all its basic data structures.
{info}
\\
\\
|