xy.txt

来自「自动化控制visio」· 文本 代码 · 共 45 行

TXT
45
字号
/// <param name="referenceWindow">Reference to a Visio window</param>
/// <param name="drawingX">X position in the Visio coordinate system
/// </param>
/// <param name="drawingY">Y position in the Visio coordinate system
/// </param>
/// <returns>Point containing the given Visio coordinate in Windows
/// coordinates</returns>
public static System.Drawing.Point MapDrawingToScreen(
Microsoft.Office.Interop.Visio.Window referenceWindow,
double drawingX,
double drawingY) {

double drawingLeft;
double drawingTop;
double drawingWidth;
double drawingHeight;
int screenLeft;
int screenTop;
int screenWidth;
int screenHeight;
int screenX = 0;
int screenY = 0;

try {

// Get the window coordinates in Visio units.
referenceWindow.GetViewRect(out drawingLeft, out drawingTop,
out drawingWidth, out drawingHeight);

// Get the window coordinates in pixels.
referenceWindow.GetWindowRect(out screenLeft, out screenTop,
out screenWidth, out screenHeight);

// Convert the X coordinate by using pixels per inch from the
// width values.
screenX = (int)Math.Round(screenLeft +
((screenWidth / drawingWidth) * (drawingX - drawingLeft)));

// Convert the Y coordinate by using pixels per inch from the
// height values and using a top-left origin (windows
// coordinates) instead of a bottom-left origin (Visio
// coordinates).
screenY = (int)(screenTop +
((screenHeight / drawingHeight) * (drawingTop - drawingY)));
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?