public ImageItemViewModel(ModelsEx models, int id) { this.Id = id; this.models = models; this.images = models.Images; var imgData = images.Images[id]; Prefix = $"I{id} - "; ToolTip = imgData.Filename + "\n" + imgData.OriginalFormat; if (imgData.Alias.StartsWith("__imported")) { imageName = ""; images.RenameImage(id, ""); System.Windows.Threading.Dispatcher.CurrentDispatcher.BeginInvoke((Action)OnRename); } else { imageName = imgData.Alias; } RenameCommand = new ActionCommand(OnRename); DeleteCommand = new ActionCommand(() => images.DeleteImage(id)); ReplaceEquationCommand = new ActionCommand <int>(OnReplaceWithEquation); }
/// <summary> /// return the view of image deletion confirmation. /// </summary> /// <param name="ImagePath">path of image to confirm deletion</param> /// <returns>view</returns> public ActionResult ConfirmDelete(string ImagePath) { //delete imagesModel.DeleteImage(ImagePath); //redirect to gallery return(RedirectToAction("Images")); }
public ImageListBoxItem(string filename, string fileformat, int id, ImagesModel imagesModel) { Id = id; // load images var imgDelete = new Image { Source = App.GetResourceImage(App.ResourceIcon.Cancel) }; var btnDelete = new Button { Height = 16, Width = 16, Content = imgDelete, Margin = new Thickness(0.0, 0.0, 5.0, 0.0) }; var text = new TextBlock { Text = $"I{Id} - {System.IO.Path.GetFileNameWithoutExtension(filename)}", }; var grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1.0, GridUnitType.Auto) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1.0, GridUnitType.Star) }); Grid.SetColumn(btnDelete, 0); grid.Children.Add(btnDelete); Grid.SetColumn(text, 1); grid.Children.Add(text); btnDelete.Click += (sender, args) => imagesModel.DeleteImage(Id); Content = grid; ToolTip = filename + "\n" + fileformat; HorizontalContentAlignment = HorizontalAlignment.Stretch; }
public ActionResult DeleteImage(string imageFullUrl) { m_imagesModel.DeleteImage(imageFullUrl); return(RedirectToAction("Images")); }