示例#1
0
        private void Window_Loaded(Object sender, RoutedEventArgs e)
        {
            this._drag.CardsDragging = new List <Card>();
            this._timer          = new Timer(1000);
            this._timer.Elapsed += this.OnTimeElapsed;

            this.SetupKeyboardShortcuts();
            Data.Load();

            // initialize all the game elements
            this._stock          = new Stock();
            this._stock.MouseUp += this.OnStockMouseUp;
            this.MainCanvas.Children.Add(this._stock);

            this._waste = new Waste();

            this.MainCanvas.Children.Add(this._waste);

            for (var a = 0; a < 4; a++)
            {
                var foundation = new Foundation();

                this.MainCanvas.Children.Add(foundation);
                this._droppableElements.Add(foundation);
                this._foundations.Add(foundation);
            }

            for (var a = 0; a < 7; a++)
            {
                var tableau = new Tableau();

                this.MainCanvas.Children.Add(tableau);
                this._droppableElements.Add(tableau);
                this._tableaus.Add(tableau);
            }

            foreach (Card.Suit suit in Enum.GetValues(typeof(Card.Suit)))
            {
                foreach (Card.Value value in Enum.GetValues(typeof(Card.Value)))
                {
                    var card = new Card(suit, value);

                    card.MouseDown += this.onMouseDown;
                    card.MouseMove += this.onMouseMove;
                    card.MouseUp   += this.onMouseUp;

                    this._cards.Add(card);
                }
            }

            this.IsReadyForGame = true;

            this.StartGame();
        }
示例#2
0
        private void Window_Loaded( Object sender, RoutedEventArgs e ) {
            this._drag.CardsDragging = new List<Card>();
            this._timer = new Timer( 1000 );
            this._timer.Elapsed += this.OnTimeElapsed;

            this.SetupKeyboardShortcuts();
            Data.Load();

            // initialize all the game elements
            this._stock = new Stock();
            this._stock.MouseUp += this.OnStockMouseUp;
            this.MainCanvas.Children.Add( this._stock );

            this._waste = new Waste();

            this.MainCanvas.Children.Add( this._waste );

            for ( var a = 0; a < 4; a++ ) {
                var foundation = new Foundation();

                this.MainCanvas.Children.Add( foundation );
                this._droppableElements.Add( foundation );
                this._foundations.Add( foundation );
            }

            for ( var a = 0; a < 7; a++ ) {
                var tableau = new Tableau();

                this.MainCanvas.Children.Add( tableau );
                this._droppableElements.Add( tableau );
                this._tableaus.Add( tableau );
            }

            foreach ( Card.Suit suit in Enum.GetValues( typeof( Card.Suit ) ) ) {
                foreach ( Card.Value value in Enum.GetValues( typeof( Card.Value ) ) ) {
                    var card = new Card( suit, value );

                    card.MouseDown += this.onMouseDown;
                    card.MouseMove += this.onMouseMove;
                    card.MouseUp += this.onMouseUp;

                    this._cards.Add( card );
                }
            }

            this.IsReadyForGame = true;

            this.StartGame();
        }