在skyline中获取当前 鼠标的位置坐标代码。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using TerraExplorerX;
/*====================================================================
标 题:“Skyline范例程序说明”。
范例简介:实现获取当前鼠标三维窗体中的坐标与屏蔽鼠标右键菜单
使用步骤:
1. 使用组合键Ctrl+O,打开数据源文件(*.fly)。
2、点击主窗体中移动鼠标。
=====================================================================*/
namespace SightAnalysis
{
public partial class MainForm : Form
{
//TerraExplorer自定义变量
private TerraExplorer objTerraExplorer;
private IMenu objIMenu;
private IRender5 objRender5;
private IPlane5 objIPlane5;
private ViewLineAnaysis.ViewlineAnalysisWindow FormViewLine;
public MainForm()
{
InitializeComponent();
//实例化TE对象
objTerraExplorer = new TerraExplorer();
objTerraExplorer.OnFrame += new _ITerraExplorerEvents5_OnFrameEventHandler(objTerraExplorer_OnFrame);
objTerraExplorer.OnRButtonDown += new _ITerraExplorerEvents5_OnRButtonDownEventHandler(objTerraExplorer_OnRButtonDown);
}
//屏蔽鼠标右键菜单
void objTerraExplorer_OnRButtonDown(int Flags, int X, int Y, ref object pbHandled)
{
pbHandled = true;
}
//获取当前鼠标对应的坐标
void objTerraExplorer_OnFrame()
{
objRender5 = objTerraExplorer as IRender5;
double dX,dY,dH;
object oFlag,oScreenX,oScreenY;
objRender5.GetMouseInfo(out oFlag, out oScreenX, out oScreenY);
objRender5.ScreenToTerrain(Convert.ToInt32( oScreenX),Convert.ToInt32( oScreenY), out dX, out dY, out dH);
//throw new NotImplementedException();
//this.Text = dX.ToString() + ";" + dY.ToString();
txt_X.Text = dX.ToString();
txt_Y.Text = dY.ToString();
txt_H.Text = dH.ToString();
}
//初始化主窗体
private void FormMail_Load(object sender, EventArgs e)
{
objTerraExplorer.Load(@"D:/*******.FLY");
}
}
转自http://lxliukang.blog.163.com/blog/static/1383246922010427116843/