public void Execute() { BackgroundModel background = backgroundCollection.Get(args.Value); string parentProfileNames = GetParentProfileNames(background); if (parentProfileNames != null) { MessageBoxView.Show("Can't delete this background", $"This background is used by one or more profiles ({parentProfileNames}), you can't delete it."); return; } backgroundCollection.Remove(background); if (screenModel.Background == background) { // Default background can't be deleted so there's always at least 1 item in the list. screenModel.SetBackground(backgroundCollection.Items[0]); } database.DeleteBackground(background); string dirPath = locationModel.GetGraphicBasePath(background.DirectoryType); File.Delete(Path.Combine(dirPath, background.FileName)); }
public void SetBackground(BackgroundModel background) { Background = background; string dirPath = locationModel.GetGraphicBasePath(background.DirectoryType); bitmap = assetsFactory.GetNoCache(Path.Combine(dirPath, Background.FileName)); DispatchEvent(new ScreenModelEventArgs(EVENT_BACKGROUND_CHANGED, this)); }