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);
}
相关推荐
ccut 第一混5 小时前
c# 调用basler 相机
c#·halcon·basler
TomCode先生5 小时前
c#动态树形表达式详解
开发语言·c#
上位机付工14 小时前
C#与倍福TwinCAT3进行ADS通信
开发语言·c#
土了个豆子的15 小时前
02.继承MonoBehaviour的单例模式基类
开发语言·visualstudio·单例模式·c#·里氏替换原则
疯狂的维修15 小时前
c#中public类比博图
c#·自动化
wanzhong233317 小时前
ArcGIS学习-18 实战-降雨量空间分布插值分析
学习·arcgis
土了个豆子的18 小时前
03.缓存池
开发语言·前端·缓存·visualstudio·c#
xiaowu0801 天前
策略模式-不同的鸭子的案例
开发语言·c#·策略模式
VisionPowerful2 天前
九.弗洛伊德(Floyd)算法
算法·c#
GIS工具-gistools20212 天前
ArcGIS Excalibur 的新功能
人工智能·arcgis