<commit_before>﻿using Caliburn.Micro;
using Microsoft.Phone.Tasks;
using MyHoard.Models;
using MyHoard.Resources;
using MyHoard.Services;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Imaging;

namespace MyHoard.ViewModels
{
    public class AddItemViewModel : ViewModelBase, IHandle<ServiceErrorMessage>, IHandle<TaskCompleted<PhotoResult>>
    {
        private ItemService itemService;
        private MediaService mediaService;
        private readonly IEventAggregator eventAggregator;

        private string pageTitle;
        private int collectionId;
        private int itemId;
        private Item currentItem;
        private Item editedItem;
        private bool canSave;
        private Visibility isDeleteVisible;
        private Media selectedPicture;
        
        private ObservableCollection<Media> pictures;
        private List<Media> picturesToDelete;

    
        public AddItemViewModel(INavigationService navigationService, CollectionService collectionService, ItemService itemService,  IEventAggregator eventAggregator, MediaService mediaService)
            : base(navigationService, collectionService)

        {
            this.mediaService = mediaService;
            this.itemService = itemService;
            this.eventAggregator = eventAggregator;
        }

        public void DeleteImage()
        {
            MessageBoxResult messageResult = MessageBox.Show(AppResources.DeleteDialog + " " + AppResources.ThisImage + "?", AppResources.Delete, MessageBoxButton.OKCancel);
            if (messageResult == MessageBoxResult.OK)
            {
                SelectedPicture.ToDelete = true;
                picturesToDelete.Add(SelectedPicture);
                Pictures.Remove(SelectedPicture);
                DataChanged();
            }
        }

        

        public void DataChanged()
        {
            bool picturesChanged=false;<commit_msg>Fixed minor issue with save button after image deletion in AddItemViewModel<commit_after>﻿using Caliburn.Micro;
using Microsoft.Phone.Tasks;
using MyHoard.Models;
using MyHoard.Resources;
using MyHoard.Services;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Imaging;

namespace MyHoard.ViewModels
{
    public class AddItemViewModel : ViewModelBase, IHandle<ServiceErrorMessage>, IHandle<TaskCompleted<PhotoResult>>
    {
        private ItemService itemService;
        private MediaService mediaService;
        private readonly IEventAggregator eventAggregator;

        private string pageTitle;
        private int collectionId;
        private int itemId;
        private Item currentItem;
        private Item editedItem;
        private bool canSave;
        private Visibility isDeleteVisible;
        private Media selectedPicture;
        
        private ObservableCollection<Media> pictures;
        private List<Media> picturesToDelete;

    
        public AddItemViewModel(INavigationService navigationService, CollectionService collectionService, ItemService itemService,  IEventAggregator eventAggregator, MediaService mediaService)
            : base(navigationService, collectionService)

        {
            this.mediaService = mediaService;
            this.itemService = itemService;
            this.eventAggregator = eventAggregator;
        }

        public void DeleteImage()
        {
            MessageBoxResult messageResult = MessageBox.Show(AppResources.DeleteDialog + " " + AppResources.ThisImage + "?", AppResources.Delete, MessageBoxButton.OKCancel);
            if (messageResult == MessageBoxResult.OK)
            {
                if (!String.IsNullOrEmpty(SelectedPicture.FileName))
                {
                    SelectedPicture.ToDelete = true;
                    picturesToDelete.Add(SelectedPicture);
                }
                Pictures.Remove(SelectedPicture);
                DataChanged();
            }
        }

        

        public void DataChanged()
        {
            bool picturesChanged=false;
{'fraction_non_alphanumeric': 0.06461394914858876, 'fraction_numerical': 0.0, 'mean_word_length': 2.6743787489288775, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4618020', 'n_tokens_mistral': 1028, 'n_tokens_neox': 1003, 'n_words': 241}