c# 历史记录的实现

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

解决思路:每一步结果保存到全局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;
        }



发布了117 篇原创文章 · 获赞 4 · 访问量 8万+

猜你喜欢

转载自blog.csdn.net/qq_36266449/article/details/78384016