Esempio n. 1
0
        private void ShowDetails()
        {
            CDItemResult selectedItem = DataGridResult.SelectedItem as CDItemResult;
            CD           selectedCD   = dataBase.GetCDById(selectedItem.CDID);

            WindowAlbum windowAlbum = new WindowAlbum(selectedCD, dataBase);

            windowAlbum.ShowDialog();
        }
        private void ShowDetails()
        {
            CD  cd       = new CD();
            int error    = 0;
            int canceled = 0;

            CDItemResult selItem = ((CDItemResult)this.DataGridResult.SelectedItem);

            if (selItem == null)
            {
                return;
            }

            CDArchiveConfig cdArchiveConfig = ((ComboBoxArchiveItem)ComboBoxCDArchives.SelectedItem).ArchiveConfig;

            if (cdArchiveConfig.Type == CDArchiveType.BIG3)
            {
                cd.Identity = selItem.Identity;

                CCDArchive cdarchive = new CCDArchive();

                cdarchive.SearchCDInInternetBig3(cdArchiveConfig, cd, ref canceled, ref error);
            }

            if (cdArchiveConfig.Type == CDArchiveType.CDArchiveLocal)
            {
                cd.Identity = selItem.Identity;

                CCDArchive cdarchive = new CCDArchive();

                CDArchiveLocalFile.SearchCDInCDArchiveLocalFile(cdArchiveConfig.ArchiveName, cd);
            }

            WindowAlbum windowAlbum = new WindowAlbum(cd, dataBase);

            windowAlbum.SaveAlbumOnOK = false;
            windowAlbum.ShowDialog();
        }
Esempio n. 3
0
        private void TransferCDs()
        {
            int count = 0;

            foreach (CDListBoxWithCoverItem item in listBoxResult.SelectedItems)
            {
                int cdSetCount = 0;

                foreach (CDItem cdItem in item.CD)
                {
                    CD cd = new CD();

                    String artist = StringTable.Unknown;
                    String title  = StringTable.Unknown;

                    if (!string.IsNullOrEmpty(item.Artist))
                    {
                        artist = item.Artist;
                    }
                    if (!string.IsNullOrEmpty(item.Title))
                    {
                        title = item.Title;
                    }

                    cd.Artist = artist;
                    cd.Title  = title;
                    cd.Label  = item.Label;
                    cd.UPC    = item.EAN;

                    if (item.CD.Length > 1)                             // Dann ist es ein CD-Set
                    {
                        cd.CDSetNumber = cdSetCount + 1;
                        cd.CDSetName   = item.Title;
                    }

                    if (item.Year != null && item.Year.Length > 4)
                    {
                        cd.YearRecorded = Convert.ToInt32(item.Year.Substring(0, 4));
                    }

                    cd.NumberOfTracks = cdItem.Tracks.Length;
                    cd.InitTracks(cd.NumberOfTracks);

                    int iTrack = 0;
                    foreach (String trackName in cdItem.Tracks)
                    {
                        cd.Tracks[iTrack].Title = trackName;
                        iTrack++;
                    }

                    // Jetzt noch das Front-Cover
                    WebClient webClient = new WebClient();
                    webClient.UseDefaultCredentials = true;
                    webClient.Proxy.Credentials     = CredentialCache.DefaultCredentials;

                    String imageFilename;

                    imageFilename = String.Format("{0} - {1}.jpg", Misc.FilterFilenameChars(artist), Misc.FilterFilenameChars(title));

                    String imageFilepath = Misc.GetCDCoverFilename(imageFilename);

                    byte[] data = null;

                    if (item.largeImageUrl != null)
                    {
                        data = webClient.DownloadData(item.largeImageUrl);
                    }
                    else
                    if (item.mediumImageUrl != null)
                    {
                        data = webClient.DownloadData(item.mediumImageUrl);
                    }
                    else
                    if (item.smallImageUrl != null)
                    {
                        data = webClient.DownloadData(item.smallImageUrl);
                    }

                    if (data != null)
                    {
                        FileStream fileStream = new FileStream(imageFilepath, FileMode.Create);
                        fileStream.Write(data, 0, data.Length);
                        fileStream.Close();

                        cd.CDCoverFrontFilename = imageFilepath;
                    }

                    // Jetzt noch das Back-Cover
                    imageFilename = String.Format("{0} - {1} - Back.jpg", Misc.FilterFilenameChars(artist), Misc.FilterFilenameChars(title));

                    imageFilepath = Misc.GetCDCoverFilename(imageFilename);

                    data = null;

                    if (item.backCoverLargeImageUrl != null)
                    {
                        data = webClient.DownloadData(item.backCoverLargeImageUrl);
                    }
                    else
                    if (item.backCoverMediumImageUrl != null)
                    {
                        data = webClient.DownloadData(item.backCoverMediumImageUrl);
                    }
                    else
                    if (item.backCoverSmallImageUrl != null)
                    {
                        data = webClient.DownloadData(item.backCoverSmallImageUrl);
                    }

                    if (data != null)
                    {
                        FileStream fileStream = new FileStream(imageFilepath, FileMode.Create);
                        fileStream.Write(data, 0, data.Length);
                        fileStream.Close();

                        cd.CDCoverBackFilename = imageFilepath;
                    }

                    bool saveCD = true;
                    if (this.checkBoxEditBeforeSave.Checked)
                    {
                        WindowAlbum windowAlbum = new WindowAlbum(cd, this.dataBase);
                        windowAlbum.SaveAlbumOnOK = true;
                        saveCD = false;
                        if (windowAlbum.ShowDialog() == true)
                        {
                            count++;
                        }
                    }

                    if (saveCD)
                    {
                        cd.Save(this.dataBase);

                        count++;
                    }

                    cdSetCount++;
                }
            }

            String str = string.Format(StringTable.AmazonCopySuccess, count);

            System.Windows.MessageBox.Show(str, System.Windows.Forms.Application.ProductName, MessageBoxButton.OK, MessageBoxImage.Information);
        }