public GamePokemonSearchResultsWindow(List <GamePokemonSearchResults> mirageIslandResults) { InitializeComponent(); this.gameSaves = new ObservableCollection <ListViewItem>(); this.selectedGameSave = null; this.selectedIndex = -1; this.mirageIslandResults = mirageIslandResults; if (!DesignerProperties.GetIsInDesignMode(this)) { this.listViewGameSaves.ItemsSource = gameSaves; for (int i = 0; i < PokeManager.NumGameSaves; i++) { GameSaveFileInfo gameSave = PokeManager.GetGameSaveFileInfoAt(i); if (GetMirageResults(gameSave.GameSave) == null) { continue; } ListViewItem listViewItem = new ListViewItem(); FillListViewItem(gameSave, listViewItem); gameSaves.Add(listViewItem); } } }
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e) { int newIndex = listViewGameSaves.SelectedIndex; if (newIndex != -1) { selectedIndex = newIndex; selectedGameSave = gameSaves[selectedIndex].Tag as GameSaveFileInfo; } }
private void FillListViewItem(GameSaveFileInfo gameSaveFile, ListViewItem listViewItem) { IGameSave gameSave = gameSaveFile.GameSave; StackPanel stackPanel = new StackPanel(); stackPanel.Orientation = Orientation.Horizontal; /*Image gameImage = new Image(); * BitmapImage bitmap = ResourceDatabase.GetImageFromName(gameSaveFile.GameType.ToString() + "Physical"); * gameImage.Source = bitmap; * if (bitmap == null) * gameImage.Width = 20; * else * gameImage.Width = bitmap.PixelWidth * (20.0 / bitmap.PixelHeight); * gameImage.Height = 20; * gameImage.VerticalAlignment = VerticalAlignment.Center;*/ TextBlock gameName = new TextBlock(); string gameTypeName = (gameSave.GameType == GameTypes.PokemonBox ? "Pokémon Box" : gameSave.GameType.ToString()); if (gameSaveFile.Nickname != "") { gameName.Text = gameSaveFile.Nickname + (gameSaveFile.GameType != GameTypes.PokemonBox ? " [" : ""); } else { gameName.Text = gameTypeName + (gameSaveFile.GameType != GameTypes.PokemonBox ? " [" : ""); } gameName.VerticalAlignment = VerticalAlignment.Center; //gameName.Margin = new Thickness(5, 0, 0, 0); TextBlock trainerName = new TextBlock(); trainerName.Text = gameSave.TrainerName; trainerName.Foreground = new SolidColorBrush(gameSave.TrainerGender == Genders.Male ? Color.FromRgb(32, 128, 248) : (gameSave.TrainerGender == Genders.Female ? Color.FromRgb(248, 24, 168) : Color.FromRgb(0, 0, 0))); trainerName.VerticalAlignment = VerticalAlignment.Center; TextBlock ending = new TextBlock(); ending.Text = "]"; ending.VerticalAlignment = VerticalAlignment.Center; //stackPanel.Children.Add(gameImage); stackPanel.Children.Add(gameName); if (gameSaveFile.GameType != GameTypes.PokemonBox) { stackPanel.Children.Add(trainerName); stackPanel.Children.Add(ending); } listViewItem.Content = stackPanel; listViewItem.Tag = gameSaveFile; }
private void OnRemoveSave(object sender, RoutedEventArgs e) { MessageBoxResult result = TriggerMessageBox.Show(this, "Are you sure you want to remove this game save?", "Remove Save", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes && selectedGameSave.GameSave.IsChanged) { result = TriggerMessageBox.Show(this, "Would you like to save changes made to this game before removing it?", "Save Changes", MessageBoxButton.YesNoCancel); } if (result == MessageBoxResult.Yes && selectedGameSave.GameSave.IsChanged) { selectedGameSave.GameSave.Save(selectedGameSave.FilePath); } if (result != MessageBoxResult.Cancel) { gameSaves.RemoveAt(selectedIndex); selectedIndex = -1; selectedGameSave = null; } }
public GamePokemonSearchResultsWindow(List<GamePokemonSearchResults> mirageIslandResults) { InitializeComponent(); this.gameSaves = new ObservableCollection<ListViewItem>(); this.selectedGameSave = null; this.selectedIndex = -1; this.mirageIslandResults = mirageIslandResults; if (!DesignerProperties.GetIsInDesignMode(this)) { this.listViewGameSaves.ItemsSource = gameSaves; for (int i = 0; i < PokeManager.NumGameSaves; i++) { GameSaveFileInfo gameSave = PokeManager.GetGameSaveFileInfoAt(i); if (GetMirageResults(gameSave.GameSave) == null) continue; ListViewItem listViewItem = new ListViewItem(); FillListViewItem(gameSave, listViewItem); gameSaves.Add(listViewItem); } } }
public SaveManager() { InitializeComponent(); this.gameSaves = new ObservableCollection <ListViewItem>(); this.selectedGameSave = null; this.selectedIndex = -1; CreateContextMenu(); if (!DesignerProperties.GetIsInDesignMode(this)) { this.listViewGameSaves.ItemsSource = gameSaves; this.dropManager = new ListViewDragDropManager <ListViewItem>(listViewGameSaves); for (int i = 0; i < PokeManager.NumGameSaves; i++) { GameSaveFileInfo gameSave = PokeManager.GetGameSaveFileInfoAt(i); ListViewItem listViewItem = new ListViewItem(); FillListViewItem(gameSave, listViewItem); gameSaves.Add(listViewItem); } } }
private void OnAddSaveClicked(object sender, RoutedEventArgs e) { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Title = "Add Generation III Save"; fileDialog.Filter = "GBA and GameCube Saves (*.sav, *.gci)|*.sav;*.gci|GBA Saves (*.sav)|*.sav|GameCube Saves (*.gci)|*.gci|All Files (*.*)|*.*"; var result = fileDialog.ShowDialog(this); if (result.HasValue && result.Value) { string filePath = fileDialog.FileName; filePath = System.IO.Path.GetFullPath(filePath); foreach (ListViewItem item in gameSaves) { GameSaveFileInfo save = item.Tag as GameSaveFileInfo; if (filePath.ToLower() == System.IO.Path.GetFullPath(save.FilePath).ToLower()) { TriggerMessageBox.Show(this, "This game save already exists", "Already Exists"); return; } } try { FileInfo fileInfo = new FileInfo(filePath); GameSaveFileInfo gameSaveFile; GameTypes gameType = GameTypes.Any; bool isJapanese = false; if (fileInfo.Length == 131072 || fileInfo.Length == 65536 || fileInfo.Length == 139264) { var results = SelectGameTypeFullWindow.ShowDialog(this, false); if (results != null) { gameType = results.GameType; isJapanese = results.IsJapanese; } } gameSaveFile = PokeManager.MakeNewGameSaveFileInfo(filePath, gameType, isJapanese); ListViewItem listViewItem = new ListViewItem(); FillListViewItem(gameSaveFile, listViewItem); gameSaves.Add(listViewItem); listViewGameSaves.SelectedIndex = listViewGameSaves.Items.Count - 1; // Hackish thing to make sure the list view is always scrolled at the bottom when adding a new box //http://stackoverflow.com/questions/211971/scroll-wpf-listview-to-specific-line /*VirtualizingStackPanel vsp = * (VirtualizingStackPanel)typeof(ItemsControl).InvokeMember("_itemsHost", * BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic, null, * listViewGameSaves, null); * double scrollHeight = vsp.ScrollOwner.ScrollableHeight; * vsp.SetVerticalOffset(vsp.ScrollOwner.ScrollableHeight * 2);*/ listViewGameSaves.ScrollIntoView(listViewGameSaves.SelectedItem); ((Control)listViewGameSaves.SelectedItem).Focus(); } catch (Exception ex) { MessageBoxResult result2 = TriggerMessageBox.Show(this, "Error loading game save file. Would you like to see the error?", "Read Error", MessageBoxButton.YesNo); if (result2 == MessageBoxResult.Yes) { ErrorMessageBox.Show(ex); } } } }
private void FillListViewItem(GameSaveFileInfo gameSaveFile, ListViewItem listViewItem) { IGameSave gameSave = gameSaveFile.GameSave; StackPanel stackPanel = new StackPanel(); stackPanel.Orientation = Orientation.Horizontal; /*Image gameImage = new Image(); BitmapImage bitmap = ResourceDatabase.GetImageFromName(gameSaveFile.GameType.ToString() + "Physical"); gameImage.Source = bitmap; if (bitmap == null) gameImage.Width = 20; else gameImage.Width = bitmap.PixelWidth * (20.0 / bitmap.PixelHeight); gameImage.Height = 20; gameImage.VerticalAlignment = VerticalAlignment.Center;*/ TextBlock gameName = new TextBlock(); string gameTypeName = (gameSave.GameType == GameTypes.PokemonBox ? "Pokémon Box" : gameSave.GameType.ToString()); if (gameSaveFile.Nickname != "") gameName.Text = gameSaveFile.Nickname + (gameSaveFile.GameType != GameTypes.PokemonBox ? " [" : ""); else gameName.Text = gameTypeName + (gameSaveFile.GameType != GameTypes.PokemonBox ? " [" : ""); gameName.VerticalAlignment = VerticalAlignment.Center; //gameName.Margin = new Thickness(5, 0, 0, 0); TextBlock trainerName = new TextBlock(); trainerName.Text = gameSave.TrainerName; trainerName.Foreground = new SolidColorBrush(gameSave.TrainerGender == Genders.Male ? Color.FromRgb(32, 128, 248) : (gameSave.TrainerGender == Genders.Female ? Color.FromRgb(248, 24, 168) : Color.FromRgb(0, 0, 0))); trainerName.VerticalAlignment = VerticalAlignment.Center; TextBlock ending = new TextBlock(); ending.Text = "]"; ending.VerticalAlignment = VerticalAlignment.Center; //stackPanel.Children.Add(gameImage); stackPanel.Children.Add(gameName); if (gameSaveFile.GameType != GameTypes.PokemonBox) { stackPanel.Children.Add(trainerName); stackPanel.Children.Add(ending); } listViewItem.Content = stackPanel; listViewItem.Tag = gameSaveFile; }
private void AddListViewItem(int gameIndex, object pocketType, string pocket, int count) { ListViewItem listViewItem = new ListViewItem(); if (decorationMode) { listViewItem.Tag = new ItemPocketGameTag(gameIndex, (DecorationTypes)pocketType); } else { listViewItem.Tag = new ItemPocketGameTag(gameIndex, (ItemTypes)pocketType); } listViewItem.SnapsToDevicePixels = true; listViewItem.UseLayoutRounding = true; DockPanel dockPanel = new DockPanel(); dockPanel.Width = 250; StackPanel stackPanel = new StackPanel(); stackPanel.Orientation = Orientation.Horizontal; if (gameIndex == -1) { TextBlock gameName = new TextBlock(); gameName.Text = PokeManager.Settings.ManagerNickname; gameName.VerticalAlignment = VerticalAlignment.Center; stackPanel.Children.Add(gameName); } else { IGameSave gameSave = PokeManager.GetGameSaveAt(gameIndex); GameSaveFileInfo gameSaveFile = PokeManager.GetGameSaveFileInfoAt(gameIndex); TextBlock gameName = new TextBlock(); string gameTypeName = (gameSave.GameType == GameTypes.PokemonBox ? "Pokémon Box" : gameSave.GameType.ToString()); if (gameSaveFile.Nickname != "") { gameName.Text = gameSaveFile.Nickname + (gameSaveFile.GameType != GameTypes.PokemonBox ? " [" : ""); } else { gameName.Text = gameTypeName + (gameSaveFile.GameType != GameTypes.PokemonBox ? " [" : ""); } gameName.VerticalAlignment = VerticalAlignment.Center; //gameName.Margin = new Thickness(5, 0, 0, 0); TextBlock trainerName = new TextBlock(); trainerName.Text = gameSave.TrainerName; trainerName.Foreground = new SolidColorBrush(gameSave.TrainerGender == Genders.Male ? Color.FromRgb(32, 128, 248) : (gameSave.TrainerGender == Genders.Female ? Color.FromRgb(248, 24, 168) : Color.FromRgb(0, 0, 0))); trainerName.VerticalAlignment = VerticalAlignment.Center; TextBlock ending = new TextBlock(); ending.Text = "]"; // " + pocket; ending.VerticalAlignment = VerticalAlignment.Center; //stackPanel.Children.Add(gameImage); stackPanel.Children.Add(gameName); if (gameSaveFile.GameType != GameTypes.PokemonBox) { stackPanel.Children.Add(trainerName); stackPanel.Children.Add(ending); } } TextBlock itemPocket = new TextBlock(); itemPocket.VerticalAlignment = VerticalAlignment.Center; itemPocket.HorizontalAlignment = HorizontalAlignment.Right; itemPocket.TextAlignment = TextAlignment.Right; itemPocket.Text = pocket + " "; itemPocket.Width = Double.NaN; itemPocket.MinWidth = 10; TextBlock itemX = new TextBlock(); itemX.VerticalAlignment = VerticalAlignment.Center; itemX.HorizontalAlignment = HorizontalAlignment.Right; itemX.TextAlignment = TextAlignment.Right; itemX.Text = "x"; itemX.MinWidth = 10; TextBlock itemCount = new TextBlock(); itemCount.VerticalAlignment = VerticalAlignment.Center; itemCount.HorizontalAlignment = HorizontalAlignment.Right; itemCount.TextAlignment = TextAlignment.Right; itemCount.Width = 30; itemCount.Text = count.ToString(); listViewItem.Content = dockPanel; listViewResults.Items.Add(listViewItem); dockPanel.Children.Add(stackPanel); dockPanel.Children.Add(itemCount); dockPanel.Children.Add(itemX); dockPanel.Children.Add(itemPocket); DockPanel.SetDock(itemX, Dock.Right); DockPanel.SetDock(itemCount, Dock.Right); DockPanel.SetDock(stackPanel, Dock.Left); }