乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 100|回复: 5

无法通过我的自定义面板创建图层?

[复制链接]

13

主题

20

帖子

4

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
72
发表于 2017-9-25 22:07:12 | 显示全部楼层 |阅读模式
我用一个按钮创建了一个面板,当我单击该按钮时,它将调用一个命令来创建图层和线型,但autocad总是提示我一个“eLockViolation”错误。
如果我不使用panel,代码将正确创建图层和线型。
  1. public class Command
  2.     {
  3.         static PaletteSet palette;
  4.         static bool wasVisible;
  5.         ///
  6.         /// Creates the palette if it did not already exist, and shwos it.
  7.         ///
  8.         [CommandMethod("test" )]
  9.         public static void CreateGridPanel()
  10.         {
  11.             if (palette == null)
  12.             {
  13.                 palette = new PaletteSet("CaiGrid", "CONVPALETTE", new Guid("{929CAC46-8606-4580-A953-238B70CA76A1}"));
  14.                 palette.Style =
  15.                     PaletteSetStyles.ShowAutoHideButton |
  16.                     PaletteSetStyles.ShowCloseButton |
  17.                     PaletteSetStyles.ShowPropertiesMenu;
  18.                 palette.MinimumSize = new System.Drawing.Size(410, 240);
  19.                 palette.AddVisual("CaiGrid", new GridView());
  20.                 // Automatically hides the palette while there is no active document.
  21.                 var docs = Application.DocumentManager;
  22.                 docs.DocumentBecameCurrent += (s, e) => palette.Visible = e.Document == null ? false : wasVisible;
  23.                 docs.DocumentCreated += (s, e) => palette.Visible = wasVisible;
  24.                 docs.DocumentToBeDeactivated += (s, e) => wasVisible = palette.Visible;
  25.                 docs.DocumentToBeDestroyed += (s, e) =>
  26.                 {
  27.                     wasVisible = palette.Visible;
  28.                     if (docs.Count == 1)
  29.                         palette.Visible = false;
  30.                 };
  31.             }
  32.             palette.Visible = true;
  33.         }
  34. }

本帖以下内容被隐藏保护;需要你回复后,才能看到!

游客,如果您要查看本帖隐藏内容请回复
回复

使用道具 举报

57

主题

559

帖子

13

银币

中流砥柱

Rank: 25

铜币
786
发表于 2017-9-25 22:47:04 | 显示全部楼层

调查
文档。LockDocument()<br>和google<strong>ElockDocument</strong><br>https://www.google.com.au/search?q=elockviolation+AutoCad
回复

使用道具 举报

13

主题

20

帖子

4

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
72
发表于 2017-9-25 22:56:21 | 显示全部楼层
谢谢kdub,现在工作了。
我想知道是否所有的非模态winform或panel都需要锁定文档?
回复

使用道具 举报

15

主题

687

帖子

169

银币

中流砥柱

Rank: 25

铜币
582
发表于 2017-9-26 01:25:06 | 显示全部楼层
你好,
来自Kean Walmsley的博客:
回复

使用道具 举报

129

主题

422

帖子

5

银币

中流砥柱

Rank: 25

铜币
936
发表于 2017-9-27 02:37:23 | 显示全部楼层

如何“手动”锁定文档?
回复

使用道具 举报

15

主题

687

帖子

169

银币

中流砥柱

Rank: 25

铜币
582
发表于 2017-9-27 02:50:35 | 显示全部楼层
文档文档=Application.DocumentManager.MdiActiveDocument;。
如果(doc!=null)。
{。
使用(doc.LockDocument())。
{。
//您可以在这里安全地使用doc。
}。
}。
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-4-29 05:08 , Processed in 1.404246 second(s), 64 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表