private void OnSetImageClicked(object sender, RoutedEventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "Image Files (*.png, *.jpg, *.bmp)|*.png;*.bmp;*.jpg|All Files (*.*)|*.*"; var result = dialog.ShowDialog(); if (result.HasValue && result.Value) { PokeManager.TryCreateDirectory(System.IO.Path.Combine(PokeManager.ApplicationDirectory, "Resources")); PokeManager.TryCreateDirectory(System.IO.Path.Combine(PokeManager.ApplicationDirectory, "Resources", "Trainer")); try { BitmapSource bitmap = PokeManager.LoadImage(dialog.FileName); try { PokeManager.SaveImage(bitmap, System.IO.Path.Combine(PokeManager.ApplicationDirectory, "Resources", "Trainer", "Trainer.png")); PokeManager.CustomTrainerImage = bitmap; imageTrainer.Width = Math.Min(90, bitmap.PixelWidth); imageTrainer.Height = Math.Min(138, bitmap.PixelHeight); imageTrainer.Source = bitmap; this.buttonRemoveImage.IsEnabled = PokeManager.CustomTrainerImage != null; } catch (Exception ex) { TriggerMessageBox.Show(this, "Error saving trainer image to Trigger's PC directory", "Image Error"); } } catch (Exception ex) { TriggerMessageBox.Show(this, "Error loading trainer image", "Image Error"); } } }