You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 33 Next »

Contents

The root page TOOLS:Tutorial could not be found in space Delta Shell.

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 a new folder to the plugin project named ObjectProperties. In this folder, create a new class named VolumeModelObjectProperties.cs and add the following code:

using System.ComponentModel;
using DelftTools.Shell.Gui;
using DeltaShell.Plugin.DemoApp.Models;

namespace DeltaShell.Plugin.DemoApp.ObjectProperties
{
    [DisplayName("Volume model information")]
    public class VolumeModelProperties : ObjectProperties<VolumeModel>
    {
        [Category("General")]
        [DisplayName("Name")]
        [Description("Name of this volume model")]
        public string Name
        {
            get { return data.Name; }
            get { 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; }
        }
    }
}

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).

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:

using DeltaShell.Plugin.DemoApp.ObjectProperties;

and

        public override IEnumerable<PropertyInfo> GetPropertyInfos()
        {
            yield return new PropertyInfo<VolumeModel, VolumeModelProperties>();
        }

Delta Shell should now be able to find matching object properties after selecting a volume model in the Project window.

Exercise results

Setup a volume model as described in the results of a previous exercise (see 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:

[TODO]

Add screenshot of property grid for a volume model (with imported catchments and time series data)

Ensure that editing the name property actually results in a change of the name of the volume model in the Project window.

 

  • No labels