/// <summary> /// Gets called when a field is selected. /// </summary> /// <param name="sender">Sender who fired the event.</param> /// <param name="e">Event Arguments.</param> protected void FieldSelected(object sender, FieldSelectedEventArgs e) { if (this.mapView != null) { var widthHeight = GeoHelper.CalculateBoundingBox(e.Field.BoundingCoordinates); var center = widthHeight.Center; var coords = new CLLocationCoordinate2D(center.Latitude, center.Longitude); var span = new MKCoordinateSpan(widthHeight.Width * 1.1, widthHeight.Height * 1.1); this.mapView.Region = new MKCoordinateRegion(coords, span); } }
/// <summary> /// Fields the selected. /// </summary> /// <param name="sender">Sender object.</param> /// <param name="e">E event.</param> public void FieldSelected(object sender, FieldSelectedEventArgs e) { if (this.Map != null) { var builder = new LatLngBounds.Builder(); var whc = GeoHelper.CalculateBoundingBox(e.Field.BoundingCoordinates); double width = whc.Width * 0.95; double height = whc.Height * 0.59; builder.Include(new LatLng(whc.Center.Latitude - width, whc.Center.Longitude - height)); builder.Include(new LatLng(whc.Center.Latitude + width, whc.Center.Longitude + height)); var bounds = builder.Build(); this.Map.MoveCamera(CameraUpdateFactory.NewLatLngBounds(bounds, 0)); } }
/// <summary> /// The event handler for OnFieldSelection. /// </summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void Board_OnFieldSelection(object sender, FieldSelectedEventArgs e) { if (!_done && _currentColor == _playerColor && e.Piece != null && e.Piece.Color == _currentColor) { var enemyColor = ColorOperations.Invert(_currentColor); var movesForPiece = Bitboard.Moves .Where(p => p.From == e.Position && !Bitboard.Moves.Any(q => p.Piece == PieceType.King && q.Color == enemyColor && q.To == p.To)) .Select(p => p.To) .ToList(); VisualBoard.AddExternalSelections(movesForPiece); } }
/// <summary> /// The event handler for OnFieldSelection. /// </summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void Board_OnFieldSelection(object sender, FieldSelectedEventArgs e) { if (e.Piece == null) { var fieldAttackers = VisualBoard.FriendlyBoard.GetFieldAttackers(e.Position); VisualBoard.AddExternalSelections(fieldAttackers); } else { var movesForPiece = Bitboard.Moves .Where(p => p.From == e.Position) .Select(p => p.To) .ToList(); VisualBoard.AddExternalSelections(movesForPiece); } }