VectorDraw Developer Framework试用版下载
点开本篇文章,是否对矢量图形工具感兴趣呢看看最新的矢量图形工具测评吧!点击此处>>即可直达哦!
问:
用户在执行新操作后,如何清空重做堆栈(排除这是一个重做步骤之后)/p>
答:
有两种方法可以实现此目的:
-
第一种是每当用户执行诸如移动夹点,添加新实体之类的操作以及通常触发UndoHistory_OnStoreValue事件的所有操作时,第一个操作都会擦除堆栈。
-
第二种方法是在用户通过命令行调用特定命令后擦除重做堆栈。
第一种:
首先获取此事件:
vdFramedControl1.BaseControl.ActiveDocument.UndoHistory.OnStoreValue += new VectorDraw.Professional.UndoRedo.ModificationHistory.StoreValueEventHandler(UndoHistory_OnStoreValue);
将此函数添加为事件处理程序:
bool whileRedo = false;void UndoHistory_OnStoreValue(object sender, bool isRedo, object propObject, string propName, object value, ref bool Cancel){ //We use this check to make sure that the new Undo value stored is not coming from a Redo command. if (!isRedo && !whileRedo) vdFramedControl1.BaseControl.ActiveDocument.UndoHistory.ClearRedoStack();}Also get this event in order to override the functionality of Redo:vdFramedControl1.CommandLine.CommandExecute += new VectorDraw.Professional.vdCommandLine.CommandExecuteEventHandler(CommandLine_CommandExecute);Add this function to handle the above event:void CommandLine_CommandExecute(string commandname, bool isDefaultImplemented, ref bool success){ //Here we override the Redo command in order to set the whileRedo function to true. That way we will know if the OnStoreValue event mentioned above is called due to a Redo function. if (string.Compare(commandname, "redo", true) == 0 || string.Compare(commandname, "r", true) == 0) { success = true; doc.CommandAction.Prompt("rn" + commandname); doc.CommandAction.Prompt(null); whileRedo = true; doc.UndoHistory.Redo(); whileRedo = false; doc.Update(); doc.Invalidate(); }}
使用上面的代码,就将实现所求操作。每次您修改对象的属性,添加新对象或任何创建撤消值的内容时,都会清除重做堆栈。这样,用户添加新项或修改属性后,您将无法选择重做。
第二种:
获取此事件以覆盖所需的任何命令的功能:
vdFramedControl1.CommandLine.CommandExecute += new VectorDraw.Professional.vdCommandLine.CommandExecuteEventHandler(CommandLine_CommandExecute);Add this function to handle the above event:void CommandLine_CommandExecute(string commandname, bool isDefaultImplemented, ref bool success) { //Here we override every command after which we want the Redo stack cleared if (string.Compare(commandname, "line", true) == 0 || string.Compare(commandname, "l", true) == 0 || string.Compare(commandname, "rect", true) == 0 || string.Compare(commandname, "move", true) == 0) { //Don’t set success to true, so that the execution of already implemented commands won’t stop after this function! vdFramedControl1.BaseControl.ActiveDocument.UndoHistory.ClearRedoStack(); doc.Update(); doc.Invalidate(); } }
使用上面的代码,每次您使用line,rect或move命令时,都会清除重做堆栈。
对于以上问答,如果您有任何的疑惑都可以在评论区留言,我们会及时回复。此系列的问答教程我们会持续更新,如果您感兴趣,可以多多关注本教程。
相关资料推荐:
-
如何排除GroundSurface对象的三角形区域/strong>
-
复杂自定义对象的入门指南
-
点击此处还有VectorDraw Developer Framework的demo示例等着你来体验哦!
如果您对想要购买正版授权VectorDraw Developer Framework(VDF),可以联系在线客服>>咨询相关问题。
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!