First, add two mapcontrols. The Master Chart is named mapMain and the eagleeye chart is named mapEye.
Imports ESRI. ArcGIS. Geometry
Imports ESRI. ArcGIS. Display
Public Class Form1
Private EyeRect As IEnvelope 'eagleeye Rectangular Box range
Private EyeSym As ISimpleFillSymbol 'eagleeye Rectangle frame symbol
'Get the range of the eagleeye rectangle.
Private Function GetEyeRect () As IEnvelope
Dim pEnvMainFull As IEnvelope
PEnvMainFull = mapMain. FullExtent
Dim pEnvMainExt As IEnvelope
PEnvMainExt = mapMain. Extent
Dim pEnvEyeFull As IEnvelope
PEnvEyeFull = mapEye. FullExtent
Dim pEnvEyeExt As IEnvelope
PEnvEyeExt = New Envelope
PEnvEyeExt. XMin = pEnvEyeFull. XMin + (pEnvMainExt. XMin-pEnvMainFull. XMin)/pEnvMainFull. Width * pEnvEyeFull. Width
PEnvEyeExt. XMax = pEnvEyeFull. XMax-(pEnvMainFull. XMax-pEnvMainExt. XMax)/pEnvMainFull. Width * pEnvEyeFull. Width
PEnvEyeExt. YMin = pEnvEyeFull. YMin + (pEnvMainExt. YMin-pEnvMainFull. YMin)/pEnvMainFull. Height * pEnvEyeFull. Height
PEnvEyeExt. YMax = pEnvEyeFull. YMax-(pEnvMainFull. YMax-pEnvMainExt. YMax)/pEnvMainFull. Height * pEnvEyeFull. Height
GetEyeRect = pEnvEyeExt
End Function
'Obtain the RGB color.
Private Function GetRGBColor (ByVal pRed As Long, ByVal pGreen As Long, ByVal pBlue As Long) As IRgbColor
Dim pRGB As IRgbColor
PRGB = New RgbColor
PRGB. Red = pRed
PRGB. Green = pGreen
PRGB. Blue = pBlue
PRGB. UseWindowsDithering = True
GetRGBColor = pRGB
End Function
'Get the eagleeye Rectangle frame symbol
Private Function GetEyeSym () As ISimpleFillSymbol
Dim pSym As ISimpleFillSymbol
PSym = New SimpleFillSymbol
Dim pLnSym As ISimpleLineSymbol
PLnSym = New SimpleLineSymbol
PLnSym. Color = Me. GetRGBColor (255, 0, 0)
PLnSym. Style = esriSimpleLineStyle. esriSLSSolid
PLnSym. Width = 2
PSym. Color = Me. GetRGBColor (255, 0, 0)
PSym. Style = esriSimpleFillStyle. esriSFSBackwardDiagonal
PSym. Outline = pLnSym
GetEyeSym = pSym
End Function
The 'mapeye. Refresh () event activates the OnAfterDraw event of mapEye-> start to draw the eagleeye rectangle.
Private Sub mapEye_OnAfterDraw (ByVal sender As System. Object, ByVal e As ESRI. ArcGIS. Controls. IMapControlEvents2_OnAfterDrawEvent) Handles mapEye. OnAfterDraw
EyeRect = GetEyeRect ()
EyeSym = GetEyeSym ()
If Not EyeRect Is Nothing And Not EyeSym Is Nothing Then
MapEye. DrawShape (EyeRect, EyeSym)
End If
End Sub
'Operate (zoom in, zoom out, and flatten) on the main chart (mapMain), and activate the mapMain_OnAfterScreenDraw event.
Private Sub mapMain_OnAfterScreenDraw (ByVal sender As System. Object, ByVal e As ESRI. ArcGIS. Controls. IMapControlEvents2_OnAfterScreenDrawEvent) Handles mapMain. OnAfterScreenDraw
MapEye. Refresh ()
End Sub
End Class
When I added events to MapControl, I found three events: OnAfterDraw, OnAfterScreenDraw, and OnBeforeScreenDraw;
After debugging, I found that the execution sequence of the three items is OnBeforeScreenDraw-> OnAfterDraw-> OnAfterScreenDraw
OnBeforeScreenDraw is quite easy to understand, meaning "drawing money on the execution screen". OnAfterDraw and OnAfterScreenDraw are a little confused.
So I made some adjustments and experiments, put mapEye. Refresh () in the mapMain_OnAfterDraw event, and the program ran smoothly;
Change the mapEye_OnAfterDraw () event to the mapEye_OnAfterScreenDraw () event. The content remains unchanged and the result program does not have the eagleeye function;
Therefore, I would like to guess whether the painting of the eagleeye frame is counted as "Screen-like painting". Therefore, it can only be performed before OnAfterScreenDraw, and a series of operations on the master image can be stimulated as long
MapEye. Refresh () is the same in mapMain_OnAfterScreenDraw or mapMain_OnAfterDraw.
For details about the three events of MapControl, OnAfterDraw, OnAfterScreenDraw, and OnBeforeScreenDraw, we hope you can give them a more detailed and in-depth discussion and explanation ~~~