Panel | ||
---|---|---|
Panel | ||
| ||
Page Tree | ||
root | TOOLS:Tutorial | startDepth | 3
scrollbar | ||
Exercise outline
The goal of this exercise is to visualize some information about created volume models in the Properties window.
Create a new object properties class
Add a new folder to the plugin project named a new folder named ObjectProperties. In this folder, create a new class named VolumeModelObjectProperties.cs and add the following codeadapt the contents as shown below:
Code Block |
---|
using System.ComponentModel; using DelftTools.Shell.Gui; using DeltaShell.Plugin.DemoApp.Models; namespace DeltaShell.PluginPlugins.DemoAppVolumeModel.ObjectProperties { [DisplayName("Volume model information")] public class VolumeModelProperties : ObjectProperties<VolumeModel>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; } } } } |
Info |
---|
The object properties class derives 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 properties that should be visualized in the Properties window object properties (see the results of the exercise) |
Fixme
Wiki Markup |
---|
*\[TODO\]* Fixme |
Exercise results
Wiki Markup |
---|
*\[TODO\]* Description of the exercise results
\\
\\
\\
\\
\\
1. Add a new folder to the project named "ObjectProperties" |
2. Create a new class named "VolumeModelProperties"
. |
Register the object properties in the gui plugin class
Register the object properties in the gui plugin by adding the following code to VolumeModelGuiPlugin.cs3. Add the following contents to this class:
Code Block |
---|
using System.ComponentModel; using DelftTools.Shell.GuiCollections.Generic; using DeltaShell.Plugin.DemoApp.Models; namespace DeltaShell.Plugin.DemoApp.ObjectProperties { [DisplayName("Volume model parameters")] public class VolumeModelProperties : ObjectProperties<VolumeModel> { [Category("General")] [DisplayName("Name")] [Description("Name of this volume model")] public string Name { get { return data.Name; } } [Category("Input")] [DisplayName("Number of catchments")] [Description("Number of catchments in basin")] public int NumberOfCatchments { get { return data.Basin.Catchments.Count; } } [Category("Input")] [DisplayName("Number of time steps")] [Description("Number of time steps in precipitation time series")] public int PrecipitationTimeSteps { get { return data.Precipitation.Time.Values.Count; } } } } Plugins.VolumeModel.ObjectProperties; |
and4. Register the object properties in the gui plugin class by adding the following code to DemoAppGuiPlugin:
Code Block |
---|
public override IEnumerable<PropertyInfo> GetPropertyInfos() { yield return new PropertyInfo<VolumeModelPropertyInfo<Models.VolumeModel, VolumeModelProperties>(); } |
...
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 |
---|