/// <summary> /// Fires an event to update the View /// and removes the Image from the DocumentObject's collection /// as well as the ImageName from this.ImageNameList. /// It then sets the selected image and name to default. /// </summary> private void OnRemoveImage() { if (CanRemoveImage()) { if (SelectedImageName != ImageNameList[0]) { Ea.Publish(new UpdateViewEventModel() { Data = SelectedImageName }); DocumentObject.Images.Remove(SelectedImageName); ImageNameList.Remove(SelectedImageName); SelectedImageName = ImageNameList[0]; SelectedImage = null; } } }
/// <summary> /// Checks whether current Key is already contained in DocumentObject's /// Images list. If not, it'll add it. If so, shows an notification. /// </summary> /// <param name="result"></param> private void CompareLoadedImage(KeyValuePair <string, BitmapImage> result) { var keyExists = DocumentObject.Images.Keys.Where(k => k.Contains(result.Key)).Any(); if (!keyExists) { DocumentObject.Images.Add(result.Key, result.Value); ImageNameList.Add(result.Key); Ea.Publish(new UpdateViewEventModel() { Data = result.Key }); SelectedImage = result.Value; SelectedImageName = result.Key; } else { MessageBox.Show("*A file of that name already exists"); } }