private void UserForm_FormClosing(object sender, FormClosingEventArgs e) { if (!(ShipChanged?.Invoke(new Ship()) ?? false)) { e.Cancel = true; } }
protected void OnShipChanged(Ship shipUpdated, bool killed) { ShipChanged?.Invoke(this, new ShipChangedEventArgs(shipUpdated, killed)); }
private void btnBoat_Click(object sender, EventArgs e) => ShipChanged?.Invoke(new Ship(ShipType.Boat, ShipOrientation.Vertical & ShipOrientation.Horizontal));
private void btnDestroyerVertical_Click(object sender, EventArgs e) => ShipChanged?.Invoke(new Ship(ShipType.Destroyer, ShipOrientation.Vertical));
private void btnCruiserHorizontal_Click(object sender, EventArgs e) => ShipChanged?.Invoke(new Ship(ShipType.Cruiser, ShipOrientation.Horizontal));
private void btnBattleshipVertical_Click(object sender, EventArgs e) => ShipChanged?.Invoke(new Ship(ShipType.Battleship, ShipOrientation.Vertical));