zoukankan      html  css  js  c++  java
  • ArcGIS Pro二次开发-放大缩小工具

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using ArcGIS.Core.CIM;
    using ArcGIS.Core.Data;
    using ArcGIS.Core.Geometry;
    using ArcGIS.Desktop.Catalog;
    using ArcGIS.Desktop.Core;
    using ArcGIS.Desktop.Editing;
    using ArcGIS.Desktop.Extensions;
    using ArcGIS.Desktop.Framework;
    using ArcGIS.Desktop.Framework.Contracts;
    using ArcGIS.Desktop.Framework.Dialogs;
    using ArcGIS.Desktop.Framework.Threading.Tasks;
    using ArcGIS.Desktop.Mapping;
    
    
    
    using System.Windows.Input;
    
    
    
    
    
    namespace ProAppModule1
    {
        internal class MapToolSelect : MapTool
        {
            public MapToolSelect()
    
            {
    
               
    
            }
            protected override Task OnToolActivateAsync(bool active)
    
            {
    
                return base.OnToolActivateAsync(active);
    
            }
    
    
    
            protected override void OnToolMouseDown(MapViewMouseButtonEventArgs e)
    
            {
    
                // On mouse down check if the mouse button pressed is:
    
                // the left mouse button to handle zoom in
    
                // or the right mouse button to handle zoom out
    
                // If it is handle the event.
    
                switch (e.ChangedButton)
    
                {
    
                    case MouseButton.Right:
    
                        e.Handled = true;
    
                        break;
    
                    case MouseButton.Left:
    
                        e.Handled = true;
    
                        break;
    
                }
    
            }
    
    
    
            protected override Task HandleMouseDownAsync(MapViewMouseButtonEventArgs e)
    
            {
    
                // Get the map coordinates from the click point and change the Camera to zoom in or out.
    
                return QueuedTask.Run(() =>
    
                {
    
                    var mapClickPnt = MapView.Active.ClientToMap(e.ClientPoint);
    
                    ActiveMapView.LookAt(mapClickPnt, TimeSpan.FromSeconds(1));
    
                    // zoom out
    
                    if (e.ChangedButton == MouseButton.Right)
    
                    {
    
                        ActiveMapView.ZoomOutFixed(TimeSpan.FromSeconds(1));
    
                    }
    
                    // zoom in
    
                    else if (e.ChangedButton == MouseButton.Left)
    
                    {
    
                        ActiveMapView.ZoomInFixed(TimeSpan.FromSeconds(1));
    
                    }
    
                });
    
            }
    
    
    
            protected override void OnToolKeyDown(MapViewKeyEventArgs k)
    
            {
    
                // using key up and down in order to zoom out and in
    
                // if those keys are used we need to mark them as handled
    
                if (k.Key == Key.Up || k.Key == Key.Down)
    
                    k.Handled = true;
    
                base.OnToolKeyDown(k);
    
            }
    
    
    
            protected override Task HandleKeyDownAsync(MapViewKeyEventArgs k)
    
            {
    
                // only called when 'handled' in OnToolKeyDown
    
                if (k.Key == Key.Up)
    
                {
    
                    // Key.Up => zoom out
    
                    return ActiveMapView.ZoomOutFixedAsync(TimeSpan.FromSeconds(1));
    
                }
    
                // Key.Down => zoom in
    
                //else if (k.Key == Key.Down)
    
                {
    
                    return ActiveMapView.ZoomInFixedAsync(TimeSpan.FromSeconds(1));
    
                }
               
    
            }
    
        }
    
    
    }
  • 相关阅读:
    SCRAM
    package-info.java https://www.intertech.com/Blog/whats-package-info-java-for/
    mybatis-3 cache 源码赏析
    Cache replacement policies 缓存实现算法
    MyBatis 强大之处 多环境 多数据源 ResultMap 的设计思想是 缓存算法 跨数据库 spring boot rest api mybaits limit 传参
    Taking a peek inside with the Actuator
    表优化 altering table OPTIMIZE TABLE `sta_addr_copy`
    Why is long2ip conversion important?
    遇到的1/3,在十进位制中是一个无限小数,但在这种进位制中就是一个有限小数。
    并发编程:Actors 模型和 CSP 模型
  • 原文地址:https://www.cnblogs.com/gisoracle/p/12462626.html
Copyright © 2011-2022 走看看