Пример #1
0
        public EditSongViewModel(Song song)
        {
            Song         = song;
            Title        = Song.Title;
            Artist       = Song.Artist;
            Duration     = Song.Duration;
            Art          = Song.Image;
            SelectedArt  = Song.Image;
            _artRepo     = new ArtRepository();
            ArtSelection = new ObservableCollection <string>(_artRepo.GetAlbumArt());
            _songRepo    = new SongRepository();

            CloseEditSongViewCommand = new RelayCommand(new Action <object>(CloseEditSongView));
            SaveChangesToSongCommand = new RelayCommand(new Action <object>(SaveChanges), Predicate => {
                if (TitleRule.TitleRegex.IsMatch(Title) &&
                    TitleRule.TitleRegex.IsMatch(Artist) &&
                    DurationRule.DurationRegex.IsMatch(Duration))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            });
        }