c# 历史记录的实现

来源:互联网 发布:mac搜狗输入法 编辑:程序博客网 时间:2024/05/16 00:38

需求:在开发图像处理软件过程,需要撤回上一步操作;

解决思路:每一步结果保存到全局list,在撤销时读取即可;


List<Bitmap> list_bmp = new List<Bitmap>();        private void button1_Click(object sender, EventArgs e)        {             list_bmp.Add(threshImge.ToBitmap());        }        private void button2_Click(object sender, EventArgs e)        {             list_bmp.Add(threshImge.ToBitmap());        }        private void button8_Click(object sender, EventArgs e)        {            Bitmap bmp = list_bmp.ElementAt(list_bmp.Count-1);            list_bmp.RemoveAt(list_bmp.Count - 1);            pictureBox2.Image = bmp;        }



原创粉丝点击