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);
}
相关推荐
Risehuxyc14 小时前
HttpClient怎么传POST参数
c#
zdr尽职尽责4 天前
UnityCli 兼容2022版本
ui·unity·ai·c#·游戏引擎
BruceNeter6 天前
C# winform卡死问题分析1——线程池子线程创建句柄
c#·.net
行者-全栈开发6 天前
【供应链攻击】CVE-2026-45321:TanStack供应链攻击漏洞深度解析与修复指南
arcgis
何以解忧唯有撸码7 天前
开源】当桌面图标开始打台球:我用 WinForms 做了一桌“真的”台球
c#·winform·自定义控件·gdi
思特奇时空智能8 天前
大规模点要素地图渲染性能优化实践
vue.js·arcgis·性能优化·node.js·html·gis·webgl
国家一级摸鱼选手8 天前
[Unity]几何碰撞检测:SAT 分离轴定理详解(从数学原理到 C# 实现)
unity·c#·游戏引擎·分离轴定理(sat)·多边形相交
汤姆宝库8 天前
BPE分词器的完整实现:字节对合并与词表构建
开发语言·人工智能·c#
Risehuxyc8 天前
C# 发展历史
开发语言·c#
kyle~8 天前
C# --- 反射
开发语言·c#