• 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
        {
            private IDisposable _graphic = null;
    
            private CIMLineSymbol _lineSymbol = null;
    
            public MapToolSelect()
            {
    
                IsSketchTool = true;
    
                SketchType = SketchGeometryType.Line; //Sketch a line geometry
    
                SketchOutputMode = SketchOutputMode.Map;
    
            }
    
    
    
            protected override Task OnToolDeactivateAsync(bool hasMapViewChanged)
            {
    
                if (_graphic != null)
    
                    _graphic.Dispose();//Clear out the old overlay
    
                _graphic = null;
    
                return base.OnToolDeactivateAsync(hasMapViewChanged);
    
            }
    
    
    
            /// <summary>
    
            /// Occurs when the tool is activated.
    
            /// </summary>
    
            /// <param name="hasMapViewChanged">A value indicating if the active <see cref="T:ArcGIS.Desktop.Mapping.MapView"/> has changed.</param>
    
            /// <returns>
    
            /// A Task that represents a tool activation event.
    
            /// </returns>
    
            protected async override Task OnToolActivateAsync(bool hasMapViewChanged)
            {
    
                if (_lineSymbol == null)
                {
    
                    _lineSymbol = await Module1.CreateLineSymbolAsync();
    
                }
    
                this.SketchSymbol = _lineSymbol.MakeSymbolReference();
    
            }
    
    
    
            protected override void OnToolMouseDown(MapViewMouseButtonEventArgs e)
            {
    
                if (_graphic != null)
                {
    
                    _graphic.Dispose();//Clear out the old overlay
    
                    _graphic = null;
    
                }
    
                base.OnToolMouseDown(e);
    
            }
    
    
    
            protected async override Task<bool> OnSketchCompleteAsync(Geometry geometry)
            {
    
                _graphic = await this.AddOverlayAsync(geometry, _lineSymbol.MakeSymbolReference());
    
                return true;
    
            }
    
    
    
        }
    
    }
    ==========
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows.Input;
    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;
    
    namespace ProAppModule1
    {
        internal class Module1 : Module
        {
            private static Module1 _this = null;
    
            /// <summary>
            /// Retrieve the singleton instance to this module here
            /// </summary>
            public static Module1 Current
            {
                get
                {
                    return _this ?? (_this = (Module1)FrameworkApplication.FindModule("ProAppModule1_Module"));
                }
            }
    
            #region Overrides
            /// <summary>
            /// Called by Framework when ArcGIS Pro is closing
            /// </summary>
            /// <returns>False to prevent Pro from closing, otherwise True</returns>
            protected override bool CanUnload()
            {
                //TODO - add your business logic
                //return false to ~cancel~ Application close
                return true;
            }
            internal static Task<CIMLineSymbol> CreateLineSymbolAsync()
            {
    
                return QueuedTask.Run(() => {
    
                    var lineStroke = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.RedRGB, 4.0);
    
                    var marker = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.RedRGB, 12, SimpleMarkerStyle.Circle);
    
                    marker.MarkerPlacement = new CIMMarkerPlacementOnVertices()
                    {
    
                        AngleToLine = true,
    
                        PlaceOnEndPoints = true,
    
                        Offset = 0
    
                    };
    
                    return new CIMLineSymbol()
                    {
    
                        SymbolLayers = new CIMSymbolLayer[2] { marker, lineStroke }
    
                    };
    
                });
    
            }
    
    
    
            #endregion Overrides
    
        }
    }
  • 相关阅读:
    启动 Appium 自带模拟器
    Android的一些常用命令提示符(cmd)指令
    Eclipse中没有andriod问题解决方法
    selenium键盘操作
    鼠标事件
    appium运行from appium import webdriver 提示most recent call last
    appium for windows 环境搭建
    python+Eclipse+pydev环境搭建
    nmon和nmon analyser的下载和使用
    Linux下使用NMON监控、分析系统性能
  • 原文地址:https://www.cnblogs.com/gisoracle/p/12464553.html
Copyright © 2020-2023  润新知