在 Visio 绘图控件(托管在 WPF 应用程序中)中更改形状大小时出现问题
我正在开发一个项目,该项目涉及在 WPF 应用程序中使用 Visio 的绘图控件。我可以托管该控件并在我的应用程序中使用它,但在调整形状大小时遇到一些问题。
问题就在这里。 在 ShapeAdded 事件处理程序中,我尝试使用此代码更改形状的大小
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);
此代码似乎可以工作,但发生如下:
- 形状在绘图控件中精确指定了宽度和高度(根据标尺
- )形状乘以 96。
因此,如果我使用 height = width = 1,我得到的形状在纸上为 1cm * 1cm,但在其属性中显示为 96cm*96cm。 我认为这是与 WPF 的设备独立单元相关的问题,但我不知道如何解决。
希望你能帮助我。 谢谢! 干杯。 -弗朗西斯科
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题在于标准 Visio 绘图比例(建筑),其中 3/32 英寸 = 1 英尺。
算一下,乘数是 96。我设法修改绘图比例和纸张比例。
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.