DockPanelWorkspace

The DockPanelWorkspace allows to use the DockPanel Suite as CAB Workspace.

1. Initializing the DockPanelWorkspace

It is common to initialize the DockPanelWorkspace inside the Shell or in an own Layout module. Listing 1 shows how the DockPanelWorkspace is initialized in the Test Suite reference application.

public ShellLayoutView()
{
    InitializeComponent();

    dockPanelWorkspace = new DockPanelWorkspace();
    dockPanelWorkspace.Name = WorkspaceNames.DockPanelWorkspace;
    dockPanelWorkspace.DocumentStyle = DocumentStyle.DockingWindow;
    dockPanelWorkspace.Dock = DockStyle.Fill;
    dockPanelWorkspace.DockTopPortion = 180;
    ...
    dockPanelWorkspace.SmartPartActivated += DockPanelWorkspaceSmartPartActivated;
    ...

Listing 1

The SmartPartActivated event in Listing 1 is handled by the DockPanelWorkspaceSmartPartActivated method. The method implementation can be seen in Listing 2. This is a workaround because the UIElementActivation service does not work properly for this workspace. UIElementActivation is responsible for activating the associated WorkItem. Without this workaround the WorkItems are not activated or deactivated. The workaround is only done for Windows Forms controls. The problem does not occur with WPF controls.

private void DockPanelWorkspaceSmartPartActivated(object sender, WorkspaceEventArgs e)
{
    if (dockPanelWorkspace.ActiveSmartPart is Control)
    {
        ((Control)dockPanelWorkspace.ActiveSmartPart).Focus();
    }
}

Listing 2

2. Showing the SmartParts inside the DockPanelWorkspace

Listing 3 shows an extract of the ModuleController class from the Help module. The implementation creates a new SmartPart and shows it inside the DockPanelWorkspace.

DockPanelSmartPartInfo dpInfo = new DockPanelSmartPartInfo("Help", "Help");
dpInfo.DockingType = DockingType.TaskView;
dpInfo.Icon = Resources.Help;
helpView = WorkItem.SmartParts.AddNew<HelpView>();
WorkItem.Workspaces[WorkspaceNames.DockPanelWorkspace].Show(helpView, dpInfo);

Listing 3

The DockPanelSmartPartInfo class is responsible to control the appearance of the SmartPart. In Listing 3 the default layout type is used. The layout type can also explicitly be set via the ShowStrategy property of the DockPanelSmartPartInfo class. The following classes represents the various layout options of the DockPanel Suite. They can be used for the ShowStrategy property:
  • DefaultShowStrategy
  • DockStateShowStrategy
  • FloatingShowStrategy
  • NestingDockingShowStrategy
  • TabLocationShowStrategy

Last edited Oct 8, 2007 at 11:59 AM by jbe2277, version 8

Comments

No comments yet.