I'm creating a C# application that uses the Visio Drawing Control and Visio SDK.
Basically, I have a windows form with the Visio control on it and the user and drag and drop objects from the Visio stencil. I am managing the OnShapeAdd and the OnShapeDelete just fine.
My problem is I don't know how to detect the event when the user just moves a shape. I need to do this due to the logic of this application. I don't see anything like 'move' or 'drag' in VisEventCodes.
The documentation isn't specific on whether or not the ShapeChanged event is fired when a shape is moved, but since this would change the location properties of the shape then it's possible. Try handling the ShapeChanged event and see if that works.
You have to use Visio's Undo Manager to begin and end an undo unit scope. See Chapter 25, Using the Visio Undo Manager in Your Program[^] in the MSDN Library. This is in referene to the OLE automation interfaces exposed by Visio, which is what the .NET interop assemblies (RCWs) wrap. For instance, the ApplicationClass has a BeginUndoScope mentioned in the link above.
It works, but if I move a shape once the event is fired MANY times (ten or more). How can I make this event be caught only once for everytime i move a shape?
I could add a counter, but then I wouldn't be able to distinguish when the event is fired correctly from when it is fired because of this weird behavior of visio sdk, so how can I control this?
This is needed because what I do when the shape moves is a heavy process and this eats up time like crazy.
You can't prevent it from being fired so many times, but you could use a simple state variable to help performance and determine when the last event was fired over a period of time (using a timer, for example, a common approach to many such problems).
If these are not Control derivatives, then you have to implement the events yourself from their container. The container would receive these events and you'd have to use the MousePosition static property of a Control (and call PointToClient on that control with the coordinates from MousePosition since those are in screen coordinates). Using the returned Point you need to have a way to figure out which shape was clicked, and then cause it to fire it's own Click or DoubleClick events (which you'd have to implement) using the same timer concept I mentioned before.
Got another question, tho'
I am creating a method that receives two shapes and connects them programmatically.
How can I do that?
Is there any visio function that can draw that connection given the two shapes?
Last Visit: 31-Dec-99 18:00 Last Update: 26-Sep-23 12:54