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);
}
相关推荐
科研online8 分钟前
ArcGIS Pro三维空间分析、专题制图、遥感制图全流程系统教学
arcgis
如影随从11 分钟前
04-ArcGIS For JavaScript的可视域分析功能
开发语言·javascript·arcgis·可视域分析
界面开发小八哥1 小时前
DevExpress WPF中文教程:Grid - 如何显示摘要(设计时)?
ui·c#·wpf·界面控件·devexpress
danielli2 小时前
C# winform中权限页面的设计和开发
开发语言·c#
WineMonk3 小时前
ArcGIS Pro SDK (七)编辑 6 检查器
arcgis·c#·gis·arcgis pro sdk
望天hous3 小时前
C#中关于表达式的构建示例,备忘
开发语言·数据库·c#
※※冰馨※※5 小时前
C# Queue、List、LinkedList 性能对比
开发语言·c#
香煎三文鱼5 小时前
C#实现根据指定运算符进行比较值,如>、>=、<、<=、==
c#·c#自定义运算符比较
WineMonk9 小时前
.NET C# 使用GDAL将mdb转换gdb数据
c#·.net·gis·gdb·gdal·mdb
code_shenbing13 小时前
上位机网络通讯
前端·数据库·ui·c#·winform