程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> 關於C語言 >> C#調用Google Earth Com API開發(三)(3)

C#調用Google Earth Com API開發(三)(3)

編輯:關於C語言

雙擊事件:

1: /// <summary>
2: /// 鼠標鉤子。鼠標雙擊事件
3: /// </summary>
4: /// <param name="sender"></param>
5: /// <param name="e"></param>
6: void mouseHook_MouseDbClick(object sender, MouseEventArgs e)
7: {
8:   IntPtr hWnd = NativeMethods.WindowFromPoint(e.Location);
9:   if (hWnd == this.GeRenderHWnd)
10:   {
11:     Point point = this.Control.PointToClIEnt(e.Location);
12:     // 如果鼠標擊點位置在控件內部,則說明鼠標點擊了GoogleEarth視圖
13:     if (this.Control.ClIEntRectangle.Contains(point))
14:     {
15:       Console.WriteLine("xx雙擊了GoogleEarth...");
16:
17:       DoublePoint dp = ((GERenderPanel) Control).DetermineScreenCoordinates(point.X, point.Y);
18:
19:       ParameterizedThreadStart pts = new ParameterizedThreadStart (ShowMouseDbClickPoint);
20:
21:       Thread thread = new Thread(pts);
22:       thread.Start(dp);
23:
24:     }
25:   }
26: }
27:
28: protected void ShowMouseDbClickPoint(object obj)
29: {
30:   //Thread.Sleep(20);
31:   DoublePoint dp = (DoublePoint)obj;
32:   PointOnTerrainGE pGe = GeApp.GetPointOnTerrainFromScreenCoords(dp.X,  dp.Y);
33:   Console.WriteLine("xx鼠標雙擊了:Lnt=" + pGe.Longitude.ToString()
34:     + ";Lat=" + pGe.Latitude.ToString());
35:
36:   MessageBox.Show("我還是出來一下吧!省得你不知道你已經雙擊了鼠標!");
37: }

這兩處代碼還比較簡陋,比如未添加主窗口焦點檢測,相信讀者可以自行添加。O(∩_∩)O~

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved