Volume 3: Programming with the Visio Object Model disclaimer


Lab 3.8: Build and run the Visio SDK Flowchart sample



Download 0.78 Mb.
Page31/36
Date29.01.2017
Size0.78 Mb.
#11974
1   ...   28   29   30   31   32   33   34   35   36

Lab 3.8: Build and run the Visio SDK Flowchart sample


During this lab, you will:

  1. Build and install the SDK Flowchart sample add-on for VB.NET

  2. Review the basics of how this sample application is put together

Estimated time to complete this lab: 60 minutes
Before You Begin

To complete this lab, you will need:

  • Participants should have completed the review of this module before completing this lab.

  • Visio 2010 SDK installed and configured.

  • Software required for the SDK Flowchart code sample:

    • Visio 2010

    • Excel 2007

    • Word 2007 (to embed the drawing into a Word document)

    • Microsoft .NET Framework 1.1 or Microsoft .NET Framework 2.0

    • Visual Studio 2005 or later
What You Will Learn

After completing this lab, you will be able to:

  • Build and run the Flowchart example from the Visio 2010 SDK

  • Understand the software architecture for this sample

42.Exercise : Build and run the Flowchart (VB.NET) sample code from the SDK

Scenario


Build the Flowchart code sample in Visual Studio, install the COM Add-in, create a drawing from the Flowchart(VB .NET) and run.

Tasks


  1. Copy the project files from the SDK folder to the Visual Studio 2005 Projects folder. From the SDK folder you can copy everything from …\visSDK\Samples\Flowchart.

  2. In the Visual Studio 2005 Projects folder double-click …\FlowChart\VBNet\Visual Studio 80\FlowchartSample.sln to open the project in Visual Studio 2005.

  3. In the Solution Explorer window right-click on FlowchartSample and choose Build.

  4. In the Solution Explorer window right-click on FlowchartSampleSetup and choose Build. This creates FlowchartSampleSetup.msi in the \Visual Studio 80\bin\Debug\Setup folder.

  5. Double-click FlowchartSampleSetup.msi to install the COM Add-in.

  6. Start Visio and verify the add-in is loaded.

    1. Choose File > Options > Add-ins

    2. Find FlowchartSample (VB.NET) in the Active Application Add-ins list

  7. Create a new drawing from the Flowchart (VB.NET) template, File > New > SDK > Samples > Flowchart (VB.NET). The following dialog will be displayed:



  1. Choose Yes. The add-in will build a multi-paged flowchart. Choosing No will do the same thing, but screen updating is turned off so you won’t see anything until the process is complete.

  2. Note that a new toolbar has been created: SDK Flowchart Publication. It has two buttons for publishing the drawing to Word and publishing the drawing to the web.

  3. Click the button to publish to Word. This copies the active page to a Word document. To put the other pages into Word you would need to go to each page individually and click the button to publish to Word.

  4. Click the button to Save Document as a Web Page.

  5. Right-click a flowchart shape and choose Number Of Connections… This command displays a message box show the number of connections and the name of the connectors glued to the shape.

43.Exercise 2: Code review.

Scenario


This is a high level break down of how the add-in has been architected.

Code components


  1. Connect.vb

This class implements the IDTExtensibility2 interface, allowing it to serve as a COM add-in for Microsoft Office Visio and initializes the Visio Application object's EventList with events, for which the Flowchart Sample add-in will listen.

  1. EventSink.vb

This class is an event sink for Visio events. It handles events from Visio which were specified using AddAdvise. It handles event notification by implementing the IVisEventProc interface, which is defined in the Visio type library.

In order to be notified of events, an instance of this class must be passed as the EventSink argument in calls to AddAdvise. The Flowchart Sample calls AddAdvise once in Visio on the Connect module where it registers for Marker events sourced by the Application object. The code in this class processes marker events created by this Flowchart sample. It listens for three events:



    1. DocumentCreate – creates a new drawing when a user creates a new document based on the Visio SDK Flowchart Sample template

    2. DocumentOpen – creates a custom command bar when a document created from the SDK Flowchart Sample template is opened

    3. handleRightMouseClick – handles the case where the user does a right mouse click on a flowchart shape and chooses Number of Connections…

  1. DocumentCreator.vb

This class creates a Visio document containing flowchart drawings, based on data contained in a Microsoft Office Excel worksheet. The drawing process is driven by the CreateDrawing procedure which is initiated from the DocumentCreate event handler.

  1. CustomCommandbar.vb

Creates the custom command bar "SDK Flowchart Publication" and adds it to the Visio CommandBars. It also contains methods to handle the click events for the buttons on the custom command bar.

  1. Publisher.vb

This class provides procedures to export a document to either a Web page or a Microsoft Office Word document.

  1. Shared.vb

Low level shared utilities and constants.

  1. Assemblyinfo.vb

Provides the assembly information for the Flowchart Sample Add-in.

Other components


  1. Flowchart (VB.NET).vst – Visio template file for creating the drawings.

  2. Flowchart.xls – Excel file containing the shape and connection information for the flowchart.


Download 0.78 Mb.

Share with your friends:
1   ...   28   29   30   31   32   33   34   35   36




The database is protected by copyright ©ininet.org 2024
send message

    Main page