Simple Microsoft™ CAB Sample

Tom Puglisi / Thursday, January 19, 2012

As I was digging through the ole’ code bucket, I found a sample that I made several years ago in order to communicate the Microsoft™ CAB (Composite UI Application Block) Architectural Framework. There have been a few customers asking me questions about MS CAB as of late, so I decided to post this sample and discuss it a tad.

This sample is a simple implementation of MS CAB; in other words, it does not use any of those Guidance Automation Toolkit scripts (SCSF – smart client software factory). This is just a plain, simple “reference the MS CAB assemblies, and write the entire code yourself by hand” kind of sample! This sample also does not implement the MVP (Model View Presenter) pattern, which is also a by-product of using SCSF. In this sample, there is actually CODE IN THE UI – GASP!

Again, this sample was created to show a very simple implementation of MS CAB and its core components, along with the Infragistics CAB Extensibility Kit that comes with your Infragistics NetAdvantage Windows Forms installation.

Feel free to download and review the code within this example.

The sample application comes in the form of a media player.

 

Project References

One of the most important things that make this a CAB application are the references. The three Microsoft.Practices.[XXXXX] assemblies contain the essential components that help execute, fire events, manage user controls (Smart Parts) and form elements (UIElements) through out your application’s execution cycle. The Microsoft CAB assemblies are located in a folder named “Lib” located within the main solution folder.

The Infragistics.CompositeUI.Winforms assembly reference represents the CAB Extensibility Kit library that extends several Infragistics controls to work just like CAB WorkSpaces as well as provide UIElement Support to other Infragistics controls.

Review of Projects

  • CabMediaPlayer – This contains the “shell” or main, empty user interface. The Shell will be populated by other, more functional user controls (Smart Parts) that exist within the other Projects. The Shell also contains controls that are designed to accept buttons, menu items, or other “UIElements” that are defined and contained within the other Projects.
  • MediaContentAddin, PlaylistAddin, WindowsMediaPlayerAddin – These projects can be considered “add-ins” or “plug-ins” that automatically expose their designated functionality at runtime, through the help of the CAB runtime, to the main Shell. Each of these add-ins contain functionality, Smart Parts, and UIElements that fit into the main Shell so that you can see and interact with these functionalities.
  • MediaPlayerCommon – This is a project that contains code common to all add-ins, therefore referenced by the add-ins.
  • Infragistics Project – This is the Infragistics CAB project. This is included within the Visual Studio Solution so that upgrading NetAdvantage volume versions is easy and performed all in one place. If you just reference the compiled assembly, you would need to upgrade this stand-alone project wherever it resides and then manually update everything that references this with your new assembly build. This project also comes with the Infragistics Windows Forms installation.

ALL projects reference the Infragistics and Microsoft CAB related assemblies.

The add-in projects reference the MediaPlayerCommon project.

The Shell project (CabMediaPlayer) does NOT have any references to any of the add-in projects. The add-ins are loaded at runtime by CAB through references noted in the ProfileCatalog.xml file located in the Shell project (CabMediaPlayer).

 

So, download this sample, run it and load up some media files. Double click the media items in the playlist to play them and observe what happens through out the UI. Afterwards, go through the various projects to see the actual parts of the CAB implementation (Dependency Injection, Events, UIElements, Smart Parts, WorkSpaces, etc) in a simplified form. Enjoy!