Rewrite repaint function in Dialog

Rewrite repaint function in Dialog