SceneControl+AE+鼠标滚轮缩放

要为SceneControl设置鼠标滚轮缩放必须定义委托,因为SceneControl没有Wheel事件,所以委托From的Wheel事件

 1 public Form1()
 2 {
 3        InitializeComponent();
 4        this.MouseWheel += new MouseEventHandler(this.SceneControl_MouseWheel); //在这个地方输入"this.MouseWheel+=”后连续按两次Tab键
 5 }
 6 private void SceneControl_MouseWheel(object sender, System.Windows.Forms.MouseEventArgs e)
 7         {
 8             try
 9             {
10                 axSceneControl1.MousePointer = esriControlsMousePointer.esriPointerZoom;
11                 System.Drawing.Point pSceneLocation = axSceneControl1.PointToScreen(axSceneControl1.Location);
12                 System.Drawing.Point Pt = axSceneControl1.PointToScreen(e.Location);
13                 if (Pt.X < pSceneLocation.X | Pt.X > pSceneLocation.X + axSceneControl1.Width | Pt.Y < pSceneLocation.Y | Pt.Y > pSceneLocation.Y + axSceneControl1.Height)
14                     return;
15                 double scale = 0.2;
16                 if (e.Delta < 0) scale = -0.2;
17                 ICamera pCamera = axSceneControl1.Camera;
18                 IPoint pObserver = pCamera.Observer;
19                 IPoint pTarget = pCamera.Target;
20                 pObserver.X += (pObserver.X - pTarget.X) * scale;
21                 pObserver.Y += (pObserver.Y - pTarget.Y) * scale;
22                 pObserver.Z += (pObserver.Z - pTarget.Z) * scale;
23                 pCamera.Observer = pObserver;
24                 axSceneControl1.SceneGraph.RefreshViewers();
25                 //this.Text = e.Delta.ToString();
26             }
27             catch (Exception ex)
28             {
29                 MessageBox.Show(ex.Message);
30             }
31         }

 

你可能感兴趣的:(缩放)