c# - Drawing method used by panels -


i'm creating monopoly game in c# , it's first bigger project. game consist of panels fields (cities, events etc.). player represented rectangle drawn on panel , here problem. table of positions store information position of each player , i'm comparing each element of table in paint method of each panel (there 21 panels, gives 84 'if' statements). example:

private void panel4_paint(object sender, painteventargs e)     {         g = e.graphics;         pen redpen = new pen(color.red, 5);         rectangle rectangle = new system.drawing.rectangle(10, 10, 120, 120);         g.drawellipse(redpen, rectangle);          if (position[0] == 3)         {             g.fillrectangle(blackbrush, new rectangle(110, 110, 20, 20));         }         if (position[1] == 3)         {             g.fillrectangle(yellowbrush, new rectangle(80, 110, 20, 20));         }         if (position[2] == 3)         {             g.fillrectangle(redbrush, new rectangle(50, 110, 20, 20));         }         if (position[3] == 3)         {             g.fillrectangle(bluebrush, new rectangle(20, 110, 20, 20));         }      } 

is shorter way achieve that? i'm planning add houses , hotels, becomes more complicated.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -