Hi, I wish this may help you:
Firstly, your code adds to redo list in MouseUp event so when when you undo twice or more and then redo with the last pic in your redo list. this will redraw the pic before the first undo so I suggest this with deleting UndoMade variable
int undo_times=0;
private void BtnUndo_Click(object sender, EventArgs e)
{
if (UndoList.Count == 0)
{
BtnUndo.Enabled = false;
return;
}
PicInMemory = UndoList[UndoList.Count - 1];
PaintOnPanel = panel1.CreateGraphics();
PaintOnPanel.DrawImage(PicInMemory, 0, 0);
UndoList.RemoveAt(UndoList.Count - 1);
undo_times+=1;
}
private void BtnRedo_Click(object sender, EventArgs e)
{
if (RedoList.Count == 0 || undo_times == 0)
{
BtnRedo.Enabled = false;
return;
}
PicInMemory = RedoList[RedoList.Count - undo_times];
PaintOnPanel = panel1.CreateGraphics();
PaintOnPanel.DrawImage(PicInMemory, 0, 0);
undo_times-=1;
}
with my best wishes.