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);
}
相关推荐
武藤一雄21 小时前
C# 引用传递:深度解析 ref 与 out
windows·microsoft·c#·.net·.netcore
bugcome_com1 天前
C# 高级集合使用示例
开发语言·c#
Mao_Hui1 天前
Unity3d实时读取Modbus RTU数据
开发语言·嵌入式硬件·unity·c#
njsgcs1 天前
怎么把面的类型特征,平面曲面融合进面邻接图或者图结构里
c#
GISBox1 天前
GISBox 2.1.7 版本更新:新增批量矢量导入功能,多项问题修复
gis·cesium·属性表·矢量·gisbox·场景编辑·切片转换
爱炸薯条的小朋友1 天前
C#依赖注入和仿写Prism注入
开发语言·c#
末点1 天前
超长文本格式坐标串数据空间化入库
数据库·c#·st_geomfromtext
GIS阵地1 天前
一场由Qt5 painter的drawRect引起的血雨腥风
开发语言·qt·gis·qgis
csdn_aspnet1 天前
使用 C# 和 Microsoft Agent Framework 构建 AI 代理
人工智能·microsoft·ai·c#·.net·agent·ai agent