Example #1
0
        private void Initialize()
        {
            if (InitializeDatabase())
            {
                DispatcherHelper.UIDispatcher.Invoke(new Action(() =>
                {
                    _webAlbumListViewModel = _viewLocator.SwitchToView <WebAlbumListView, WebAlbumListViewModel>();
                }), null);

                ReadActualDatabase();
            }
            //if we cannot interop with the zune database switch to the old view
            else
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    var selectAudioFilesViewModel = _viewLocator.SwitchToView <SelectAudioFilesView, SelectAudioFilesViewModel>();
                    selectAudioFilesViewModel.CanSwitchToNewMode = false;
                });
            }
        }
Example #2
0
        private void LinkAlbum()
        {
            try
            {
                DbAlbum dbAlbum = _dbReader.GetAlbum(MediaId);
                _sharedModel.DbAlbum = dbAlbum;

                IEnumerable <string> filePaths = dbAlbum.Tracks.Select(x => x.FilePath);
                _sharedModel.SongsFromFile = _fileRetriever.GetContainers(filePaths);

                var searchVm = _locator.SwitchToView <SearchView, SearchViewModel>();
                searchVm.Search(dbAlbum.Artist, dbAlbum.Title);
            }
            catch (COMException)
            {
                Messenger.Default.Send(new ErrorMessage(ErrorMode.Error,
                                                        "Could not find album, you may need to refresh the database."));
            }
            catch (Exception ex)
            {
                Messenger.Default.Send(new ErrorMessage(ErrorMode.Error, ex.Message));
            }
        }
 public void SwitchToClassicMode()
 {
     _locator.SwitchToView <SelectAudioFilesView, SelectAudioFilesViewModel>();
 }
Example #4
0
        private void Save()
        {
            Mouse.OverrideCursor = Cursors.Wait;

            var uaeExceptions = new List <UnauthorizedAccessException>();

            bool canContinue = true;

            if (UpdateAlbumInfo)
            {
                const string message = "Track metadata will be updated with information from the Zune Marketplace. Do you want to continue?";
                var          result  = ZuneMessageBox.Show(new ErrorMessage(ErrorMode.Warning, message), System.Windows.MessageBoxButton.YesNo);

                if (result == System.Windows.MessageBoxResult.Cancel)
                {
                    canContinue = false;
                }
            }

            if (canContinue)
            {
                foreach (var row in Rows.OfType <DetailRow>())
                {
                    try
                    {
                        if (row.SelectedSong != null)
                        {
                            var container = (IZuneTagContainer)row.SongDetails.BackingData;
                            container.RemoveZuneAttribute("WM/WMContentID");
                            container.RemoveZuneAttribute("WM/WMCollectionID");
                            container.RemoveZuneAttribute("WM/WMCollectionGroupID");
                            container.RemoveZuneAttribute("ZuneCollectionID");
                            container.RemoveZuneAttribute("WM/UniqueFileIdentifier");

                            foreach (var attribute in container.ZuneAttributes)
                            {
                                Trace.WriteLine(attribute.Name + " " + attribute.Guid);
                            }

                            var webTrack = (WebTrack)row.SelectedSong.BackingData;
                            container.AddZuneAttribute(new ZuneAttribute(ZuneIds.Album, webTrack.AlbumMediaId));
                            container.AddZuneAttribute(new ZuneAttribute(ZuneIds.Artist, webTrack.ArtistMediaId));
                            container.AddZuneAttribute(new ZuneAttribute(ZuneIds.Track, webTrack.MediaId));

                            if (UpdateAlbumInfo)
                            {
                                container.AddMetaData(CreateMetaDataFromWebDetails((WebTrack)row.SelectedSong.BackingData));
                            }

                            container.WriteToFile();
                            //TODO: run a verifier over whats been written to ensure that the tags have actually been written to file
                        }
                    }
                    catch (UnauthorizedAccessException uae)
                    {
                        uaeExceptions.Add(uae);
                        //TODO: better error handling
                    }
                }

                if (uaeExceptions.Count > 0)
                {   //usually occurs when a file is readonly
                    Messenger.Default.Send(new ErrorMessage(ErrorMode.Error,
                                                            "One or more files could not be written to. Have you checked the files are not marked read-only?"));
                }
                else
                {
                    _locator.SwitchToView <SuccessView, SuccessViewModel>();
                }
            }

            Mouse.OverrideCursor = null;
        }
 public void SwitchToNewMode()
 {
     _locator.SwitchToView <WebAlbumListView, WebAlbumListViewModel>();
 }
 public void MoveNext()
 {
     _sharedModel.WebAlbum = _searchResultsViewModel.DownloadedAlbum;
     _locator.SwitchToView <DetailsView, DetailsViewModel>().PopulateRows();
 }