scrollbar |
---|
Exercise
...
outline
...
The
...
goal
...
of
...
this
...
exercise
...
is
...
to
...
visualize
...
information
...
about
...
created
...
volume
...
models
...
in
...
the
...
Properties
...
window.
...
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 Block |
---|
Add a new folder to the plugin project named _ObjectProperties_. In this folder, create a new class named _VolumeModelObjectProperties.cs_ and add the following code: {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 derives 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 DeltaShell.Plugin.DemoApp.ObjectProperties; {code} and {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). |
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 Block |
---|
using System.Collections.Generic;
using DeltaShell.Plugins.VolumeModel.ObjectProperties;
|
and
Code Block |
---|
public override IEnumerable<PropertyInfo> GetPropertyInfos() { { yield return new PropertyInfo<VolumeModelPropertyInfo<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 Setup a volume model as described in the results of a previous exercise (see [TOOLS:Create a simple hydrological model]). Then select the created volume model in the _Project_ view and inspect the _Properties_ window; a properties grid should be visible like shown in the following image: {color:#ff0000}*\[TODO\]*{color} {color:#ff0000}Add screenshot of property grid for a volume model (with imported catchments and time series data){color} {color:#000000}Ensure that editing the name 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} You might have noticed that clicking other items in the _Project_ window results in showing a corresponding property grid in the _Properties_ window too. This is because Delta Shell already defines object properties for all its basic data structures. {info} \\ \\ } |
Delta Shell should now be able to find matching object properties after selecting a volume model in the Project window.
Exercise results
Set up a volume model as described in the results of the previous exercise (see 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:
Make sure that editing the Name property actually results in a change of the name of the volume model in the Project window.
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. |
scrollbar |
---|