المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : A Layout Question, And A Bit More



C# Programming
05-18-2012, 11:34 AM
Background:

My lady loves the game of Keno, specifically Cleopatra Keno. Her birthday is in 4 weeks, and I have 3 weeks relatively free until classes start again. I'd like to make a Windows version of the game for her to play at home for her birthday. Not only would she love it, but it would save me a ton of money if I could get her used to playing at home instead of a casino. The logic of the game is trivial. The player selects 3 to 10 numbers from a field of 80, places a bet, and presses Go to run a game.In Cleopatra Keno, if the run is a winner, and the last number drawn is one selected by the player, the game awards 12 free runs with doubled payouts. Each run draws 20 numbers from the field. The overall payout is only 90.1%, so it's a lousy money maker, but I have to admit that it's fun when a game starts hitting these bonus rounds over and over... it does happen.

So, I've created a Keno tile class as a user control. It has a button overlaid on a UserControl background with a Text member that represents the number of the tile, set in the constructor for each instance. A Tile contains methods to set and reset states of Selected by the player, Hit during game play, Last hit in a run, et cetera. These are all self-contained functions to control the colors displayed to the user. But how do I lay them out in a rectangular grid, and what's the best way to handle interactions between the game and the user? I think that having the individual tiles raise an event when the user makes a change makes sense, but during the game run, what should control?

The layout question is really the top priority right now. I have to instantiate 80 separate controls and make them display in a grid of 8 rows of 10 columns, and I'm not sure of the most efficient way to accomplish that. I could calculate the XY coordinates for each top left corner and render them that way, but that seems awfully ugly. Is there a better way?
Will Rogers never met me.