How to add a plugin
Three are two options for creating new plugins:
Create a plugin from scratch
You can create a Visual Studio project, include a single class in it that implements the IPlugin interface (located in LSOne.ViewCore.Interfaces) and then take it from there. Maybe you are a person who likes to start from zero, but if you want to get a running start we recommend the alternative below.
Copy another plugin
The fastest way to create a plugin is to copy another plugin. In the development pack we provide a sample plugin. This plugin is called HelloWorld and is located under the Training_materials folder in the development package. This plugin adds its self to a number of Site Manager locations and you can take a look at the code to see how it works.
You can either copy the Hello World plugin or the another suitable plugin from the development package to get started.
The Hello World plugin is more of a shell plugin with minimal functionality while other plugins might offer more functional examples such as how to access data from a database.
The biggest benefit of copying the Hello world plugin is that you develop your plugin functionality yourself while looking at the similar functionality of the demo plugin.
As an example you can copy the Hello World plugin, rename it and clean up the code to get a clean slate. To do this follow the these steps:
First navigate to the DevPack\Training_materials\Source folder in the development package and copy the HelloWorld Plugin folder. Paste it into DevPack\Source\SM\Plugins. Rename the folder to MyPlugin and rename the HelloWorld.csproj file inside it to MyPlugin.csproj.
If you are following the training course you should name the plugin Criminal
You need to fix the path to this file. First you need to delete the file from the MyPlugin project. Next right click on the MyPlugin project and select Add > Existing Item. Navigate to the DevPack\Source folder and select the SolutionInfo.cs file. Open the drop down menu for Add and select Add as link.
Post-build events are used to stage the plugin DLLs to the build folder but they need to be fixed so that they output to the correct folder. Select the project and go to Properties > Build Events tab to change the post-build events.
Now click the Edit Post-build button and replace the text there with the following command:
start /MIN XCopy "$(TargetDir)*$(TargetName).*" "$(ProjectDir)..\..\Build\Plugins" /S /R /Y
By moving the project into another folder structure some file references are now broken. To quickly fix this expand the project and right click the References node. From there select Add reference to get the Reference Manager dialog. Select the Browse option on the left hand side and click the Browse button.
Navigate to the DevPack\Source\SM\Build folder and copy-paste the following text into the File name box:
"LSOne.ViewCore.dll" "LSOne.Controls.ContextBar.dll" "LSOne.Controls.dll" "LSOne.Controls.OperationPanel.dll" "LSOne.DataLayer.BusinessObjects.dll" "LSOne.DataLayer.DataProviders.dll" "LSOne.DataLayer.GenericConnector.dll"
Press the Add button to close the dialog. Now press the Browse button again and copy-paste the following text into the File name box:
"LSOne.DataLayer.SqlConnector.dll" "LSOne.Services.Interfaces.dll" "LSOne.Utilities.dll"
Press the Add button to close the dialog and then press the OK button to close the Reference Manager. After following these steps all references should be fixed.
Next you need to clean up the code to get an empty plugin to start with. First you need to fix the project properties so that the assembly name is LSOne.ViewPlugins.HelloWorld. Select the project and go to Properties > Application tab to change the Assembly name and Default namespace.
Next you need to clean up the code in the project. Since you just changed the namespace of the assembly you also need to change the namespace references in the code. The easiest way to do this is to simply do a find/replace operation on the project. Press ctrl+left shift+f to open the Find and Replace dialog. Go to the Replace in Files tab end enter the information as shown below.
Now select Replace All to fix the namespace in the code.
Next you need to remove some code that comes with the HelloWorld plugin. You do not need to remove the existing views and dialogs but to get a clean slate to start working on you need to remove some of it.
First remove all code from the PluginEntry.cs > Init function so that it looks like this:
public void Init(IConnectionManager dataModel, IApplicationCallbacks frameworkCallbacks)
{
DataModel = dataModel;
Framework = frameworkCallbacks;
}
Next remove all code from the following functions in PluginOperations.cs:
- TaskBarItemCallback
- AddOperationCategoryHandler
- AddOperationItemHandler
- AddOperationButtonHandler
- ConstructTabs
Next you should have a look at the Site Manager Navigation