public class Views
{
public const string TripDestinations = "TripDestinations";
public const string TripManagement = "TripManagement";
public const string TripPurpose = "TripPurpose";
public const string TripTypes = "TripTypes";
}
/// <summary>
/// Constants for workspace names.
/// </summary>
public class WorkspaceNames : TravelTrackerSmartClient.Infrastructure.Interface.Constants.WorkspaceNames
{
public const string TripTabWorkspace = "TripTabWorkSpace";
}
private void AddViews()
{
WorkItem.Items.AddNew<TripDestinations>(Constants.Views.TripDestinations);
WorkItem.Items.AddNew<TripManagement>(Constants.Views.TripManagement);
WorkItem.Items.AddNew<TripPurpose>(Constants.Views.TripPurpose);
WorkItem.Items.AddNew<TripTypes>(Constants.Views.TripTypes);
}
- Once all of this is complete I now have an application that actually starts, loads the TravelTracker Project and on Run() adds each of the SmartPart Views into the WorkItem Items collection. With this in place I can now wire up each of the specific event publications and subscriptions that will allow me to have each SmartPart displayed when a particular menu item is selected (or Tab Part).
- To start wiring up the Subscription and Publications make a reference in the ModuleController:
using Microsoft.Practices.CompositeUI.EventBroker;
EventTopicNames.cs
public class EventTopicNames : TravelTrackerSmartClient.Infrastructure.Interface.Constants.EventTopicNames
{
public const string TripDestinationsClicked_Event = "TripDestinationsClicked_Event";
public const string TripManagementClicked_Event = "TripManagementClicked_Event";
public const string TripPurposeClicked_Event = "TripPurposeClicked_Event";
public const string TripTypesClicked_Event = "TripTypesClicked_Event";
}
ModuleController.cs
[EventSubscription(Constants.EventTopicNames.TripDestinationsClicked_Event, ThreadOption.UserInterface)
public void TripDestinationsClicked_Handler(object sender, EventArgs e)
{}
[EventSubscription(Constants.EventTopicNames.TripManagementClicked_Event, ThreadOption.UserInterface)
public void TripManagementClicked_Handler(object sender, EventArgs e)
{}
[EventSubscription(Constants.EventTopicNames.TripPurposeClicked_Event, ThreadOption.UserInterface)
public void TripPurposeClicked_Handler(object sender, EventArgs e)
{}
[EventSubscription(Constants.EventTopicNames.TripTypesClicked_Event, ThreadOption.UserInterface)
public void TripTypesClicked_Handler(object sender, EventArgs e)
{}
- At this point I actually, for readability, went back and changed in the ShellForm.cs code and events for the menu selections. Along with that I added the event publications attributes and more. The code when finished looks like this:
[EventSubscription(Constants.EventTopicNames.TripDestinationsClicked_Event, ThreadOption.UserInterface)]
public void TripDestinationsClicked_Handler(object sender, EventArgs e)
{
if (!WorkItem.SmartParts.Contains(Constants.Views.TripDestinations))
{
WorkItem.SmartParts.AddNew<TripDestinations>(Constants.Views.TripDestinations);
}
WorkItem.RootWorkItem.Workspaces[Constants.WorkspaceNames.TripTabWorkspace].Show(
WorkItem.SmartParts.Get<TripDestinations>(Constants.Views.TripDestinations));
}
Well, that's that. I'm all wired up. The next step (Part 3, it's coming soon) is to wire up some button pushin data entering GUI Interacing events, buttons, and other such items. Stay tuned...