Skip to content

Parallels in WPF and WinForms Support

Gary edited this page Mar 23, 2015 · 3 revisions

This section shows similarities in WinForms and WPF platforms in application support. For a practical view of similarities and differences, see Converting from WinForms to WPF.

Table of Contents

Namespace Contents

Comparing the contents of similarly named namespaces for those that begin with Sce.Atf and Sce.Atf.Wpf, such as Sce.Atf.Applications and Sce.Atf.Wpf.Applications, reveals they have similar or identically named classes and interfaces—with similar capabilities. For example, the previously mentioned namespaces both have CommandId, ErrorDialogService, LayoutContexts, and StandardEditCommands classes. Both have IControlHostClient, ILayoutContext, and IViewingContext interfaces.

In general, to get the same functionality, your WPF application would use or implement the WPF version of the class or interface.

Common Interfaces and Classes

ICommandService is the same on both platforms. Although each has their own CommandService class that implements ICommandService, both inherit from Sce.Atf.Applications.CommandServiceBase.

DOM support is largely platform agnostic, too. The main difference is that WPF has its own DomRecorder component, because DomRecorder has a UI.

Similar Capabilities

Some features are similar in both platforms, but provided in a different way.

For example, both platforms offer window docking. A WinForms ATF application uses WindowLayoutService to implement a dock, but WPF's docking support is in the namespace Sce.Atf.Wpf.Docking. Both use IWindowLayoutService.

Both platforms implement a distinct WindowLayoutServiceCommands component, but both derive from the common Sce.Atf.Applications.WindowLayoutServiceCommandsBase.

Parallel Classes

ATF has WinForms and WPF classes with the same name that provide the same service in a different way. Many of these are MEF components like CommandService and ControlHostService. Typically the WinForms classes reside in Sce.Atf.Applications and the WPF classes in Sce.Atf.Wpf.Applications.

Many of the sample applications show how to use these MEF components.

This section lists comparable classes with a brief description and cites any pertinent differences for users. In some cases, the differences between the classes are trivial, such as AtfScriptVariables; in others, the implementation is quite different, as for CommandService. Generally, they are used in the same fashion in both WinForms and WPF. For information on using ATF components, see Details on Using Selected ATF Components.

  • AtfScriptVariables: Exposes common ATF services as script variables.
  • AutoDocumentService: Auto-loads a document at application startup.
  • CommandService: Host controls/content and documents. Both derive from Sce.Atf.Applications.CommandServiceBase, so they both implement Sce.Atf.Applications.ICommandService and Sce.Atf.Applications.ICommandClient.
  • ControlHostService: Both implement Sce.Atf.Applications.ICommandClient and Sce.Atf.Applications.IDockStateProvider. Both also implement IControlHostService, but this interface is different for the platforms. Both use IControlHostClient, and it's also different on WinForms and WPF. For control information, WinForms uses ControlInfo, but WPF uses ControlDef, so the RegisterControl() functions differ.
  • ErrorDialogService: Display error messages to user in an error dialog. Both have the same public API.
  • FileDialogService: Provide file dialogs for an application. Both have the same public API, except WPF has no MainWindow or MainForm properties.
  • HelpAboutCommand (WinForms) and HelpCommands (WPF): Both display a Help About dialog, but WPF also provides support for context-sensitive help and several other help dialogs.
  • OutputService: Display text output to user. WinForms uses a RichTextBox for output; WPF uses a OutputView.
  • TargetService: Provides network support for targets. Both implement ITargetService, which is different for WinForms and WPF.
  • ThumbnailService: Manages the transformation of Resources into thumbnail images and file paths.
  • UnhandledExceptionService: Catch all unhandled exceptions and present the user with the option of continuing the application so work can be saved.
  • WindowLayoutServiceCommands: Provides menu options and GUIs for managing and using layouts.

Parallel Interfaces

ATF also contains interfaces with the same names in both WinForms and WPF.

In some cases, though the interface name is the same in WinForms and WPF, the two are quite different, and this is noted when it's the case.

  • IControlHostClient: For control host clients. Essentially the same for both, but in WPF, the parameter is object rather than Control.
  • IControlHostService: For control host services. In WPF, the parameter for a control is object rather than Control. For control information, WinForms uses ControlInfo, but WPF uses ControlDef, so the RegisterControl() functions differ.
  • ILayoutConstraint: Layout constraint, which modifies bounding rectangles. Almost identical interfaces.
  • ILayoutContext: For contexts that support positioning and sizing items. Very similar interfaces.
  • IMenu: Although they have the same name, these interfaces are quite different. The WinForms one is for menus, but the WPF one is for root menu models.
  • IPaletteService: Although the same name, very different. The WinForms one allows you to add and remove palette items, but the WPF one converts a palette item to an object. For examples of their use, see ATF Simple DOM Editor Sample and ATF Simple DOM Editor WPF Sample.
  • IStatusService: For service that manages a status display. Rather different interfaces. Both show status and monitor progress, but do it differently. The WinForms version has more capability.
  • ITarget: Although both interfaces deal with targets, the WinForms one deals with devices available via Deci4p. The WPF one is more generic and offers more members.
  • ITargetService: Both work with targets, but differ substantially. The WinForms version is larger and manages various targets; the WPF one deals only with ITargets.
  • IThumbnailResolver: For thumbnail resolvers. They are both simple but their Resolve() methods differ.
  • IViewingContext: Both are for contexts where items can be viewed, but offer very different capabilities. The WinForms version is concerned about framing objects and ensuring their visibility, but the WPF one is about getting adapters and layout constraints.

Topics in this Section

Clone this wiki locally