ArcGIS Pro SDK (七)编辑 2 启用编辑

ArcGIS Pro SDK (七)编辑 2 启用编辑

目录

  • [ArcGIS Pro SDK (七)编辑 2 启用编辑](#ArcGIS Pro SDK (七)编辑 2 启用编辑)
    • [1 启用编辑](#1 启用编辑)
    • [2 禁用编辑](#2 禁用编辑)

环境:Visual Studio 2022 + .NET6 + ArcGIS Pro SDK 3.0

1 启用编辑

csharp 复制代码
// 如果没有正在编辑
if (!Project.Current.IsEditingEnabled)
{
  var res = MessageBox.Show("You must enable editing to use editing tools. Would you like to enable editing?",
                                                        "Enable Editing?", System.Windows.MessageBoxButton.YesNoCancel);
  if (res == System.Windows.MessageBoxResult.No ||
                res == System.Windows.MessageBoxResult.Cancel)
  {
    return;
  }
  Project.Current.SetIsEditingEnabledAsync(true);
}

2 禁用编辑

csharp 复制代码
// 如果正在编辑
if (Project.Current.IsEditingEnabled)
{
    var res = MessageBox.Show("Do you want to disable editing? Editing tools will be disabled",
                              "Disable Editing?", System.Windows.MessageBoxButton.YesNoCancel);
    if (res == System.Windows.MessageBoxResult.No ||
        res == System.Windows.MessageBoxResult.Cancel)
    {
        return;
    }

    //必须检查编辑
    if (Project.Current.HasEdits)
    {
        res = MessageBox.Show("Save edits?", "Save Edits?", System.Windows.MessageBoxButton.YesNoCancel);
        if (res == System.Windows.MessageBoxResult.Cancel)
        {
            return;
        }
        else if (res == System.Windows.MessageBoxResult.No)
        {
            Project.Current.DiscardEditsAsync();
        }
        else
        {
            Project.Current.SaveEditsAsync();
        }
    }
    Project.Current.SetIsEditingEnabledAsync(false);
}
相关推荐
csdn_aspnet8 小时前
C# (QuickSort using Random Pivoting)使用随机枢轴的快速排序
数据结构·算法·c#·排序算法
游乐码14 小时前
c#lambad表达式
开发语言·c#
一念春风15 小时前
Qwen2.5 (AI模型 PC搭建)
人工智能·ai·c#·wpf·模型
~plus~17 小时前
C# 事件溯源与 CQRS 架构:用 EventStoreDB 打造可靠系统
开发语言·架构·c#
aq553560017 小时前
Laravel7.x重磅升级:十大新特性解析
开发语言·汇编·c#·html
唐青枫19 小时前
C#.NET Mapperly 深入解析:源生成映射、安装使用与工程化取舍
c#·.net
大空大地202620 小时前
Windows打印技术和网络编程技术
c#
xiaoshuaishuai81 天前
C# 实现Workstation相关功能
开发语言·windows·c#
游乐码1 天前
c#Lsit排序
开发语言·c#
hard_coding_wang1 天前
了解一个Excel批量替换的公式用法:REDUCE + LAMBDA 实现循环替换
开发语言·c#·excel