Test composite UI Application Block
The composite UI Application Block is mainly used to create an aggregated Smart Client solution. A client can be built from a group of functional blocks.
1. General steps for creating an application using composite UI
Create Shell
Create a module
Create a reference to services
Create and display smartparts
Developed with MVC and workitems
Create a customized service
Publish and subscribe to events
Use workitems
Show uielements
Register commands
The first attempt is to create only shell and use workitem and controller.
1. Create a winform application, add a main form form1, add the main menu in the form, and add menu items A and B. Generate click events for menu item A and item B respectively. Add deckworkspace to the form
2. modify the program class as a non-static class and inherit formshellapplication <workitem, form1>. In program, the beforeshellcreated and aftershellcreated methods and methods respectively call base. beforeshellcreated () and base. aftershellcreated (). You can add your own code after calling the base class method. Add new program (). Run ();
3. create custom controls view1 and view2. These two custom controls will be added to the deckworkspace of the main form. Add [smartpart] to the class name
4. Create myworkitem
Public class myworkitem: workitem
{
Private view1 _ view1;
Public void showview1 (iworkspace workspace)
{
If (_ view1 = NULL)
_ View1 = This. Items. addnew <view1> ("view1 ");
Workspace. Show (this. _ view1 );
}
Private view2 _ view2;
Public void showview2 (iworkspace workspace)
{
If (_ view2 = NULL)
_ View2 = This. Items. addnew <view2> ("view2 ");
Workspace. Show (this. _ view2 );
}
}
5. Create mycontroller
Public class mycontroller: Controller
{
Private workitem rootworkitem
{
Get {return base. workitem ;}
}
Private myworkitem _ myworkitem;
Public void showview1 (iworkspace workspace)
{
If (_ myworkitem = NULL)
_ Myworkitem = rootworkitem. Items. addnew <myworkitem> ();
_ Myworkitem. showview1 (workspace );
}
Public void showview2 (iworkspace workspace)
{
If (_ myworkitem = NULL)
_ Myworkitem = rootworkitem. Items. addnew <myworkitem> ();
_ Myworkitem. showview2 (workspace );
}
}
6. Inject mycontroller into form1
Private mycontroller controller;
[Createnew]
Public mycontroller Controller
{
Set {controller = value ;}
}
7. Add
Controller. showview1 (this. deckworkspace1 );
Controller. showview2 (this. deckworkspace1 );