zoukankan      html  css  js  c++  java
  • ArcGIS Pro放大缩小按钮

    /*
    
       Copyright 2019 Esri
    
       Licensed under the Apache License, Version 2.0 (the "License");
       you may not use this file except in compliance with the License.
       You may obtain a copy of the License at
    
           http://www.apache.org/licenses/LICENSE-2.0
    
       Unless required by applicable law or agreed to in writing, software
       distributed under the License is distributed on an "AS IS" BASIS,
       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    
       See the License for the specific language governing permissions and
       limitations under the License.
    
    */
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Input;
    using ArcGIS.Core.Geometry;
    using ArcGIS.Desktop.Framework.Threading.Tasks;
    using ArcGIS.Desktop.Mapping;
    
    namespace MapToolZoom
    {
        internal class MapToolZoomInOut : MapTool
        {
            public MapToolZoomInOut()
            {
            }
    
            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));
                }
            }
        }
    }
  • 相关阅读:
    微信 token ticket jsapi_ticket access_token 获取 getAccessToken get_jsapi_ticket方法
    PHP 日志 记录 函数 支持 数组 对象 新浪 sae 环境 去掉 空格 换行 格式化 输出 数组转字符串
    原生 原始 PHP连接MySQL 代码 参考mysqli pdo
    PHP 数字金额转换成中文大写金额的函数 数字转中文
    使用PHPMailer发送带附件并支持HTML内容的邮件
    设置输出编码格式 header 重定向 执行时间 set_time_limit 错误 报告 级别 error_reporting
    html5 bootstrap pannel table 协议 公告 声明 文书 模板
    指向指针的指针
    二级指针
    c语言:当指针成为参数后
  • 原文地址:https://www.cnblogs.com/gisoracle/p/14498024.html
Copyright © 2011-2022 走看看