SmartParts
There are two scenarios for using SmartParts in a Composite UI Application Block application:
- The SmartPart required for a specific location on a form is known at design time (you can drag the SmartPart into a suitable workspace).
- The SmartPart is created and displayed dynamically at run time, typically in response to user interaction.
For example, the following code creates an OfficerPanelViewSmartPart and shows it in the workspace identified by the string "OfficerPanel."
OfficerPanelView view = WorkItem.SmartParts.AddNew
();
WorkItem.Workspaces[“OfficerPanel”].Show(view);
Workspaces
are components that encapsulate a particular visual way of displaying controls and SmartParts.
The Composite UI Application Block includes the following types of workspaces:
- WindowWorkspace.
- MdiWorkspace.
- TabWorkspace.
- DeckWorkspace.
- ZoneWorkspace.
UI Elements
We can create add menu items to a menu bar. Developers register a user interface element as a UI extension site.
RootWorkItem.UIExtensionSites.RegisterSite(“FileMenu”, Shell.MainMenuStrip);
The application block provides a UI extension site catalog (collection) for each WorkItem. This catalog allows you to access and manage the elements in the catalog using the site name of the element.
ToolStripMenuItem printItem = new ToolStripMenuItem("Print");Commands enable to write one event handler that is associated with more than one user interface element, and associate one user interface element with multiple command handlers.
RootWorkItem.UIExtensionSites[“FileMenu”].Add(printItem);
WorkItems
A WorkItem is a run-time container for components that are working together to fulfill a use case. The components can be both visual and non-visual parts of the application.
A service is a supporting class that provides functionality to other components. The Composite UI Application Block includes a set of basic services. You can also build your own services .
The following code shows how to add the CustomerFinderService to a WorkItem.
WorkItem.Services.AddNew
A component within a WorkItem can ask the WorkItem for any other component. The following code shows how you can request the service that implements the ICustomerFinderServcie interface.
ICustomerFinderService customerFinderServcie = WorkItem.Services.GetThere is always an active WorkItem, which implements the currently active use case, and you can activate and deactivate WorkItems as required. The application adds these additional WorkItems to a parent WorkItem.
Events
Components can use events to publish or receive notifications. The Composite UI Application Block contains an eventbroker system that enables you to implement a multicast event scheme. You publish an event by adding the EventPublication attribute to an event declaration, as shown in the following code.
[EventPublication("topic://UpdatesAvailable", PublicationScope.Global)] public event EventHandlerMethods can subscribe to events using the EventSubscription attribute on a method declaration, as shown in the following code.
[EventSubscription("topic://UpdatesAvailable")]
public void SomethingHappened(object sender, DataEventArgse)
{ ... }
Services
Services are objects that are used by many components in the application, such as security services, tracing services, and eventing services.
No comments:
Post a Comment