Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you need to draw that many images your best bet is to use a panel control and handle the drawing yourself by either handling the OnPaint event or even better: creating a custom control that inherits from the Panel control and which overrides the Paint method. Look online for examples of how to create custom-painted controls in .NET.</p> <p>Do not try to create hundreds of images using Image controls or other such controls because it adds to much overhead.</p> <p>In the Paint method, you can use the <a href="http://msdn.microsoft.com/en-us/library/42807xh1.aspx" rel="nofollow noreferrer">DrawImage</a> function to draw the chairs based on the different states (i.e. selected or not-selected). You can store the states of the chairs in a one- or two-dimensional array in memory and then loop through it in the Paint method to draw each chair, computing the position of the chair on-screen based on its' index:</p> <pre><code>for(int chairIndex = 0; chairIndex &lt; chairsCount; chairIndex++) { // compute the on-screen position of each chair chairX = (chairIndex % chairsPerLine) * chairWidh; chairY = (chairIndex / chairsPerLine) * chairHeight; // and read the current state from the array chairState = chairsArray[chairIndex]; // then draw the chair image in the graphics context switch(chairState) { case /* SELECTED */ .. DrawImage(selectedImage, new Point(chairX, chairY)); case /* NOT-SELECTED */ .. DrawImage(nonSelectedImage, new Point(chairX, chairY)); } } </code></pre> <p>You will also have to handle mouse events to "hit-test" when a user clicks a chair to toggle it's state in memory.</p> <pre><code>// compute chairIndex based on mouse position (for hit-test) chairIndex = mouseX / chairWidth + (mouseY / chairHeight) * chairsPerLine; // then toggle state accordingly </code></pre> <p><em>The code snippets above assume you have previously defined some of the variables, that you've loaded the different chair images into two or more variables, and that you're using a one-dimensional array for storing the chair states.</em></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload