The most familiar program pieces to the user are those that display in the display area of Mountain Meadow, and can be selected by clicking on its title in the vertical navigation bar. This tutorial shows how to take the simple "Hello, World" program piece made in the previous tutorial and convert it to show a display in the display area when its name is clicked.
Retrace the steps you took making the HelloWorld project with a new project named HelloUser:
We will come back to this class later to make it reference our display after we create it.
The additional steps you will take to make a display so show in the program's main form are:
Add a new User Control to the project and call it "HelloUserDisplay"
Add a new class to the project, called "HelloUser" (the program adds the .cs suffix)
Resize the user control to 706,514 to fit in the display space (when in the default 800x600 main form size)
Drag a panel onto the surface, and set its Dock property to Fill.
Drag a label onto its surface. You should have something like this:
The beauty of program pieces is that they have access to the database and to the program state information through the objects MM3Data and MM3State. For example, we can access the name of the current user through MM3State. To do this we make a constructor for our new user control that requests a reference to the Program Piece that calls it.
Right click on the surface of the user control and choose View Code.
add the line using MM3;
create a local variable for the program piece reference and create a constructor for the user control as shown:
We'll make a method called LoadData() to make the connection to the database and display the user's name on the label control. Notice the intellisence type-ahead feature of Microsoft Visual Studio works as you type in this code because of the reference made to MM3Common where those types are declared.
The code looks like this now:
Now go back to the HelloUserProgramPiece class we made at first. We will override a couple of the methods of ProgramPieceBase in order to specify how we want to call our piece (name,color, etc in the vertical navigation bar, and what display to show when called) and to actually call a method in our display piece.
Type in the following code:
(note the lines for description, LabelSuggested, etc are optional and are just suggestions to the Administrator for what properties to give the program piece when plugging it in to the program. They can be left out. The important line is 'display=new HelloUserDisplay(this)'
That should do it
Run the programs Administrator's console (described elsewhere) to plug in your newly created piece.
Then when you run Mountain Meadow, it should work like this:
Finally: the Plugin Interface: PPInterface.htm