1

I'm making a keno game in C#. I'm now trying to build the "Card" where a user would click on the number they'd like to add to their picks, which would add it into an Arraylist to check against the picked numbers when they generate. What I'm thinking of doing is creating 80 rectangles on my xaml using the toolbox, and then putting an image I'd make in Powerpoint and make parts transparent in GIMP, so when you click on a number on the picture, it would make the rectangle behind change colors, showing through the transparency.

Something like what I'm thinking That seems overly complicated though. And I don't think the game will recognize I'm clicking in the square, when I've got something over the top unless I add 80 more clear ones on top. Anybody else have a better idea on how to implement this? I'll probably have 4 different patterns : Unpicked, User picked but not a winner, winner but user didn't pick it, and User picked and a winner. Any help is greatly appreciated! :)

Cthanatos
  • 137
  • 1
  • 7
  • Use an `ItemsControl`. Post your current code and XAML. – Federico Berasategui Apr 11 '14 at 18:39
  • 1
    and no, don't use bitmap graphics in WPF. Use WPF's built in support for vector graphics instead. – Federico Berasategui Apr 11 '14 at 18:40
  • @HighCore At work now so I don't have access to post my code just this minute, but I will look into ItemsControl, and wouldn't using vector graphics just improve how things change shape when you change the window? Would vector graphics still help if I make a window with a fixed size? I'm still learning, I'll look into both options :) – Cthanatos Apr 11 '14 at 19:50
  • as a general rule, don't use bitmaps in WPF whenever a vector graphics approach is available. In this case, I't really easy to do what you show here using 2 or 3 `Rectangles` and some `Path`s for the bevel effect. And vector graphics are native in WPF and make your code much cleaner and happier since you can then just change the `Fill` and `Stroke` color properties instead of swapping bitmaps around which needs more code and gives a glitchy effect. – Federico Berasategui Apr 11 '14 at 19:54
  • @HighCore 2 or 3 rectangles? Keno has the numbers 1-80 that the user gets to pick from, so I'm not sure how 2 or 3 would work that well. I really appreciate your answers :) I'll be looking at the vids on PluralSight to see what I can glean there on Vector stuff :) – Cthanatos Apr 11 '14 at 20:16
  • numbers are just text. use a `TextBlock`, as opposed to "drawing" them. see [My Example](http://stackoverflow.com/a/15344546/643085) of a Sudoku board in WPF, which is a similar concept (squares with numbers). You just need to style it a little bit more and use some `DataTriggers` to toggle colors, etc. – Federico Berasategui Apr 11 '14 at 20:20
  • @HighCore Wow! Thanks so much! That example will help a ton! If you want to post the example as a solution I can choose that :) – Cthanatos Apr 12 '14 at 02:39

0 Answers0