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.pswp.cn/diannao/35083.shtml
繁體地址,請注明出處:http://hk.pswp.cn/diannao/35083.shtml
英文地址,請注明出處:http://en.pswp.cn/diannao/35083.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

極速安裝的藝術:使用 Mamba 革新你的 Conda 環境管理

標題&#xff1a;極速安裝的藝術&#xff1a;使用 Mamba 革新你的 Conda 環境管理 引言 在數據科學和機器學習領域&#xff0c;Conda 是一個廣受歡迎的包管理器和環境管理器。然而&#xff0c;隨著項目規模的增長&#xff0c;Conda 在處理大量依賴時可能會顯得緩慢。Mamba&am…

水下機器人ArduSub 固件常用參數

目前最新版的ArduSub 固件是4.1.2&#xff0c;本文的參數是基于這個版本的固件 SURFACE_DEPTH&#xff1a;水表深度讀數 當水下機器人在水面時&#xff0c;水壓傳感器將讀取的深度數據&#xff08;以厘米為單位&#xff09;&#xff0c;這個相當于抵消零偏 單位&#xff1a;…

ArcGIS批量設置多圖層的三調地類符號

?? 點擊下方全系列課程學習 點擊學習—>ArcGIS全系列實戰視頻教程——9個單一課程組合系列直播回放 01需求說明 這次我們要實現的是將多個地類圖層批量符號化。比如將多個三調地類圖斑批量符號化。 ? 有什么好方法呢 &#xff1f; 我們可以將一個圖層利用三調符號庫進行…

android 從應用中打開第三方應用

打開第三方應用之前需要先判斷該應用是否存在&#xff0c;代碼如下&#xff1a; public boolean isAppInstalled(Context context, String packageName) {PackageManager packageManager context.getPackageManager();try {packageManager.getPackageInfo(packageName, Packa…

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;聯合開源…

chmod,chown命令

一.chmod命令 1.chmod命令的作用 我們使用chmod命令來修改文件和文件夾的權限信息&#xff08;只有文件和文件夾的所屬用戶和root用戶可以修改該文件或文件夾的權限信息&#xff09; 2.chmod命令的語法 chmod [-R] 我們將要賦予用戶/用戶組/其他用戶的權限 要修改的文件/文件…

SpringBoot實現定時任務的動態停止和更新

目錄 定時任務管理器定時任務的任務接口定時任務和定時任務結果的緩存對象定時任務使用姿勢 定時任務管理器 負責啟動一個定時任務、停止一個定時任務、更新一個定時任務 /*** 定時任務管理器* 1、創建并啟動一個定時任務* 2、停止一個定時任務* 3、更新一個定時任務*/ publi…

Mybatis-plus學習|性能分析插件、條件構造器、代碼自動生成器

性能分析插件 我們在平時的開發中&#xff0c;會遇到一些慢sql。測試!druid…. MP也提供性能分析插件&#xff0c;如果超過這個時間就停止運行! 1、導入插件 該插件只允許在開發和測試環境中使用&#xff0c;故先設置開發環境為開發模式 在MP配置類中注冊這個插件&#xff0…

【Python機器學習】數據表示和特征工程的一些概念

對于由浮點數組成的二維數據&#xff0c;其中每一列是描述數據點的連續特征。 對于很多應用來說&#xff0c;數據的收集方式并不是這樣&#xff0c;一種特別常見的特征類型就是分類特征&#xff0c;也叫離散特征&#xff0c;這種特征通常不是說數值。 分類特征和連續特征之間…

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…