2015-01-08 3 views
1

MCU_timer_Tick()이 호출 될 때 OnPaint()으로 전화를 걸고 싶습니다. 어떻게하면됩니까?어떻게 EventArgs를 PaintEventArgs로 변환 할 수 있습니까? C#

private void MCU_timer_Tick(object sender, EventArgs e) 
    { 
     ... 
    } 
    protected override void OnPaint(PaintEventArgs e) 
    { 
     Graphics g = e.Graphics; 

     int width = 30; 
     int x, y; 
     x = 150; 
     y = 530; 
     double color_max; 
     color_max = 255; 
     SolidBrush aBrush_1 = 
     new SolidBrush(Color.FromArgb(100, 255, 
     (int)(255 * color_map[0]/color_max), 0)); //color_map[0] is real value 
     g.FillEllipse(aBrush_1, x-100, y, width * 2, width); 

답변

4

Tick 이벤트에 this.Invalidate()으로 전화하십시오. 결국 Paint 이벤트가 발생합니다.

private void MCU_timer_Tick(object sender, EventArgs e) 
{ 
    this.Invalidate(); 
} 

thisControl 지칭 여기서. 일반적으로 Form입니다.