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

Compare with Current View Page History

« Previous Version 24 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 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 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; }
        }

        [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 decorating the properties that should be visualized in the Properties window (see the results of the exercise)

Fixme

[TODO] Fixme

Exercise results

[TODO] Description of the exercise results




1. Add a new folder to the project named "ObjectProperties"

2. Create a new class named "VolumeModelProperties"

3. Add the following contents to this class:

using System.ComponentModel;
using DelftTools.Shell.Gui;
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; }
        }
    }
}

4. Register the object properties in the gui plugin class by adding the following code to DemoAppGuiPlugin:

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

5. Run the application, create a volume model, click the volume model item in the Project Explorer and ensure the newly create object properties are visible in the property grid Image

  • No labels