c# 歷史記錄的實現
阿新 • • 發佈:2019-01-31
需求:在開發影象處理軟體過程,需要撤回上一步操作;
解決思路:每一步結果儲存到全域性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; }