private void OnPokemonContextMenuOpening(object sender, ContextMenuEventArgs e) { Rectangle selector = sender as Rectangle; IGen3Pokemon pkm = pokeContainer[(int)selector.Tag]; selectedIndex = (int)selector.Tag; ((MenuItem)contextMenu.Items[0]).IsEnabled = true; if (pkm == null) { if (movingPokemon) { ((MenuItem)contextMenu.Items[0]).Header = "Place"; } else { ((MenuItem)contextMenu.Items[0]).IsEnabled = false; } } else { if (movingPokemon) { ((MenuItem)contextMenu.Items[0]).Header = "Switch"; } else { ((MenuItem)contextMenu.Items[0]).Header = "Move"; } } ((MenuItem)contextMenu.Items[1]).IsEnabled = pkm != null; ((MenuItem)contextMenu.Items[2]).IsEnabled = (pkm != null && !movingPokemon && !pkm.IsShadowPokemon); ((MenuItem)contextMenu.Items[3]).IsEnabled = (pkm != null && !pkm.IsShadowPokemon); }
private void OnBoxSlotClicked(object sender, MouseButtonEventArgs e) { if (pokeContainer == null) { return; } if (master != null) { master.OnBoxSlotClicked(sender, e); } Rectangle selector = sender as Rectangle; IGen3Pokemon pkm = pokeContainer[(int)selector.Tag]; if (e.ChangedButton == MouseButton.Left) { if (pkm != null && pokemonViewer != null) { pokemonViewer.LoadPokemon(pkm); } if (pickupMode) { if (mode == PokeBoxControlModes.MovePokemon) { MovePokemon(pkm, pokeContainer, hoverIndex); } else if (mode == PokeBoxControlModes.SelectPlacement && pkm == null) { MovePokemon(pkm, pokeContainer, hoverIndex); Window.GetWindow(this).DialogResult = true; Window.GetWindow(this).Close(); } } } else if (e.ChangedButton == MouseButton.Middle) { if (mode != PokeBoxControlModes.SelectPlacement) { pickupMode = !pickupMode; if (pickupMode) { imagePartySelector.Source = new BitmapImage(new Uri(System.IO.Path.Combine(Environment.CurrentDirectory, "../../Resources", "Selector2.png"))); imageBoxSelector.Source = new BitmapImage(new Uri(System.IO.Path.Combine(Environment.CurrentDirectory, "../../Resources", "Selector2.png"))); } else { imagePartySelector.Source = new BitmapImage(new Uri(System.IO.Path.Combine(Environment.CurrentDirectory, "../../Resources", "Selector.png"))); imageBoxSelector.Source = new BitmapImage(new Uri(System.IO.Path.Combine(Environment.CurrentDirectory, "../../Resources", "Selector.png"))); } } } }
public void MovePokemon(IGen3Pokemon pokemon, IPokeContainer container, int index) { if (movingPokemon) { RemoveAdornerLayer(); movingPokemon = false; } PokeManager.PickupPokemon(container, index); if (PokeManager.IsHoldingPokemon) { InitializeAdornerLayer(); RemoveAdornerLayer(); ((Image)pickupElement.Children[1]).Source = PokeManager.HoldingPokemon.BoxSprite; ((Rectangle)pickupElement.Children[2]).OpacityMask = new ImageBrush(PokeManager.HoldingPokemon.BoxSprite); ((Rectangle)pickupElement.Children[2]).Visibility = (PokeManager.HoldingPokemon.IsShadowPokemon ? Visibility.Visible : Visibility.Hidden); InitializeAdornerLayer(); movingPokemon = true; OnPreviewMouseMove(null, null); } RefreshUI(); }