This post, I would like to share my Winforms Shell application, that provides the core foundation for the Winforms application. With this foundation, it can be load the external modules from the pre-defined folders when it started. So that you can add-in and maintenance the modules easily.
How does it work?
This Shell application had been developed based onHBD.Meflibrary to loading and executing external modules when it starts. For more information aboutHBD.Mefyou can found inhere.
In this Shell there are a few services had been developed and exposed into Mef that helps you to interact with the Shell component. 1. TheIMainMenuServicewill help to add Menu Item into the Menu-bar of Main window.
TheIStatusBarServicewill help to set the status into the Status-Bar of Main window.
TheIMainViewServicewill help to interact with Tab Manager of the Main window. That allow to add/remove UserControl into TabManager.
TheNavigationManagerwill provide the details in the below section. # Quick Start – Develop a new module for HBD.WinForms.Shell
1. Add New Module
Open Visual Studio and create a new Class Library project example project name isDemo.Module.
Install the latest version ofHBD.WinForms.Shellfrom Nuget.
Add new class namedStartupDemoModuleand inherited from HBD.Mef.WinForms.Modularity.WinFormModuleBaseand then implement 2 abstract methods (GetStartUpViewTypesandMenuConfiguration(IMainMenuService menuSet)) as below. Remember to add theModuleExportattribute into your StartupDemoModule class.
Set Start external program under Debug toPublish\WinForms.Shell\HBD.WinForms.Shell.exe
And set Working directory toPublish\WinForms.Shellfolder.
4. Add Module config and Debug your module.
Add a newModule_Demo.jsonfile with the following content.
//this file name convention is Module_[Your project Name]
"Description":"This is demo module for WinForms Shell",
//The list of assemblies that you want to be exposed to the EMF.
Set Build action of this config file as below
Run your module the Shell application will display as below.
Navigation between the Views.
From version 1.0.1 a new interface had been added intoHBD.Mef.WinForms.Commonto provide the communication channel between the views. So that the view and navigate to the other view with the parameters.
If your view wants to be navigated from the other view you need to implement theINavigationAwareinterface and handleOnNavigatedTo(WinformNavigationContext navigationContext)method, This method will be called when navigating from the other view.
Hope this Shell will help you to develop a plugin-able application faster and easier. Your feedback and ideas are much appreciated. Please feel free to drop me an email with your opinion.Nuget Dependences