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

 

转载于:https://www.cnblogs.com/ycbfish333/archive/2008/08/09/1264171.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值