ShapeApp Samples (Visual Studio Tools for Applications)

The ShapeApp samples demonstrate how to integrate Visual Studio Tools for Applications with a Windows Forms application. ShapeApp is a drawing application; you can drag shapes onto a drawing surface and manipulate the shapes. ShapeApp includes an object model that defines the shapes and the actions that each shape supports.

There are six ShapeApp samples. The following table describes each version.

Sample Version

Description

ShapeAppCSharp

Contains no Visual Studio Tools for Applications modifications.

ShapeAppBasicCSharp

Includes a basic Visual Studio Tools for Applications integration in a managed application.

ShapeAppMacroRecordingCSharp

Demonstrates macro recording.

ShapeAppDynamicProgrammingModelCSharp

Demonstrates how to dynamically add host items and host objects to a project and how to remove them.

ShapeAppClickOnceCSharp

Demonstrates how to implement support for ClickOnce deployment.

ShapeAppBasicMFC

Includes a basic Visual Studio Tools for Applications integration with an unmanaged version of ShapeApp.

Each sample consists of a .zip file that contains a Visual Studio 2008 solution. By default, the .zip files for the samples are installed to the following locations:

  • 32-bit versions of Windows:

    %ProgramFiles%\Visual Studio Tools For Applications 2.0 SDK\build number\Visual Studio Tools For Applications\Samples

  • 64-bit versions of Windows:

    %ProgramFiles(x86)%\Visual Studio Tools For Applications 2.0 SDK\build number\Visual Studio Tools For Applications\Samples

For a walkthrough that provides step-by-step instructions for integrating Visual Studio Tools for Applications with the unmodified ShapeAppCSharp sample, see Walkthrough: Integrating Visual Studio Tools for Applications with ShapeApp.

ShapeAppCSharp

This sample contains the source code for a version of ShapeApp that is written in C#. This sample contains no Visual Studio Tools for Applications modifications. Use this sample to learn how ShapeApp works and how the ShapeApp object model is designed.

ShapeAppCSharp provides the following features:

  • Users can create and load a document that contains multiple drawings that are displayed in a tabbed interface.

  • Users can drag shapes onto drawings. The shapes include squares, stars, circles, triangles, and octagons.

  • Users can modify the location, size, or color of shapes in drawings by right-clicking shapes and clicking shortcut menu commands.

  • Users can save documents and the current state of the shapes on the drawings.

For information about how to build and run the ShapeAppCSharp sample, see How to: Build and Run the ShapeAppCSharp Sample.

ShapeAppBasicCSharp

This sample contains the source code for a basic integration of Visual Studio Tools for Applications with ShapeAppCSharp. This sample also includes project templates for ShapeAppBasicCSharp and the source code for an application-level add-in. Use the ShapeAppBasicCSharp sample to learn about the core integration tasks that you must perform for any host application that is integrated with Visual Studio Tools for Applications.

ShapeAppBasicCSharp demonstrates the following integration tasks:

  • How to generate proxies for the object model of ShapeAppCSharp. The proxies for ShapeAppCSharp are located in the ShapeAppCSharpProxy project. The Proxy.cs file contains the proxy code, and the ShapeAppCSharpOM.xml file contains the XML proxy descriptor file. For more information about proxies, see Creating Proxies.

  • How to modify ShapeAppCSharp to load application-level add-ins by using the add-in management API. This code is located in the extension.cs, HostItemProvider.cs, HostTypeProvider.cs, and Program.cs files. For more information about the add-in management API, see Discovering and Loading Add-Ins.

For information about how to build and run the ShapeAppBasicCSharp sample, see How to: Build and Run the ShapeAppBasicCSharp Sample.

ShapeAppMacroRecordingCSharp

This sample contains the source code for an advanced integration of Visual Studio Tools for Applications with ShapeAppCSharp. This sample also includes project templates for ShapeAppMacroRecordingCSharp and the source code for an application-level add-in and a document-level add-in.

