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

Compare with Current View Page History

« Previous Version 9 Next »

Exercise outline

The goal of this exercise is to show how a new plugin can be developed using the Delta Shell Application plugin Nuget package. The Delta Shell NuGet package will be used in order to make a quick start.

Create a new C# project

Start Visual Studio 2013 and create a new C# project (File | New | Project...) by configuring the project wizard as shown in the following image:



Afterwards, a solution should be created with a structure as shown in the following image:



The default class named Class1.cs can be removed.

Add the Delta Shell SDK to the project using NuGet

A Visual Studio extension called NuGet will be used to add the Delta Shell application plugin package to the newly created project.

General information about NuGet can be found at http://docs.nuget.org/.

Information on how to install NuGet as a Visual Studio extension can be found at http://docs.nuget.org/docs/start-here/installing-nuget.

Since Visual Studio 2013 NuGet is installed by default. However you have to make sure that it is updated to the latest version by checking the Extension and Updates window (click TOOLS | Extensions and Updates... | Updates | Visual Studio Gallery). When previous version is used - installing Delta Shell SDK package might result in the following error:

 

The Delta Shell application plugin package is build on the teamcity build server, and so we must add the build server package feed address to the package locations of nuget. Open the options of Visual studio (click TOOLS | Options) and browse to the Nuget package manager settings.

In the Package Sources add a new source by using the + button and add the following information :

NameTeamCityAuth
Sourcehttp://build.deltares.nl/httpAuth/app/nuget/v1/FeedService.svc/

 


Open the NuGet package manager (right click the solution | Manage NuGet Packages for Solution...) and search for the Delta Shell application plugin package in the TeamCityAuth like shown in the following image:

Select the Deltashell.Plugins.VolumeModel project as project to add the Nuget package to :

Complete the install by pressing ok. This may take a while because Nuget will now download the DeltaShell framework and runs install scripts to configure your project for use as a deltashell plugin.

After installing the package your project will look something like this :

In this tutorial we don't use PostSharp so we can remove postsharp from the project by removing the selected items from the project (PostSharp is mostly used for adding property and collection changed events + event bubbling and requires a license to run). Also open the packages.config and remove the postsharp reference "<package id="PostSharp" version="2.1.7.28" targetFramework="net40" />"

Now open the settings of our plugin project and change the following settings :

Change the target framework to .Net Framework 4 (DeltaShell is build using the .Net version 4.0)

Go to the debug page and set the startup program to : D:\DeltaShell.Plugins.VolumeModel\bin\Debug\DeltaShell\DeltaShell.Gui.exe

 

Create an application plugin class

Add a class named "VolumeModelApplicationPlugin " to the project and add the following code describing the application part of the plugin:

using DelftTools.Shell.Core;
using Mono.Addins;

namespace DeltaShell.Plugins.VolumeModel
{
    [Extension(typeof(IPlugin))]
    public class VolumeModelApplicationPlugin : ApplicationPlugin
    {
        public override string Name
        {
            get { return "VolumeModelApplication"; }
        }
        public override string DisplayName
        {
            get { return "Volume model application"; }
        }
        public override string Description
        {
            get { return "Application plugin of the volume model application"; }
        }
        public override string Version
        {
            get { return "1.0"; }
        }
        public override string FileFormatVersion
        {
            get { return "1.0"; }
        }
    }
}

Created an gui plugin class

Create a class named "VolumeModelGuiPlugin" to the project and add the following code describing Gui part of the plugin:

using DelftTools.Shell.Core;
using DelftTools.Shell.Gui;
using Mono.Addins;
namespace DeltaShell.Plugins.VolumeModel
{
    [Extension(typeof(IPlugin))]
    public class VolumeModelGuiPlugin : GuiPlugin
    {
        public override string Name
        {
            get { return "VolumeModelApplicationUI"; }
        }
        public override string DisplayName
        {
            get { return "Volume model application (UI)"; }
        }
        public override string Description
        {
            get { return "Gui plugin of the volume model application"; }
        }
        public override string Version
        {
            get { return "1.0"; }
        }
        public override string FileFormatVersion
        {
            get { return "1.0"; }
        }
    }
}

Add reference to DeltaShell Gui

To get the code above to work we need to add a reference to DelftTools.Shell.Gui. This dll can be found in the packages folder of our project : .\packages\DeltaShell.Framework.1.1.1.34867\lib\net40\DeltaShell

Also set the copy local property of the DelftTools.Shell.Gui reference to false (the DeltaShell framework will already copied to the bin, so we do not need to copy the "DelftTools.Shell.Gui.dll" to our plugin folder)

Exercise results

Run the application and open the About window (File | Help | About). Ensure both the application plugin and the gui plugin are visible in the overview of loaded plugins:

  • No labels