|
//----------------------------------------------------------------------------------------
// patterns & practices - Smart Client Software Factory - Guidance Package
//
// This file was generated by this guidance package as part of the solution template
//
// The WorkItemController is an abstract base class that contains a WorkItem.
// This class contains logic that would otherwise exist in the WorkItem.
// You can use this class to partition your code between a class that derives from WorkItemController and a WorkItem.
//
// For more information see:
// ms-help://MS.VSCC.v80/MS.VSIPCC.v80/ms.practices.scsf.2007may/SCSF/html/03-01-010-How_to_Create_Smart_Client_Solutions.htm
//
// Latest version of this Guidance Package: http://go.microsoft.com/fwlink/?LinkId=62182
//----------------------------------------------------------------------------------------
using System;
using System.Windows.Forms;
using Microsoft.Practices.CompositeUI;
using DialogBox.Infrastructure.Interface.Services;
namespace DialogBox.Infrastructure.Interface
{
/// <summary>
/// Base class for a WorkItem controller.
/// </summary>
public abstract class WorkItemController : IWorkItemController
{
private WorkItem _workItem;
/// <summary>
/// Gets or sets the work item.
/// </summary>
/// <value>The work item.</value>
[ServiceDependency]
public WorkItem WorkItem
{
get { return _workItem; }
set { _workItem = value; }
}
public IActionCatalogService ActionCatalogService
{
get { return _workItem.Services.Get<IActionCatalogService>(); }
}
public virtual void Run()
{
}
/// <summary>
/// Creates and shows a smart part on the specified workspace.
/// </summary>
/// <typeparam name="TView">The type of the smart part to create and show.</typeparam>
/// <param name="workspaceName">The name of the workspace in which to show the smart part.</param>
/// <returns>The new smart part instance.</returns>
protected virtual TView ShowViewInWorkspace<TView>(string workspaceName)
{
TView view = WorkItem.SmartParts.AddNew<TView>();
WorkItem.Workspaces[workspaceName].Show(view);
return view;
}
/// <summary>
/// Shows a specific smart part in the workspace. If a smart part with the specified id
/// is not found in the <see cref="WorkItem.SmartParts"/> collection, a new instance
/// will be created; otherwise, the existing instance will be re used.
/// </summary>
/// <typeparam name="TView">The type of the smart part to show.</typeparam>
/// <param name="viewId">The id of the smart part in the <see cref="WorkItem.SmartParts"/> collection.</param>
/// <param name="workspaceName">The name of the workspace in which to show the smart part.</param>
/// <returns>The smart part instance.</returns>
protected virtual TView ShowViewInWorkspace<TView>(string viewId, string workspaceName)
{
TView view = default(TView);
if (WorkItem.SmartParts.Contains(viewId))
{
view = WorkItem.SmartParts.Get<TView>(viewId);
}
else
{
view = WorkItem.SmartParts.AddNew<TView>();
}
WorkItem.Workspaces[workspaceName].Show(view);
return view;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Program Manager in Sculpture project, Interesting in .NET Model driven development.