ArcGIS Pro SDK (三)Addin控件 3 事件功能类

22 ArcGIS Pro 放置处理程序

目录

    • 22 ArcGIS Pro 放置处理程序
      • 22.1 添加控件
      • 22.2 Code
    • 23 ArcGIS Pro 构造工具
      • 23.1 添加控件
      • 23.2 Code
    • 24 ArcGIS Pro 表构造工具
      • 24.1 添加控件
      • 24.2 Code

22.1 添加控件

image-20240605102400652

image-20240605102500388

image-20240605102627851

22.2 Code

放置处理程序可以实现文件拖动放置、TreeVIew、ListBox等控件拖动放置功能,此处新建一个停靠窗并添加一个TreeVIew,实现节点拖动事件;

TestDropHandlerDockpane.xaml

<UserControlx:Class="WineMonk.Demo.ProAppModule.Code21_DropHandler.Dockpanes.TestDropHandlerDockpaneView"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:extensions="clr-namespace:ArcGIS.Desktop.Extensions;assembly=ArcGIS.Desktop.Extensions"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:ui="clr-namespace:WineMonk.Demo.ProAppModule.Code21_DropHandler.Dockpanes"d:DataContext="{Binding Path=ui.TestDropHandlerDockpaneViewModel}"d:DesignHeight="300"d:DesignWidth="300"mc:Ignorable="d"><UserControl.Resources><ResourceDictionary><ResourceDictionary.MergedDictionaries><extensions:DesignOnlyResourceDictionary Source="pack://application:,,,/ArcGIS.Desktop.Framework;component\Themes\Default.xaml" /></ResourceDictionary.MergedDictionaries></ResourceDictionary></UserControl.Resources><Grid><Grid.RowDefinitions><RowDefinition Height="Auto" /><RowDefinition Height="*" /></Grid.RowDefinitions><DockPanelGrid.Row="0"Height="30"KeyboardNavigation.TabNavigation="Local"LastChildFill="true"><TextBlock Style="{DynamicResource Esri_TextBlockDockPaneHeader}" Text="{Binding Heading}"><TextBlock.ToolTip><WrapPanel MaxWidth="300" Orientation="Vertical"><TextBlock Text="{Binding Heading}" TextWrapping="Wrap" /></WrapPanel></TextBlock.ToolTip></TextBlock></DockPanel><TreeViewGrid.Row="1"AllowDrop="False"MouseMove="TreeView_MouseMove"PreviewMouseLeftButtonDown="TreeView_PreviewMouseLeftButtonDown"><TreeViewItem AllowDrop="False" Header="资源目录"><TreeViewItem AllowDrop="False" Header="矢量"><TreeViewItemAllowDrop="True"Header="行政区划数据"Tag="C:\\xzqh.shp" /></TreeViewItem><TreeViewItem AllowDrop="False" Header="栅格"><TreeViewItemAllowDrop="True"Header="行政区正射影像"Tag="C:\\xzq.tif" /></TreeViewItem></TreeViewItem></TreeView></Grid>
</UserControl>

TestDropHandlerDockpaneViewModel.cs

