ArcObject操作之"拉框放大","拉框缩小","撤销","前进"

Private Sub AxMapControl1_OnMouseDown(ByVal sender As System.Object, ByVal e As ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent) Handles AxMapControl1.OnMouseDown

        '拉框放大
        If Me.TrackRectangle_big_small = True Then
            Dim pEnv As IEnvelope
            Dim pActiveView As IActiveView
            pEnv = Me.AxMapControl1.TrackRectangle
            pActiveView = Me.AxMapControl1.ActiveView

            If pEnv.IsEmpty Then
                pEnv = Me.AxMapControl1.Extent
                pEnv.Expand(0.8, 0.8, True)
                pEnv.CenterAt(pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y))
            ElseIf pEnv.Height = 0 Or pEnv.Width = 0 Then
                pEnv = Me.AxMapControl1.Extent
                pEnv.Expand(0.8, 0.8, True)
                pEnv.CenterAt(pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y))
            End If

            pActiveView.Extent = pEnv
            pActiveView.Refresh()

 

            '拉框缩小
        ElseIf Me.TrackRectangle_big_small = False Then
            Dim pEnv As IEnvelope
            Dim pActiveView As IActiveView
            Dim pRubberBand As IRubberBand
            Dim dWidth As Double, dHeight As Double
            Dim dXmin As Double, dYmin As Double, dXmax As Double, dYmax As Double

            pRubberBand = New RubberEnvelope
            pActiveView = Me.AxMapControl1.ActiveView
            pEnv = pRubberBand.TrackNew(pActiveView.ScreenDisplay, Nothing)

            If pEnv.IsEmpty Then
                pEnv = Me.AxMapControl1.Extent
                pEnv.Expand(1.2, 1.2, True)
                pEnv.CenterAt(pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y))
            ElseIf pEnv.Width = 0 Or pEnv.Height = 0 Then
                pEnv = Me.AxMapControl1.Extent
                pEnv.Expand(1.2, 1.2, True)
                pEnv.CenterAt(pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y))
            Else
                dWidth = pActiveView.Extent.Width * pActiveView.Extent.Width / pEnv.Width
                dHeight = pActiveView.Extent.Height * pActiveView.Extent.Height / pEnv.Height
                dXmin = pActiveView.Extent.XMin - ((pEnv.XMin - pActiveView.Extent.XMin) * pActiveView.Extent.Width / pEnv.Width)
                dYmin = pActiveView.Extent.YMin - ((pEnv.YMin - pActiveView.Extent.YMin) * pActiveView.Extent.Height / pEnv.Height)
                dXmax = dXmin + dWidth
                dYmax = dYmin + dHeight
                pEnv.PutCoords(dXmin, dYmin, dXmax, dYmax)
            End If
            pActiveView.Extent = pEnv
            pActiveView.Refresh()
        End If

Exit sub

 

 Private Sub 撤消操作ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 撤消操作ToolStripMenuItem.Click

        If Me.AxMapControl1.ActiveView.ExtentStack.CanUndo Then
            Me.AxMapControl1.ActiveView.ExtentStack.Undo()
        End If

End Sub

 

Private Sub 前进操作ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 前进操作ToolStripMenuItem.Click

        If Me.AxMapControl1.ActiveView.ExtentStack.CanRedo Then
            Me.AxMapControl1.ActiveView.ExtentStack.Redo()
        End If

End Sub

 

你可能感兴趣的:(object)