c#中撤消选项的代码 [英] code for undo option in c#

查看:106
本文介绍了c#中撤消选项的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void menuItemUndo_Click(object sender, EventArgs e)
       {
           imageHandler.ResetBitmap();
           this.AutoScrollMinSize = new Size(Convert.ToInt32(imageHandler.CurrentBitmap.Width * zoomFactor), Convert.ToInt32(imageHandler.CurrentBitmap.Height * zoomFactor));
           this.Invalidate();
       }





以上代码仅用于在图像(c#)中执行一次撤消操作。我需要使用此功能,直到从图像中删除所有更改。



The above code is used to do the undo operation only once in an image(c#).I need to work this function until all changes removed from the image.

推荐答案

请访问此链接



[ ^ ]


you需要创建一个动作列表。理想情况下,您不会在内存中保留单个更改的图像,保留起始图像,并且每次都应用相关操作。然后,您只需将除要撤消的操作之外的所有操作应用于原始图像,以获取撤消的操作。唯一的选择是将x图像保存在内存中,其中x是撤消步骤的数量。
you need to create a list of actions. Ideally you don't keep a single altered image in memory, you keep the starting image, and each time apply the actions in question. Then you just apply all your actions except the one you want to undo, to the original image, to get the undone one. The only alternative is to keep x images in memory where x is the number of undo steps.


这篇关于c#中撤消选项的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