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);
}
相关推荐
三*一8 小时前
Mapbox GL JS 自研面要素整形工具开发实录
开发语言·javascript·arcgis·ecmascript
qq_431280709 小时前
上位与基恩士PLC通讯工作记录
c#
weixin_4280053012 小时前
C#调用 AI学习从0开始-第1阶段(基础与工具)-第2天Prompt工程基础
人工智能·学习·c#·prompt
咩图14 小时前
WPF-VisualStudio-C#-Fluent.Ribbon8.0.0学习
c#·wpf·visual studio
加号314 小时前
【C#】WPF基于Halcon 的HWindowControlWPF 控件实现图像缩放、移动
开发语言·c#·wpf
雪豹阿伟15 小时前
2.C# —— 结构体、类型转换与运算符
c#·上位机
qq_3813385016 小时前
前端状态管理新范式:Zustand、Jotai 与 Preact Signals 深度对比
前端·arcgis
njsgcs17 小时前
c# solidworks GetPartBox无法获得正确实体边界框原因
开发语言·c#·solidworks
rockey62717 小时前
AScript之匿名类型与动态类型
c#·.net·script·eval·expression·动态脚本
99乘法口诀万物皆可变18 小时前
BMS HIL 自动化测试框架方案(基于 CANoe + C# + Excel)
开发语言·c#·excel