private void SelectPokemon(PokemonDataWrapper selectedPokemon) { if (SelectedPokemons.Contains(selectedPokemon)) { SelectedPokemons.Remove(selectedPokemon); // If no pokemons are left selected, close the selection mode if (SelectedPokemons.Count == 0) { currentSelectionMode = SelectionMode.GoToDetail; MultiplePokemonSelected?.Invoke(null, selectedPokemon); } } else { if (selectedPokemon != null) { SelectedPokemons.Add(selectedPokemon); // When the first pokemon is selected, open selection mode if (SelectedPokemons.Count == 1) { MultiplePokemonSelected?.Invoke(null, selectedPokemon); } } } RaisePropertyChanged(() => SelectedPokemons); RaisePropertyChanged(() => SelectedPokemonCount); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PokemonsInventory_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (!SettingsService.Instance.IsLiveTileEnabled) { return; } // Using a Switch here because we might handle other changed events in other ways. switch (e.Action) { case NotifyCollectionChangedAction.Add: case NotifyCollectionChangedAction.Remove: case NotifyCollectionChangedAction.Replace: var images = new List <string>(); foreach (PokemonData pokemonData in e.NewItems) { var pokemon = new PokemonDataWrapper(pokemonData); images.Add($"Assets/Pokemons/{(int)pokemon.PokemonId}.png"); } var tile = LiveTileHelper.GetPeopleTile(images); LiveTileUpdater.Update(new TileNotification(tile.GetXml())); break; } }
/// <summary> /// Generates a <see cref="TileBindingContentAdaptive"/> for a given list of image URLs. /// </summary> /// <param name="pokemon"> /// A <see cref="PokemonDataWrapper"/> containing the Pokemon to generate a tile for. /// </param> /// <returns></returns> /// <remarks>Original contribution from sam9116 (https://github.com/ST-Apps/PoGo-UWP/pull/626/files)</remarks> private static TileBinding GetPeekBindingSmall(PokemonDataWrapper pokemon) { return(GetPeekBinding( $"{(int)pokemon.PokemonId}.png", GetCenteredAdaptiveText($"CP: {pokemon.Cp}", AdaptiveTextStyle.Caption), GetCenteredAdaptiveText($"{(pokemon.Stamina / pokemon.StaminaMax) * 100}%", AdaptiveTextStyle.Caption) )); }
private async void UseRevive(PokemonDataWrapper pokemon, ItemId item) { try { ServerRequestRunning = true; // Use local var to prevent bug when changing selected pokemon during running request var affectingPokemon = SelectedPokemon; // Send revive request var res = await GameClient.UseItemRevive(item, pokemon.Id); switch (res.Result) { case UseItemReviveResponse.Types.Result.Unset: break; case UseItemReviveResponse.Types.Result.Success: // Reload updated data bool selectedPokemonSameAsAffecting = affectingPokemon == SelectedPokemon; PokemonInventory.Remove(affectingPokemon); var affectedPokemon = new PokemonDataWrapper(affectingPokemon.WrappedData); affectedPokemon.SetStamina(res.Stamina); PokemonInventory.SortBySortingmode(CurrentPokemonSortingMode); CurrentUseItem.Count--; // If the affecting pokemon is still showing (not fliped to other), change selected to affected if (selectedPokemonSameAsAffecting) { SelectedPokemon = affectedPokemon; RaisePropertyChanged(nameof(SelectedPokemon)); RaisePropertyChanged(nameof(CurrentUseItem)); } await GameClient.UpdateProfile(); // If nothing of this item is left, remove from inventory manually and return to the inventory overview page if (CurrentUseItem?.Count == 0) { ItemsInventory.Remove(CurrentUseItem); ReturnToInventoryCommand.Execute(); } break; case UseItemReviveResponse.Types.Result.ErrorDeployedToFort: ErrorDeployedToFort?.Invoke(this, null); break; case UseItemReviveResponse.Types.Result.ErrorCannotUse: break; default: throw new ArgumentOutOfRangeException(); } } finally { ServerRequestRunning = false; } }
private async void UsePotion(PokemonDataWrapper pokemon, ItemId item) { try { ServerRequestRunning = true; // Use local var to prevent bug when changing selected pokemon during running request var affectingPokemon = SelectedPokemon; // Send potion request var res = await GameClient.UseItemPotion(item, affectingPokemon.Id); switch (res.Result) { case UseItemPotionResponse.Types.Result.Unset: break; case UseItemPotionResponse.Types.Result.Success: // Reload updated data bool selectedPokemonSameAsAffecting = affectingPokemon == SelectedPokemon; PokemonInventory.Remove(affectingPokemon); var affectedPokemon = new PokemonDataWrapper(affectingPokemon.WrappedData); affectedPokemon.SetStamina(res.Stamina); if (affectedPokemon.Stamina < affectedPokemon.StaminaMax) { PokemonInventory.Add(affectedPokemon); } PokemonInventory.SortBySortingmode(CurrentPokemonSortingMode); CurrentUseItem.Count--; // If the affecting pokemon is still showing (not fliped to other), change selected to affected if (selectedPokemonSameAsAffecting) { SelectedPokemon = affectedPokemon; RaisePropertyChanged(nameof(SelectedPokemon)); RaisePropertyChanged(nameof(CurrentUseItem)); } //GameClient.UpdateInventory(); await GameClient.UpdateProfile(); break; case UseItemPotionResponse.Types.Result.ErrorDeployedToFort: ErrorDeployedToFort?.Invoke(this, null); break; case UseItemPotionResponse.Types.Result.ErrorCannotUse: break; default: throw new ArgumentOutOfRangeException(); } } finally { ServerRequestRunning = false; } }
/// <summary> /// Generates a <see cref="TileBindingContentAdaptive"/> for a given list of image URLs. /// </summary> /// <param name="pokemon"> /// A <see cref="PokemonDataWrapper"/> containing the Pokemon to generate a tile for. /// </param> /// <returns></returns> /// <remarks>Original contribution from sam9116 (https://github.com/ST-Apps/PoGo-UWP/pull/626/files)</remarks> private static TileBinding GetPeekBindingLarge(PokemonDataWrapper pokemon) { return(GetPeekBinding( $"{(int)pokemon.PokemonId}.png", GetCenteredAdaptiveText(GetPokemonName(pokemon), AdaptiveTextStyle.Body), GetCenteredAdaptiveText($"Combat Points: {pokemon.Cp}", AdaptiveTextStyle.BodySubtle), GetCenteredAdaptiveText($"Stamina: {(pokemon.Stamina / pokemon.StaminaMax) * 100}%", AdaptiveTextStyle.BodySubtle) )); }
/// <summary> /// Generates a <see cref="TileBindingContentAdaptive"/> for a given list of image URLs. /// </summary> /// <param name="pokemon"> /// A <see cref="PokemonDataWrapper"/> containing the Pokemon to generate a tile for. /// </param> /// <returns></returns> /// <remarks>Original contribution from sam9116 (https://github.com/ST-Apps/PoGo-UWP/pull/626/files)</remarks> private static TileBinding GetPeekBindingMedium(PokemonDataWrapper pokemon) { return(GetPeekBinding( $"{(int)pokemon.PokemonId}.png", GetCenteredAdaptiveText(GetPokemonName(pokemon), AdaptiveTextStyle.Body), GetCenteredAdaptiveText($"CP: {pokemon.Cp}"), GetCenteredAdaptiveText($"HP: {(pokemon.Stamina / pokemon.StaminaMax) * 100}%") )); }
/// <summary> /// Generates a <see cref="TileBindingContentAdaptive"/> for a given list of image URLs. /// </summary> /// <param name="pokemon"> /// A <see cref="PokemonDataWrapper"/> containing the Pokemon to generate a tile for. /// </param> /// <returns></returns> /// <remarks>Original contribution from sam9116 (https://github.com/ST-Apps/PoGo-UWP/pull/626/files)</remarks> private static TileBinding GetPeekBindingWide(PokemonDataWrapper pokemon) { return(GetPeekBinding( $"{(int)pokemon.PokemonId}.png", GetCenteredAdaptiveText(Resources.Pokemon.GetString(pokemon.PokemonId.ToString()), AdaptiveTextStyle.Body), GetCenteredAdaptiveText($"Combat Points: {pokemon.Cp}"), GetCenteredAdaptiveText($"Stamina: {(pokemon.Stamina / pokemon.StaminaMax) * 100}%") )); }
public void SelectPokemon(PokemonDataWrapper selectedPokemon) { foreach (PokemonDataWrapper pdw in PokemonInventoryGridView.Items) { if (pdw == selectedPokemon) { PokemonInventoryGridView.SelectedItems.Add(pdw); } } }
/// <summary> /// Gets a Live Tile containing a "peek" template that renders like the Me tile. /// </summary> /// <param name="pokemon"> /// A <see cref="PokemonDataWrapper"/> containing the Pokemon to use for the tile image. /// </param> /// <returns>A populated <see cref="TileContent"/> object suitable for submitting to a TileUpdateManager.</returns> /// <remarks>https://msdn.microsoft.com/windows/uwp/controls-and-patterns/tiles-and-notifications-special-tile-templates-catalog</remarks> public static TileContent GetPeekTile(PokemonDataWrapper pokemon) { var tile = GetTile(PokemonBasePath); tile.Visual.TileSmall = GetPeekBindingSmall(pokemon); tile.Visual.TileMedium = GetPeekBindingMedium(pokemon); tile.Visual.TileWide = GetPeekBindingWide(pokemon); tile.Visual.TileLarge = GetPeekBindingLarge(pokemon); return(tile); }
private void ViewModel_MultiplePokemonSelected(object sender, PokemonDataWrapper e) { // Show or hide the 'Transfer multiple' button at the bottom of the screen if (ViewModel.SelectedPokemons.Count > 0) { PokemonInventory.SelectPokemon(e); ShowMultipleSelectStoryboard.Begin(); PokemonInventory.ShowHideSortingButton(false); } else { PokemonInventory.ClearSelectedPokemons(); HideMultipleSelectStoryboard.Begin(); PokemonInventory.ShowHideSortingButton(true); } }
private static string GetPokemonName(PokemonDataWrapper pokemon) { string PokemonName = String.Empty; try { PokemonName = Resources.Pokemon.GetString(pokemon.PokemonId.ToString()); } catch { } if (PokemonName == String.Empty) { try { PokemonSettings currentPokemon = GameClient.PokemonSettings.Where(x => x.PokemonId == pokemon.PokemonId).FirstOrDefault(); PokemonName = currentPokemon.PokemonId.ToString(); } catch { } } return(PokemonName); }
public PokemonDetailsPageViewModel() { if (Windows.ApplicationModel.DesignMode.DesignModeEnabled) { var pokeData = new PokemonData { PokemonId = PokemonId.Abra, Cp = 10, Stamina = 800, StaminaMax = 1000, WeightKg = 12, BattlesAttacked = 5 }; CurrentPokemon = new PokemonDataWrapper(pokeData); StardustAmount = 18000; StardustToPowerUp = 1800; CandiesToPowerUp = 100; CurrentCandy = new Candy { FamilyId = PokemonFamilyId.FamilyAbra, Candy_ = 10 }; } }
private void ScrollPokemonToVisible(PokemonDataWrapper p) { PokemonInventory.PokemonInventoryGridView.ScrollIntoView(p); }
private void SelectPokemon(PokemonDataWrapper selectedPokemon) { SelectedPokemon = selectedPokemon; RaisePropertyChanged(() => SelectedPokemon); }