• 博客园logo
  • 会员
  • 周边
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

gisoracle

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

ArcGIS Pro 删除记录时提示

protected override void OnClick()
        {

            QueuedTask.Run(() =>
            {
                Table table = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault().GetTable();
                RowDeletedEvent.Subscribe(OnRowDeletedEvent, table);
            });

        }
        private static Guid _lastEdit = Guid.Empty;
        private static void OnRowDeletedEvent1(RowChangedEventArgs obj)
        {
            if (_lastEdit != obj.Guid)
            {
                //cancel with dialog
                // Note - feature edits on Hosted and Standard Feature Services cannot be cancelled.
                obj.CancelEdit("Delete Event\nAre you sure", true);
                _lastEdit = obj.Guid;
            }
        }

        public static long CurrentlyDeletingOID = 0;
        protected static void OnRowDeletedEvent(RowChangedEventArgs args)
        {
            try
            {
                long _deletingOID = args.Row.GetObjectID();
                if (CurrentlyDeletingOID != _deletingOID)
                {
                    MessageBoxResult mbr = ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(
                        "Are you sure you want to Delete this Feature?",
                        "Confirm Delete",
                        MessageBoxButton.YesNo, MessageBoxImage.Warning);

                    if (mbr == MessageBoxResult.Yes)
                    {
                        //PROCEED with the delete
                        args.CancelEdit(() => Task.FromResult(true));

                        //Need to set this so that the code doesn't get stuck in loop, no need to reset
                        CurrentlyDeletingOID = _deletingOID;
                    }
                    else
                    {
                        //CANCEL the Delete
                        args.CancelEdit(() => Task.FromResult(false));
                    }

                    //cancel with dialog using ESRI commands
                    //args.CancelEdit("Delete Event\nAre you sure", true);

                }
            }

            catch (Exception e)
            {
                //logError("onRowDeleteEvent", e);
            }
        }

 

posted on 2022-03-22 11:21  gisai  阅读(91)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3