public void Add() { if (addImageWindow != null) { MessageBox.Show( "Only able to have one add image dialog open at a time!", "Add image", MessageBoxButton.OK, MessageBoxImage.Error); } else { addImageWindow = new AddImageWindow { DataContext = this, Owner = Application.Current.MainWindow }; var imageService = ServiceLocator.Instance.Get<ITypeImageService>(); var data = new AddEditTypeImageViewModel(addImageWindow, imageService, true); var dialogResult = addImageWindow.ShowDialog(); if (dialogResult == true) { if (imageService != null) { var imageSize = (ImageQuality)Enum.Parse(typeof(ImageQuality), data.Size); imageService.Register(data.Type, imageSize, data.FileName); } } addImageWindow = null; } }
public void Edit(ImageTypeRecord imageTypeRecord) { Debug.Assert(imageTypeRecord != null, "ImageTypeRecord must be supplied to allow editing."); var service = ServiceLocator.Instance.Get<ITypeImageService>(); var window = new AddImageWindow(); var data = new AddEditTypeImageViewModel(window, service, false); window.DataContext = data; window.Owner = Application.Current.MainWindow; data.Type = imageTypeRecord.Name; data.Size = imageTypeRecord.Quality.ToString(); data.FileName = imageTypeRecord.Image; bool? dialogResult = window.ShowDialog(); if (dialogResult != null && (bool)dialogResult) { imageTypeRecord.Image = data.FileName; } }