public override void DragCards( Card refCard, List<Card> cardsDragging ) { var reached = false; foreach ( Card card in this.Children ) { if ( ReferenceEquals( card, refCard ) ) { reached = true; } if ( reached ) { cardsDragging.Add( card ); } } }
public virtual void DragCards( Card refCard, List<Card> cardsDragging ) { cardsDragging.Add( refCard ); }
private Boolean IsCardDraggable( Card card ) { var parent = card.Parent; if ( parent is Stock ) { return false; } // the last card is draggable, the others aren't if ( parent is Waste ) { if ( this._waste.Children.Count != 0 ) { var last = this._waste.Children[ this._waste.Children.Count - 1 ]; if ( last != card ) { return false; } } } return true; }
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(); }