Add the following code to the MainForm. cs file:
Private void MainForm_Load (object sender, EventArgs e)
{
// Add the scroll wheel zoom-in and zoom-out function to Arcglobe.
This. MouseWheel + = new System. Windows. Forms. MouseEventHandler (axglobecontrolpoliconmousewheel );
}
Private void axglobecontrolpoliconmousewheel (object sender, MouseEventArgs e)
{
Try
{
Cursor. current = new System. windows. forms. cursor (@".. \.. \ Resources \ ZOOMINOUT. CUR "); // convert the mouse style to a custom mouse Style
// M_cursor = new System. Windows. Forms. Cursor (@ "... \ .. \ Resources \ ZOOMINOUT. CUR ");
System. Drawing. Point pSceLoc = axGlobeControl1.PointToScreen (axGlobeControl1.Location );
System. Drawing. Point Pt = this. PointToScreen (e. Location );
If (Pt. X <pSceLoc. X | Pt. x> pSceLoc. X + axGlobeControl1.Width | Pt. Y <pSceLoc. Y | Pt. y> pSceLoc. Y + axGlobeControl1.Height)
{
Return;
}
Double scale = 0.2;
If (e. Delta <0) scale =-scale;
IGlobeCamera pGlobeCamera = axGlobeControl1.GlobeCamera;
ICamera pCamera = pGlobeCamera as ICamera;
IGlobeDisplay pGlobeDisplay = axGlobeControl1.GlobeDisplay;
If (pGlobeCamera. OrientationMode = esriGlobeCameraOrientationMode. esriGlobeCameraOrientationGlobal)
{
Double zt, xo, yo, zo;
PGlobeCamera. GetObserverLatLonAlt (out xo, out yo, out zo );
PGlobeDisplay. GetSurfaceElevation (xo, yo, true, out zt );
IPoint pObserver = new PointClass ();
PObserver. PutCoords (xo, yo );
Double zt1 = zt * (UnitSacleToMeter (axGlobeControl1.Globe. GlobeUnits ));
Zo = (zo-zt1) * (1 + scale );
PGlobeCamera. SetObserverLatLonAlt (xo, yo, zo );
}
Else
{
PCamera. ViewingDistance + = pCamera. ViewingDistance * scale;
}
AxGlobeControl1.GlobeDisplay. RefreshViewers ();
}
Catch
{
}
}
/// <Summary>
/// The UnitSacleToMeter method is used to obtain the coefficient from unit to meter.
/// </Summary>
/// <Param name = "unit"> </param>
/// <Returns> </returns>
Public static double UnitSacleToMeter (esriUnits unit)
{
Switch (unit)
{
Case esriUnits. esriKilometers:
Return 1000;
Case esriUnits. esriMeters:
Return 1;
Default:
Return-1;
}
}