I’m working on a project that involves the use of Visio’s Drawing Control hoseted in a WPF application. I’m able to host the control and use it in my application but I’m having some problems with resizing the shapes.
Here’s the problem.
in the ShapeAdded event handler I’m trying to change the shape’s size using this code
e.shape.get_CellsSRC(
(short)Microsoft.Office.Interop.Visio.VisSectionIndices.
visSectionObject,
(short)Microsoft.Office.Interop.Visio.VisRowIndices.
visRowXFormOut,
(short)Microsoft.Office.Interop.Visio.VisCellIndices.
visXFormHeight).set_Result("CM", height);
e.shape.get_CellsSRC(
(short)Microsoft.Office.Interop.Visio.VisSectionIndices.
visSectionObject,
(short)Microsoft.Office.Interop.Visio.VisRowIndices.
visRowXFormOut,
(short)Microsoft.Office.Interop.Visio.VisCellIndices.
visXFormWidth).set_Result("CM", width);
This code seems to work but happens as follows:
- the shape has in the drawing control exactly width and height specified (accordingly to the rulers)
- the height and width of the shape are multiplied by 96.
So if I use height = width = 1 I get a shape that on the paper is 1cm * 1cm but in its properties it says it is 96cm*96cm.
I think it’s a problem related to Device Indipendent Units of WPF, but I don’t figure out how to solve.
Hope you can help me.
Thanks!
Cheers.
-Francesco
The problem was the standard Visio Drawing scale (architectural) where 3/32 of inch = 1 feet.
Doing some math it cames the 96 multiplying factor. I managed modifying the drawing scale and the paper scale.