ShapeAppMacroRecordingCSharp demonstrates all of the basic integration tasks of ShapeAppBasicCSharp, plus the following advanced integration tasks:

  • How to start the Visual Studio Tools for Applications integrated development environment (IDE) when the user clicks a menu command or presses ALT+F11. This code is located in the VstaDesignTimeIntegration.cs file. For more information, see Incorporating the Integrated Development Environment.

  • How to debug add-ins in an external process. This code is located in the VstaDesignTimeIntegration.cs file. For more information, see Add-In Debugging.

  • How to record macros. This code is located in the MacroRecorder.cs file and the MacroManager.cs form.

  • How to provide a UI for dynamically loading and unloading document-level add-ins.

  • How to create a Setup project that installs project templates for ShapeAppCSharp add-ins and creates required registry keys on an end-user computer. This code is located in the VSTAHostSetupCustomAction and ShapeAppMacroRecordingCSharpSetup projects.

For information about how to build and run the ShapeAppMacroRecordingCSharp sample, see How to: Build and Run the ShapeAppMacroRecordingCSharp Sample.

ShapeAppDynamicProgrammingModelCSharp

This sample extends ShapeAppCSharp by enabling add-in developers to dynamically add, remove, and rename drawings and shapes in a document-level add-in project.

ShapeAppDynamicProgrammingModelCSharp demonstrates all the basic integration tasks of ShapeAppBasicCSharp, plus the following advanced integration tasks:

For information about how to build and run the ShapeAppDynamicProgrammingModelCSharp sample, see How to: Build and Run the ShapeAppDynamicProgrammingModelCSharp Sample.

ShapeAppClickOnceCSharp

The ShapeAppClickOnceCSharp sample demonstrates how to incorporate support for ClickOnce deployment into the ShapeAppCSharp application.

ShapeAppClickOnceCSharp demonstrates all the basic integration tasks of ShapeAppBasicCSharp, plus the following advanced integration tasks:

For information about how to build and run the ShapeAppClickOnceCSharp sample, see How to: Build and Run the ShapeAppClickOnceCSharp Sample.

ShapeAppBasicMFC

The ShapeAppBasicMFC sample demonstrates how to integrate Visual Studio Tools for Applications with an unmanaged version of ShapeApp. This sample contains the source code for the minimum level of integration required to load and unload add-ins and to enable add-in developers to create new application-level add-ins that extend ShapeApp. This sample also includes project templates and the source code for a sample application-level add-in. Use the ShapeAppBasicMFC sample to learn about the core integration tasks that you must perform for any host application that is integrated with Visual Studio Tools for Applications.

ShapeAppBasicMFC demonstrates the following integration tasks of Visual Studio Tools for Applications:

  • How to generate proxies for the object model of an unmanaged host application. The proxies for ShapeAppBasicMFC are located in the Proxy project. The proxy.cs file contains the proxy code, and the descriptor.xml file contains the XML proxy descriptor file. For more information about proxies, see Creating Proxies.

  • How to modify an unmanaged host application to load application-level add-ins. This code is located in the VSTAIntegration project. For more information, see Discovering and Loading Add-Ins.

  • How to start the Visual Studio Tools for Applications IDE when the user clicks a menu command or presses ALT+F11. This code is located in the IdeIntegration.cs file. For more information, see Incorporating the Integrated Development Environment.

Note

ShapeAppBasicMFC does not compile until you install Visual Studio Tools for Applications on the development computer. For information about how to install Visual Studio Tools for Applications, see Installing Visual Studio Tools for Applications.

See Also

Tasks

How to: Build and Run the ShapeAppCSharp Sample

How to: Build and Run the ShapeAppBasicCSharp Sample

How to: Build and Run the ShapeAppMacroRecordingCSharp Sample

How to: Build and Run the ShapeAppDynamicProgrammingModelCSharp Sample

How to: Build and Run the ShapeAppClickOnceCSharp Sample

How to: Build and Run the ShapeAppBasicMFC Sample

Walkthrough: Integrating Visual Studio Tools for Applications with ShapeApp

Concepts

ShapeApp Samples (Visual Studio Tools for Applications)