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);
}
相关推荐
阿蒙Amon36 分钟前
C#数字金额转中文大写金额:代码解析
java·mysql·c#
程序猿多布2 小时前
C# 密封类和密封方法
c#
nuclear20113 小时前
使用C# 快速删除Excel表格中的重复行数据-详解
c#·excel·删除excel重复行·删除excel重复数据·excel重复行查找并删除
FuckPatience7 小时前
UI 资源整合
ui·c#
庄小焱7 小时前
设计模式——面向对象设计六大原则
数据库·windows·c#
江沉晚呤时8 小时前
深入解析 Dotnet-Boxed.Framework:提升 .NET 开发效率的利器
深度学习·c#·.net·.netcore
小小弯_Shelby10 小时前
arcgis js 4.x 的geometryEngine计算距离、面积、缓冲区等报错、失败
arcgis
专注VB编程开发20年14 小时前
vb.net oledb-Access 数据库本身不支持命名参数,赋值必须和参数顺序一致才行
数据库·c#·.net·vb.net·oledb
Hare_bai15 小时前
WPF响应式UI的基础:INotifyPropertyChanged
ui·c#·wpf·xaml
Hare_bai15 小时前
WPF的布局核心:网格布局(Grid)
ui·c#·wpf·交互·xaml