using ArcGIS.Desktop.Framework;
using ArcGIS.Desktop.Framework.Contracts;namespace WineMonk.Demo.ProAppModule.Code21_DropHandler.Dockpanes
{internal class TestDropHandlerDockpaneViewModel : DockPane{private const string _dockPaneID = "WineMonk_Demo_ProAppModule_Code21_DropHandler_Dockpanes_TestDropHandlerDockpane";protected TestDropHandlerDockpaneViewModel() { }/// <summary>/// Show the DockPane./// </summary>internal static void Show(){DockPane pane = FrameworkApplication.DockPaneManager.Find(_dockPaneID);if (pane == null)return;pane.Activate();}/// <summary>/// Text shown near the top of the DockPane./// </summary>private string _heading = "My DockPane";public string Heading{get { return _heading; }set{SetProperty(ref _heading, value, () => Heading);}}}/// <summary>/// Button implementation to show the DockPane./// </summary>internal class TestDropHandlerDockpane_ShowButton : Button{protected override void OnClick(){TestDropHandlerDockpaneViewModel.Show();}}
}

DropHandlerTest.cs

using ArcGIS.Desktop.Framework.Contracts;
using ArcGIS.Desktop.Framework.DragDrop;
using System;
using System.Windows;namespace WineMonk.Demo.ProAppModule.Code21_DropHandler
{internal class DropHandlerTest : DropHandlerBase{public override void OnDragOver(DropInfo dropInfo){//default is to accept our data typesdropInfo.Effects = DragDropEffects.All;}public override void OnDrop(DropInfo dropInfo){//eg, if you are accessing a dropped file//string filePath = dropInfo.Items[0].Data.ToString();if (dropInfo.Items == null || dropInfo.Items.Count < 1){return;}DropDataItem dropDataItem = dropInfo.Items[0];object data = dropDataItem.Data;if (data == null){return;}if (data is DataObject dataObject){string[] formats = dataObject.GetFormats();if (formats == null || formats.Length < 1){return;}string msg = string.Empty;foreach (string f in formats){object subData = dataObject.GetData(f);msg += $"{Environment.NewLine}{f}: {subData}";}ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show($"接收到数据:{msg}");dropInfo.Handled = true;}//set to true if you handled the drop//dropInfo.Handled = true;}}
}

Config.daml

<modules><insertModule id="WineMonk_Demo_ProAppModule_Module" className="Module1" autoLoad="false" caption="Module1"><groups><!-- comment this out if you have no controls on the Addin tab to avoid an empty group --><!-- 如果您没有插件选项卡上的控件,请将其注释掉,以避免出现空组 --><group id="WineMonk_Demo_ProAppModule_Group3" caption="Group 3" appearsOnAddInTab="false"><button refID="WineMonk_Demo_ProAppModule_Code21_DropHandler_Dockpanes_TestDropHandlerDockpane_ShowButton" size="large" /></group></groups><controls><!-- add your controls here --><!-- 在这里添加控件 --><button id="WineMonk_Demo_ProAppModule_Code21_DropHandler_Dockpanes_TestDropHandlerDockpane_ShowButton" caption="Show TestDropHandlerDockpane" className="WineMonk.Demo.ProAppModule.Code21_DropHandler.Dockpanes.TestDropHandlerDockpane_ShowButton" loadOnClick="true" smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonPurple16.png" largeImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonPurple32.png"><tooltip heading="Show Dockpane">Show Dockpane<disabledText /></tooltip></button></controls><dockPanes><dockPane id="WineMonk_Demo_ProAppModule_Code21_DropHandler_Dockpanes_TestDropHandlerDockpane" caption="TestDropHandlerDockpane" className="WineMonk.Demo.ProAppModule.Code21_DropHandler.Dockpanes.TestDropHandlerDockpaneViewModel" dock="group" dockWith="esri_core_projectDockPane"><content className="WineMonk.Demo.ProAppModule.Code21_DropHandler.Dockpanes.TestDropHandlerDockpaneView" /></dockPane></dockPanes></insertModule>
</modules>
<dropHandlers><!--specific file extensions can be set like so: dataTypes=".XLS|.xls"--><insertHandler id="WineMonk_Demo_ProAppModule_Code21_DropHandler_DropHandlerTest" className="WineMonk.Demo.ProAppModule.Code21_DropHandler.DropHandlerTest" dataTypes="*" />
</dropHandlers>

23 ArcGIS Pro 构造工具

23.1 添加控件

image-20240605113928001

image-20240605114003342

image-20240605113851867

23.2 Code

ConstructionToolTest.cs

using ArcGIS.Core.Geometry;
using ArcGIS.Desktop.Editing;
using ArcGIS.Desktop.Framework;
using ArcGIS.Desktop.Mapping;
using System.Threading.Tasks;namespace WineMonk.Demo.ProAppModule.Code22_ConstructionTool
{internal class ConstructionToolTest : MapTool{public ConstructionToolTest(){IsSketchTool = true;UseSnapping = true;// Select the type of construction tool you wish to implement.  // Make sure that the tool is correctly registered with the correct component category type in the daml SketchType = SketchGeometryType.Point;// SketchType = SketchGeometryType.Line;// SketchType = SketchGeometryType.Polygon;//Gets or sets whether the sketch is for creating a feature and should use the CurrentTemplate.UsesCurrentTemplate = true;//Gets or sets whether the tool supports firing sketch events when the map sketch changes. //Default value is false.FireSketchEvents = true;}/// <summary>/// Called when the sketch finishes. This is where we will create the sketch operation and then execute it./// </summary>/// <param name="geometry">The geometry created by the sketch.</param>/// <returns>A Task returning a Boolean indicating if the sketch complete event was successfully handled.</returns>protected override Task<bool> OnSketchCompleteAsync(Geometry geometry){if (CurrentTemplate == null || geometry == null)return Task.FromResult(false);// Create an edit operationvar createOperation = new EditOperation();createOperation.Name = string.Format("Create {0}", CurrentTemplate.Layer.Name);createOperation.SelectNewFeatures = true;// Queue feature creationcreateOperation.Create(CurrentTemplate, geometry);// Execute the operationNotification notification = new Notification();notification.Title = "绘制";notification.Message = $"绘制图层{CurrentTemplate.Layer.Name}点要素...";FrameworkApplication.AddNotification(notification);return createOperation.ExecuteAsync();}}
}

Config.daml

<modules><insertModule id="WineMonk_Demo_ProAppModule_Module" className="Module1" autoLoad="false" caption="Module1"><controls><!-- add your controls here --><!-- 在这里添加控件 --><tool id="WineMonk_Demo_ProAppModule_Code22_ConstructionTool_ConstructionToolTest" categoryRefID="esri_editing_construction_point" caption="ConstructionToolTest" className="WineMonk.Demo.ProAppModule.Code22_ConstructionTool.ConstructionToolTest" loadOnClick="true" smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonRed16.png" largeImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonRed32.png"><!-- note: use esri_editing_construction_polyline,  esri_editing_construction_polygon for categoryRefID as needed --><!-- esri_editing_construction_annotationesri_editing_construction_dimensionesri_editing_construction_knowledge_graph_entityesri_editing_construction_knowledge_graph_relationshipesri_editing_construction_multipatchesri_editing_construction_multipointesri_editing_construction_pointesri_editing_construction_polygonesri_editing_construction_polylineesri_editing_construction_table --><tooltip heading="Tooltip Heading">Tooltip text<disabledText /></tooltip><content guid="cdfdb0f2-c229-458e-bac8-5a638cd98bb3" /></tool></controls></insertModule>
</modules>

24 ArcGIS Pro 表构造工具

24.1 添加控件

image-20240605114718537

image-20240605114949930

image-20240605115730930

24.2 Code

TableConstructionToolTest.cs

using ArcGIS.Core.Geometry;
using ArcGIS.Desktop.Editing;
using ArcGIS.Desktop.Framework;
using ArcGIS.Desktop.Mapping;
using System.Threading.Tasks;namespace WineMonk.Demo.ProAppModule.Code23_TableConstructionTool
{internal class TableConstructionToolTest : MapTool{public TableConstructionToolTest(){IsSketchTool = false;// set the SketchType to NoneSketchType = SketchGeometryType.None;//Gets or sets whether the sketch is for creating a feature and should use the CurrentTemplate.UsesCurrentTemplate = true;}/// <summary>/// Called when the "Create" button is clicked. This is where we will create the edit operation and then execute it./// </summary>/// <param name="geometry">The geometry created by the sketch - will be null because SketchType = SketchGeometryType.None</param>/// <returns>A Task returning a Boolean indicating if the sketch complete event was successfully handled.</returns>protected override Task<bool> OnSketchCompleteAsync(Geometry geometry){if (CurrentTemplate == null)return Task.FromResult(false);// geometry will be null// Create an edit operationvar createOperation = new EditOperation();createOperation.Name = string.Format("Create {0}", CurrentTemplate.StandaloneTable.Name);createOperation.SelectNewFeatures = false;// determine the number of rows to addvar numRows = this.CurrentTemplateRows;for (int idx = 0; idx < numRows; idx++)// Queue feature creationcreateOperation.Create(CurrentTemplate, null);// Execute the operationNotification notification = new Notification();notification.Title = "添加行";notification.Message = $"添加表{CurrentTemplate.MapMember.Name}行...";FrameworkApplication.AddNotification(notification);return createOperation.ExecuteAsync();}}
}

Config.daml

<modules><insertModule id="WineMonk_Demo_ProAppModule_Module" className="Module1" autoLoad="false" caption="Module1"><controls><!-- add your controls here --><!-- 在这里添加控件 --><tool id="WineMonk_Demo_ProAppModule_Code23_TableConstructionTool_TableConstructionToolTest" categoryRefID="esri_editing_construction_table" caption="TableConstructionToolTest" className="WineMonk.Demo.ProAppModule.Code23_TableConstructionTool.TableConstructionToolTest" loadOnClick="true" smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonRed16.png" largeImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonRed32.png"><tooltip heading="Tooltip Heading">Tooltip text<disabledText /></tooltip><content guid="a3d2b675-374a-44c1-be88-e0991cc7fe39" /></tool></controls></insertModule>
</modules>   

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/35083.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

ArcGIS批量设置多图层的三调地类符号

​​ 点击下方全系列课程学习 点击学习—>ArcGIS全系列实战视频教程——9个单一课程组合系列直播回放 01需求说明 这次我们要实现的是将多个地类图层批量符号化。比如将多个三调地类图斑批量符号化。 ​ 有什么好方法呢 &#xff1f; 我们可以将一个图层利用三调符号库进行…

Stable Diffusion 3 正式开源,超强文生图模型 SD3-M 上线,赶紧来试试吧!

前言 我们都知道 Stable Diffusion 3 是一款强大的文生图模型&#xff0c;拥有20亿参数&#xff0c;因其高效的推理速度和卓越的生成效果而备受瞩目。 近日&#xff0c;Stability AI在推特上宣布正式开源了 Stable Diffusion 3 Medium&#xff08;SD3-M&#xff09; 权重&…

Dooprime外汇:如何高效规划家庭理财?从哪里开始?

摘要&#xff1a; 家庭理财是每个家庭都必须面对的重要课题。合理的理财规划不仅能提高家庭的生活质量&#xff0c;还能为未来的生活提供保障。然而&#xff0c;许多人在面对复杂的理财选项和信息时感到无从下手。本文将从不同角度详细分析如何进行高效的家庭理财规划&#xf…

【Playwright+Python】手把手带你写一个自动化测试脚本

如何使用代理方式打开网页 在 playwright.chromium.launch() 中传入 proxy 参数即可&#xff0c;示例代码如下&#xff1a; 1、同步写法&#xff1a; from playwright.sync_api import sync_playwrightproxy {server: http:/127.0.0.1:8080}def run():with sync_playwright(…

Kafka精要

Apach Kafka 是一款分布式流处理框架&#xff0c;用于实时构建流处理应用。它有一个核心 的功能广为人知&#xff0c;即 作为企业级的消息引擎被广泛使用 kafka设计 Kafka 将消息以 topic 为单位进行归纳 将向 Kafka topic 发布消息的程序成为 producers. 将预订 topics 并消…

Linux内核开发-编写一个proc文件

0.前言 上一章&#xff08;点击返回上一章&#xff09;完成了一个内核模块的编写&#xff0c;实现了在内核运行时的动态加载和卸载。 在模块的开发调测过程中或者模块运行过程中&#xff0c;可能需要打印内核模块的变量的值或者想要动态开关模块的运行日志打印&#xff0c;那么…

小盒子跑大模型!基于算能BM1684X+FPGA平台实现大模型私有化部署

当前&#xff0c;在人工智能领域&#xff0c;大模型在丰富人工智能应用场景中扮演着重要的角色&#xff0c;经过不断的探索&#xff0c;大模型进入到落地的阶段。而大模型在落地过程中面临两大关键难题&#xff1a;对庞大计算资源的需求和对数据隐私与安全的考量。为应对这些挑…

springcloud-gateway include-expression 配置说明

在开发过程中遇到的一些配置问题&#xff0c;记录下来以供参考 spring-gateway版本是2.2.9-release,使用的spring cloud dependence 是 Hoxton.SR12 在依赖eureka 服务发现并自动将发现服务器加入到router中的时候&#xff0c;需要指定对应的服务进行添加&#xff0c;根据文档…

postman国内外竞争者及使用详解分析

一、postman简介 Postman 是一款广泛使用的 API 开发和测试工具&#xff0c;适用于开发人员和测试人员。它提供了一个直观的界面&#xff0c;用于发送 HTTP 请求、查看响应、创建和管理 API 测试用例&#xff0c;以及自动化 API 测试工作流程。以下是 Postman 的主要功能和特点…

linux的CP指令

实现 CP 指令 src 源文件 des 目标文件 执行流程&#xff1a; 打开源文件&#xff08; src &#xff09; open 打开目标文件&#xff08; des &#xff09; open 写入目标文件 write 读取 src 文件到缓存数组 read 关闭目标文件和源文件 close ./a.out src.c de…

开源网安参与编制的《代码大模型安全风险防范能力要求及评估方法》正式发布

​代码大模型在代码生成、代码翻译、代码补全、错误定位与修复、自动化测试等方面为研发人员带来了极大便利的同时&#xff0c;也带来了对安全风险防范能力的挑战。基于此&#xff0c;中国信通院依托中国人工智能产业发展联盟&#xff08;AIIA&#xff09;&#xff0c;联合开源…

Mybatis-plus学习|性能分析插件、条件构造器、代码自动生成器

性能分析插件 我们在平时的开发中&#xff0c;会遇到一些慢sql。测试!druid…. MP也提供性能分析插件&#xff0c;如果超过这个时间就停止运行! 1、导入插件 该插件只允许在开发和测试环境中使用&#xff0c;故先设置开发环境为开发模式 在MP配置类中注册这个插件&#xff0…

Python:浅谈迭代器、生成器与协程的演化路径

“人生苦短&#xff0c;我用Python”&#xff0c;虽然说大量数学和统计分析库是一个重要优势&#xff0c;但是归根结底&#xff0c;Python的最大优势就是三点&#xff1a; 但是通常一般来讲&#xff0c;当扯到并发的时候&#xff0c;无论是多服务器、多进程、多线程、还是协程&…

C# SocketUDP服务器,组播

SocketUDP 自己即是服务器又是客户端 &#xff0c;在发消息只需要改成对方ip和端口号即可 前提对方必须开启服务器 socket.Bind(new IPEndPoint(IPAddress.Parse("192.168.107.72"), 8080)); 控件&#xff1a;Button,TextBox,RichTextBox 打开自己服务器 public…

【操作系统】信号处理与阻塞函数|时序竞态问题

&#x1f525;博客主页&#xff1a; 我要成为C领域大神&#x1f3a5;系列专栏&#xff1a;【C核心编程】 【计算机网络】 【Linux编程】 【操作系统】 ❤️感谢大家点赞&#x1f44d;收藏⭐评论✍️ 本博客致力于知识分享&#xff0c;与更多的人进行学习交流 ​ 关于阻塞函数和…

Windows环境部署MySQL_8.4.0 LTS的部署安装、验证连接以及卸载全过程实操手册

前言&#xff1a; 什么是 MySQL MySQL 是一个关系型数据库管理系统&#xff0c;由瑞典 MySQL AB 公司开发&#xff0c;目前属于Oracle 公司。MySQL 是一种关系型数据库管理系统&#xff0c;关系型数据库将数据保存在不同的表中&#xff0c;而不是将所有数据放在一个大仓库内&am…

8.12 矢量图层面要素单一符号使用七(随机标记填充)

文章目录 前言随机标记填充&#xff08;Random Marker Fill&#xff09;QGis设置面符号为随机标记填充&#xff08;Random Marker Fill&#xff09;二次开发代码实现随机标记填充&#xff08;Random Marker Fill&#xff09; 总结 前言 本章介绍矢量图层线要素单一符号中使用随…

分班查询怎么发布?

在现代教育环境中&#xff0c;传统的学生分班通知方式可能显得有些过时和低效。通常&#xff0c;这些方式依赖于纸质通知单&#xff0c;这不仅需要大量的物理资源进行打印和分发&#xff0c;而且容易出错&#xff0c;如丢失、错误分发或延迟。 幸运的是&#xff0c;现在有了更高…

心灵馆咨询系统小程序心理咨询平台聊天咨询

心灵馆咨询系统小程序&#xff1a;解锁你的心灵密码 &#x1f496; 心灵之旅的导航者 在繁忙的现代生活中&#xff0c;我们时常会面临各种压力与困惑。心灵馆咨询系统小程序&#xff0c;如同一位贴心的导航者&#xff0c;引领我们探索内心的世界&#xff0c;寻找真正的自我。 …