public MainWindow() { InitializeComponent(); backgroundImage.Visibility = Visibility.Hidden; drawBorder.Visibility = Visibility.Hidden; colorRect.Visibility = Visibility.Hidden; buttons = new Ellipse[] { red_selector, blue_selector, green_selector, eraser_selector, background_selector, refresh_selector }; drawController = new DrawController(drawingCanvas, backgroundImage, colorRect, image1, buttons); soundController = new SoundController(); cardController = new CardController(); kinectController = new KinectController(drawController, image1, soundController, buttons); }
public void selectCard(int index) { if (matched.Contains(index)) { return; } setCardBorder(index, Brushes.Yellow); selected.Add(index); if (selected.Count() == 2) { bool isMatching = cards.ElementAt(index).checkMatch(cards.ElementAt(selected.First())); foreach (int i in selected) { setCardBorder(i, isMatching ? Brushes.Green : Brushes.Black); if (isMatching) { matched.Add(i); // remove the card from list Console.WriteLine("remove card at index " + i); // card can only be removed by replacement of another blank card at the same spot on the grid CardController blankCard = new CardController(true, true, cards.ElementAt(i).topYcoordinate, cards.ElementAt(i).leftXcoordinate, i); Button blank = new Button { Width = CardController.width, Height = CardController.height }; Canvas.SetLeft(blank, blankCard.rightXcoordinate); Canvas.SetTop(blank, blankCard.topYcoordinate); cards.ElementAt(i).setButton(blank); grid.Children.Add(cards.ElementAt(i).getButton()); } } selected.Clear(); } }
// determines whether or not this card matches with another public Boolean checkMatch(CardController other) { // Need to get the filename or some association of what matches with what, // and compare this.index with other.matchingIndexs Console.WriteLine("Checking to see if a match between " + ((Image)button.Content).Source.ToString() + " and " + ((Image)other.button.Content).Source.ToString()); if (((Image)button.Content).Source.ToString().Equals(((Image)other.button.Content).Source.ToString())) return true; return false; }