Example #1
0
		private void ShipClicked(object sender, System.Windows.Input.MouseButtonEventArgs e)
		{
			if(possiblePosition) 
			{
				if(currentShip != null) 
				{
					placedShips.Add(currentShip);
					currentShip = null;
				}
				currentShip = (Ship)sender;
				currentShip.PreviewMouseDown -= ShipClicked;
				currentShip = currentShip.Clone();
				int length = currentShip.Size;
				currentShip.Width = Playfield.Width / (Playfield.nrOfRowsCols + 1) * length;
            	currentShip.Height = Playfield.Width / (Playfield.nrOfRowsCols + 1);
            	Grid.SetRow(currentShip, 1);
            	Grid.SetColumn(currentShip, 1);
           		Grid.SetColumnSpan(currentShip, length);
            	Playfield.Fields.Children.Add(currentShip);
                checkOverlapping();
			}
			this.Focus();
		}