Visio also provides scoping methods BeginUndoScope and EndUndoScope to set a scope range. These methods start and end a transaction for Visio’s Application object.
Note:
|
If you call the BeginUndoScope method, you should call the EndUndoScope method as soon as you are finished with the actions that comprise the scope.
|
These methods in turn cause the event procedures EnterScope and ExitScope to fire. When EnterScope fires, it records extra information in the EventInfo property of the Application object. This textual description is then accessible in the MoreInfo argument of the VisEventProc.
Together, these methods and events can be used to produce results similar to using Marker events.
For more information on Scoping methods, see the files Undo Scope I.vsd and Undo Scope II.vsd in the Demos student files.
Lab 3.5: Create a Shape Area Calculator
13.Points to Consider
Use ActivePage for your page reference.
Make sure the area that you add to the total is for shapes only.
You can actually shut event handling down altogether. This might be useful when debugging. It can be done through the Trust Center or through the object model by setting the Application.EventsEnabled property.
To start Visio without automation events and without VBA: -
Start Visio normally.
-
Enter the Trust Center (File > Options > Trust Center > Trust Center Settings…)
-
Click Macro Settings, and then click Disable all macros without notification.
-
Click Add-ins.
-
Click to select the Disable all Application Add-ins check box.
-
Click OK.
-
Exit Visio, and then restart Visio.
It is sometimes necessary to build a model to contain run-time data to support your drawing. But how does this model get reconstructed when a drawing is closed and then reopened? The DocumentOpened event can be used to make data persist. This works fine when you are through with development and are ready to distribute your solution. However, it can be a nuisance during the development process to always be opening and closing the drawing in order to reinitialize data.
Instead of DocumentOpened, use RunModeEntered to initialize run-time data. When a document is opened, both the DocumentOpened and the RunModeEntered events fire. However, it is much easier to initialize your run-time data during the development process by just switching to Design Mode and then back to Run Mode.
In this module you have seen how to handle events in Visio by using simple cell dependency techniques in the ShapeSheet, by utilizing ShapeSheet event section cells, and by using the WithEvents keyword in Visual Basic for Applications. Here are some questions based on the material you just covered.
Questions -
Under what circumstances would you want to use Automation event handling over ShapeSheet event handling?
-
What is the name of Visio’s pre-defined base class?
-
What does the WithEvents keyword allow you to do?
Answers -
Automation event handling is preferred when a more robust solution is required, beyond what can be accomplished in the ShapeSheet.
-
ThisDocument
-
Set up event management for any source object.
In this module we will take an in-depth look at data graphics. The implementation of data graphics beginning with Visio 2007 primarily utilizes the existing environment and objects of Visio 2003. Data graphics and data graphic items are maintained as masters in the Visio object model (albeit hidden except through the Drawing Explorer window). Therefore, when working with data graphics you are working with Visio master objects.
The GraphicItem and GraphicItems objects are new for Visio 2007. The GraphicItem holds the detailed information about a data graphic item, such as its position, and the GraphicsItems object is a collection of the individual items that make up the data graphic. The GraphicsItems collection has been added as a property to the Master object. The Shape object has a DataGraphic property that holds the reference to the data graphic applied to the shape.
Data graphics can be customized. There are several built in text and data bar callouts as well as several built in icon sets. These callouts and icon sets can be modified and new ones can be created, most easily by copying and modifying existing data graphic items.
When a data graphic is applied to the shape, the data graphic master and the shape are grouped. You can then work with the elements of the group just as in previous versions of Visio or you can modify the data graphics within the Data tab of the ribbon. When these masters are modified the changes are then reflected throughout the drawing just as when a master is modified in the Document Stencil.
Note:
|
Modifications made using the Data Graphics within the ribbon will override any manual modifications made to the grouped shape.
|
Module Objectives
After completing this module you will be able to:
-
Work with data graphics with the Visio user interface to add text and data bar callouts
-
Understand how data graphics are managed by Visio and where information about them exists in the Visio object model
-
Understand key ShapeSheet cells required by data graphics
-
Customize data graphics with the Visio user interface to add additional graphic items to data graphics
-
Modify data graphic items to fine tune their behavior within the drawing environment
-
Create icon sets
-
Customize and manage data graphics with automation code
-
Manage data graphics in the drawing environment by making data graphics available for new drawings
Share with your friends: |