c# - How can I invoke PaintEventArgs for results returned by EventArgs from Web Service -
i have code:
public partial class form1 : form { private int size; public form1() { initializecomponent(); size = 10; } private void runautomat_click(object sender, eventargs e) { var mymatrix = new int[size][]; (int = 0; < size; i++) { mymatrix[i] = new int[size]; (int j = 0; j < size; j++) mymatrix[i][j] = 0; } var cw = new mywebservice(); var result = cw.fillmatrix(mymatrix, size); } }
next want draw grid result, don't have idea how send method painteventargs. example this:
private void pb_paint(object sender, painteventargs e) { int cellsize = 2; (int x = 0; x < size; ++x) (int y = 0; y < size; ++y) { if (result [y, x].state == 1) e.graphics.fillrectangle(new system.drawing.solidbrush(color.cyan), new rectangle(y * cellsize, x * cellsize, cellsize, cellsize)); else if (result [y, x].state == 2) e.graphics.fillrectangle(new system.drawing.solidbrush(color.yellow), new rectangle(y * cellsize, x * cellsize, cellsize, cellsize)); } }
i know incorrect , need better solution.
you store value of result
form level variable , call this.refresh()
make form redraw.
public partial class form1 : form { //guessing data type is: private int[,] _result; private void runautomat_click(object sender, eventargs e) { //snip _result = cw.fillmatrix(mymatrix, size); this.refresh(); } }
Comments
Post a Comment