简体   繁体   English

AutoCAD .NET API - 中断close pallete / window / user控制命令

[英]AutoCAD .NET API - Interrupting the close pallete/window/user control command

My first post, be gentle! 我的第一篇文章,温柔!

Im developing my own user controls for AutoCAD 2011 and cant for the life of me figure out how to interrupt the close on the User Control and insert my own functions before carrying on with the close. 我正在为AutoCAD 2011开发自己的用户控件,并且在我的生活中无法弄清楚如何在继续关闭之前中断用户控件上的关闭并插入我自己的功能。

Just for clarity here is a capture. 为了清楚起见,这是一个捕获。

http://imgur.com/q1yDU http://imgur.com/q1yDU

Basically before the window closes I need to clear a few of my own layers hidden behind the model space, because if the user can just close the tool and carry on without performing the wipe its going to cause issues eventually when it comes to adding new objects/saving/etc. 基本上在窗口关闭之前,我需要清除隐藏在模型空间后面的一些我自己的层,因为如果用户可以关闭工具并继续执行而不执行擦除,最终会在添加新对象时导致问题/节能/等。 I certainly cant trust a user to click a "Wipe" button on the UC before exiting, thats just asking for trouble. 我当然不能相信用户在退出之前点击UC上的“擦除”按钮,那只是在寻找麻烦。

So my question is: Where am I looking in the API for the code that closes the user control? 所以我的问题是:我在API中查找关闭用户控件的代码?

Acad palettes are not actually closed (disposed) when you click on the 'X' mark. 当您单击“X”标记时,Acad调色板实际上并未关闭(处置)。 They are just hidden. 它们只是隐藏起来。 You might want to try the PaletteState::StateChanged event. 您可能想尝试PaletteState::StateChanged事件。 It might be triggered when you 'close' the palette set. 当您“关闭”调色板集时可能会触发它。 Just register a delegate for that event and see if it is called. 只需为该事件注册一个委托,看看它是否被调用。 Might work. 可能会工作。

* EDIT * Now that I think more about it, you should be able to catch that event by registering a delegate to the Control.VisibleChanged event of your custom control. *编辑*现在我想了更多,你应该能够通过向自定义控件的Control.VisibleChanged事件注册一个委托来捕获该事件。 The one that you add as a child to the PaletteSet. 您作为子项添加到PaletteSet的那个。 That should work. 这应该工作。

This is more of a comment than an answer, but I fear it will end up too big for a comment. 这不仅仅是一个评论,而是一个答案,但我担心它最终会因评论而过大。 Here's some food for thought. 这里有一些值得思考的东西。 I'll try to be as gentle as I can but I'm not known among those who know me for my gentleness.... ;) 我会尽量保持温柔,但在那些因我的温柔而认识我的人中我并不为人所知。

I'm worried that you're going about this in a... less-than-ideal way architecturally. 我担心你会以一种不那么理想的方式来解决这个问题。 Your question suggests that you want the user to perform a modal operation (command - show dialog - do stuff with dialog - close dialog) but you're using a modeless (potentially always on) GUI element (the PaletteSet ). 您的问题表明您希望用户执行模态操作(命令 - 显示对话框 - 使用对话框执行操作 - 关闭对话框),但您使用的是无模式(可能始终打开)GUI元素( PaletteSet )。

Have you asked yourself - what happens if the user never closes the dialog? 您是否问过自己 - 如果用户从未关闭对话框会发生什么? With the PaletteSet they have that option. 使用PaletteSet他们有这个选项。 In that case your "wipe" will never run. 在这种情况下,你的“擦拭”永远不会运行。 Will that also cause problems down the road? 这会不会引发问题?

I guess the question I would encourage you to ask is "is the PaletteSet the right tool for the job I'm doing?" 我想我鼓励你问的问题是“ PaletteSet是我正在做的工作的正确工具吗?” I'm only taking a guess at the job and work flow from your description and screen shot, but what I'm guessing concerns me. 我只是从你的描述和屏幕截图中猜测工作和工作流程,但我猜测的是我。 I wonder if what you really want to use here is a simple modal Form, launched from whatever mechanism currently launches your PaletteSet , that the user has to dismiss with an OK button, and then you would do your "wipe" in the OK handler. 我想知道你真正想要使用的是一个简单的模态表单,从当前启动PaletteSet任何机制启动,用户必须通过OK按钮解除,然后你将在OK处理程序中进行“擦除”。

If the reason you're using a PaletteSet is because the user has to interact with the drawing while it's active, there are ways to make a modal dialog get out of the way and allow them to pick entities or whatever it needs. 如果您使用PaletteSet的原因是因为用户必须在图形处于活动状态时与图形进行交互,则有一些方法可以使模式对话框脱离,并允许它们选择实体或其所需的任何内容。 Bear in mind that while a modeless PaletteSet is active the user can do literally anything else - open other drawings, draw entities, xref other drawings, run other commands, etc. Does your dialog need them to have that much flexibility? 请记住,当一个无模式PaletteSet处于活动状态时,用户可以执行其他任何操作 - 打开其他绘图,绘制实体,外部参照其他绘图,运行其他命令等。您的对话框是否需要它们具有那么大的灵活性? Is it prepared to handle itself properly in all those situations? 在所有这些情况下,它是否准备妥善处理?

I hope this has been somehow helpful even if I completely misunderstand your situation. 我希望即使我完全误解了你的情况,这也有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM