private void axSceneControl_OnMouseWheel(object sender, MouseEventArgs e) { try { System.Drawing.Point pSceLoc = axSceneControl1.PointToScreen(this.axSceneControl1.Location); System.Drawing.Point Pt = this.PointToScreen(e.Location); if (Pt.X < pSceLoc.X || Pt.X > pSceLoc.X + axSceneControl1.Width || Pt.Y < pSceLoc.Y || Pt.Y > pSceLoc.Y + axSceneControl1.Height) { return; } double scale = 0.2; if (e.Delta < 0) scale = -0.2; ICamera pCamera = axSceneControl1.Camera; IPoint pPtObs = pCamera.Observer; IPoint pPtTar = pCamera.Target; pPtObs.X += (pPtObs.X - pPtTar.X) * scale; pPtObs.Y += (pPtObs.Y - pPtTar.Y) * scale; pPtObs.Z += (pPtObs.Z - pPtTar.Z) * scale; pCamera.Observer = pPtObs; axSceneControl1.SceneGraph.RefreshViewers(); } catch { } }
//添加滚轮事件
this.MouseWheel += new System.Windows.Forms.MouseEventHandler(axSceneControl_OnMouseWheel);