private void CDListBoxWithCover_MouseMove(object sender, MouseEventArgs e)
        {
            int index = this.IndexFromPoint(e.X, e.Y);

            if (index > -1)
            {
                if (PointInMore(index, e.Location))
                {
                    Cursor = Cursors.Hand;
                }
                else
                {
                    Cursor = Cursors.Default;
                }

                string tooltip = "";
                CDListBoxWithCoverItem item = (CDListBoxWithCoverItem)Items[index];
                if (item.CD != null)
                {
                    for (int i = 0; i < item.CD[0].Tracks.Length; i++)
                    {
                        tooltip += string.Format("{0}. {1}", i + 1, item.CD[0].Tracks[i]);
                        if (i < item.CD[0].Tracks.Length - 1)
                        {
                            tooltip += "\r\n";
                        }
                    }
                }

                if (toolTip.GetToolTip(this) != tooltip)
                {
                    toolTip.SetToolTip(this, "");
                    toolTip.SetToolTip(this, tooltip);
                }
            }
            else
            {
                toolTip.SetToolTip(this, "");
            }
        }
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            //base.OnDrawItem(e);
            if (e.Index >= Items.Count || e.Index < 0)
            {
                return;
            }

            Graphics g = e.Graphics;

            if ((e.State & DrawItemState.Selected) != 0)
            {
                g.FillRectangle(new SolidBrush(ColorTable.MenuItemSelected), e.Bounds);
                Rectangle rect = Rectangle.FromLTRB(e.Bounds.Left, e.Bounds.Top, e.Bounds.Right - 1, e.Bounds.Bottom - 1);
                g.DrawRectangle(new Pen(ColorTable.MenuItemBorder), rect);
            }
            else
            {
                g.FillRectangle(Brushes.White, e.Bounds);
            }

            CDListBoxWithCoverItem item = (CDListBoxWithCoverItem)Items[e.Index];

            string title = item.Title;

            if (item.CD != null && item.CD.Length > 1)
            {
                title += string.Format(" [{0} {1}]", item.CD.Length, StringTable.CDs);
            }

            g.DrawString(title, fontBold, Brushes.Black, new PointF(e.Bounds.Left + ItemHeight + Border * 2, e.Bounds.Top + Border));
            g.DrawString(item.Artist, fontNormal, Brushes.Black, new PointF(e.Bounds.Left + ItemHeight + Border * 2, e.Bounds.Top + 18));

            g.DrawString(item.Label, fontNormal, Brushes.Black, new PointF(e.Bounds.Left + ItemHeight + Border * 2, e.Bounds.Top + 42));

            string releaseDate = "";

            if (item.Year != null && item.Year.Length == 10)
            {
                DateTime dateTime = new DateTime(Convert.ToInt32(item.Year.Substring(0, 4)), Convert.ToInt32(item.Year.Substring(5, 2)), Convert.ToInt32(item.Year.Substring(8, 2)));
                releaseDate = string.Format("{0}: {1}", StringTable.ReleaseDate, dateTime.ToLongDateString());
            }

            if (item.Year != null && item.Year.Length == 7)              // Dann wurde wohl nur Jahr und Monat angegeben
            {
                DateTime dateTime = new DateTime(Convert.ToInt32(item.Year.Substring(0, 4)), Convert.ToInt32(item.Year.Substring(5, 2)), 1);

                releaseDate = string.Format("{0}: {1}", StringTable.ReleaseDate, dateTime.ToString("MMMM yyyy"));
            }

            if (item.Year != null && item.Year.Length == 4)              // Dann wurde wohl nur ein Jahr angegeben
            {
                releaseDate = string.Format("{0}: {1}", StringTable.ReleaseDate, item.Year.ToString());
            }

            g.DrawString(releaseDate, fontNormal, Brushes.Black, new PointF(e.Bounds.Left + ItemHeight + Border * 2, e.Bounds.Top + 55));

            if (item.Image != null)
            {
                g.DrawImage(item.Image, new Rectangle(new Point(e.Bounds.Left + Border, e.Bounds.Top + Border), new Size(ItemHeight - Border * 2, ItemHeight - Border * 2)));
            }

            int starXPos = e.Bounds.Right - 200;

            for (int i = 0; i < (int)item.Ranking; i++)
            {
                g.DrawImage(imageList.Images[0], new Point(starXPos, e.Bounds.Top + Border));
                starXPos += imageList.Images[0].Width;
            }

            if (item.Ranking != 0)
            {
                int   count = (int)item.Ranking;
                float f     = Convert.ToSingle(item.Ranking);
                if (f - (float)((int)item.Ranking) > 0.25 && f - (float)((int)item.Ranking) < 0.75)
                {
                    g.DrawImage(imageList.Images[2], new Point(starXPos, e.Bounds.Top + Border));
                    starXPos += imageList.Images[2].Width;
                    count++;
                }

                for (int i = count; i < 5; i++)
                {
                    g.DrawImage(imageList.Images[1], new Point(starXPos, e.Bounds.Top + Border));
                    starXPos += imageList.Images[1].Width;
                }
            }

            string more = StringTable.More + "...";

            g.DrawString(more, fontSmall, Brushes.Blue, new PointF(e.Bounds.Right - Border * 2 - e.Graphics.MeasureString(more, fontSmall).Width, e.Bounds.Top + 10));
        }
        private void SearchNow(int page)
        {
            listBoxResult.Items.Clear();

            amazonProgressControl.labelStatus.Text  = StringTable.SearchWebService;
            amazonProgressControl.progressBar.Value = 0;

            amazonProgressControl.Visible = true;
            amazonProgressControl.Refresh();

            ItemSearchRequest request = new ItemSearchRequest();

            request.Artist        = textBoxArtist.Text;
            request.Title         = textBoxTitle.Text;
            request.Keywords      = textBoxEAN.Text;
            request.ItemPage      = (page + 1).ToString();
            request.ResponseGroup = new string[] { "Large", "Tracks" };


            request.SearchIndex = "Music";

            AmazonSort sort = ((AmazonSortItem)comboBoxSort.Items[comboBoxSort.SelectedIndex]).sort;

            switch (sort)
            {
            case AmazonSort.YearDescend:
                request.Sort = "-releasedate";
                break;

            case AmazonSort.YearAscend:
                request.Sort = "releasedate";
                break;

            case AmazonSort.TitleAscend:
                request.Sort = "titlerank";
                break;

            case AmazonSort.TitleDescend:
                request.Sort = "-titlerank";
                break;

            case AmazonSort.BestSelling:
                request.Sort = "salesrank";
                break;
            }

            AWSECommerceServicePortTypeClient amazonClient = new AWSECommerceServicePortTypeClient();

            ItemSearch itemSearch = new ItemSearch();

            itemSearch.Request        = new ItemSearchRequest[] { request };
            itemSearch.AWSAccessKeyId = "0FN016GTSMZHJD0C7YG2";
            itemSearch.AssociateTag   = "hitbase-21";

            bool nothingFound = false;
            ItemSearchResponse searchResult = null;

            try
            {
                searchResult = amazonClient.ItemSearch(itemSearch);
            }
            catch
            {
                nothingFound = true;
            }

            if (!nothingFound)
            {
                int totalCount = Convert.ToInt32(searchResult.Items[0].TotalResults);
                labelResult.Text = String.Format(StringTable.Result, totalCount);

                if (totalCount < 1)         // Leider nichts gefunden
                {
                    amazonProgressControl.Visible = false;
                    return;
                }

                WebClient webclient = new WebClient();
                webclient.UseDefaultCredentials = true;
                webclient.Proxy.Credentials     = CredentialCache.DefaultCredentials;

                amazonProgressControl.progressBar.Maximum = searchResult.Items[0].Item.Length;

                int count = 0;
                foreach (Items searchItems in searchResult.Items)
                {
                    foreach (Item details in searchItems.Item)
                    {
                        amazonProgressControl.labelStatus.Text = String.Format(StringTable.ReadingResult, count + 1, searchItems.Item.Length);
                        amazonProgressControl.labelStatus.Refresh();

                        CDListBoxWithCoverItem item = new CDListBoxWithCoverItem();
                        if (details.ItemAttributes.Artist != null && details.ItemAttributes.Artist.Length > 0)
                        {
                            item.Artist = details.ItemAttributes.Artist[0].ToString();
                        }
                        item.Title = details.ItemAttributes.Title;

                        item.Label = details.ItemAttributes.Label;
                        if (details.ItemAttributes.ReleaseDate != null)
                        {
                            item.Year = details.ItemAttributes.ReleaseDate;
                        }
                        else
                        {
                            if (details.ItemAttributes.PublicationDate != null)
                            {
                                item.Year = details.ItemAttributes.PublicationDate;
                            }
                        }
                        item.ASIN = details.ASIN;
                        item.EAN  = details.ItemAttributes.EAN;

                        /*if (details.CustomerReviews != null)
                         *  item.Ranking = details.CustomerReviews.AverageRating;
                         * else
                         *  item.Ranking = 0;*/

                        if (details.EditorialReviews != null && details.EditorialReviews.Length > 0)
                        {
                            item.EditorNotes = details.EditorialReviews[0].Content;
                        }

                        if (details.Tracks != null)
                        {
                            item.CD = new CDItem[details.Tracks.Length];
                            foreach (TracksDisc disc in details.Tracks)
                            {
                                int discNumber = Convert.ToInt32(disc.Number) - 1;
                                item.CD[discNumber]        = new CDItem();
                                item.CD[discNumber].Tracks = new string[disc.Track.Length];
                                foreach (TracksDiscTrack track in disc.Track)
                                {
                                    int trackNumber = Convert.ToInt32(track.Number) - 1;

                                    // Das hier wird wohl (von WCF?) fälschlicherweise als CodePage 1252 interpretiert, obwohl es UTF-8 ist.
                                    // Muss dann konvertiert werden.
                                    Encoding iso      = Encoding.GetEncoding("Windows-1252");
                                    Encoding utf8     = Encoding.UTF8;
                                    byte[]   utfBytes = iso.GetBytes(track.Value);
                                    string   msg      = utf8.GetString(utfBytes);

                                    item.CD[discNumber].Tracks[trackNumber] = msg;
                                }
                            }
                        }
                        else
                        {
                            // Wenn keine Track-Daten vorhanden sind, ein Pseudo-Track erzeugen
                            item.CD              = new CDItem[1];
                            item.CD[0]           = new CDItem();
                            item.CD[0].Tracks    = new string[1];
                            item.CD[0].Tracks[0] = StringTable.Unknown;
                        }

                        if (details.SmallImage != null)
                        {
                            item.smallImageUrl = details.SmallImage.URL;
                        }

                        if (details.MediumImage != null)
                        {
                            item.mediumImageUrl = details.MediumImage.URL;
                        }

                        if (details.LargeImage != null)
                        {
                            item.largeImageUrl = details.LargeImage.URL;
                        }

                        if (details.ImageSets != null && details.ImageSets.Length > 0)
                        {
                            //foreach (ImageSet[] imgSet in details.ImageSets)
                            {
                                foreach (ImageSet imageSet in details.ImageSets)
                                {
                                    if (imageSet.Category == "variant")
                                    {
                                        if (imageSet.SmallImage != null)
                                        {
                                            item.backCoverSmallImageUrl = imageSet.SmallImage.URL;
                                        }

                                        if (imageSet.MediumImage != null)
                                        {
                                            item.backCoverMediumImageUrl = imageSet.MediumImage.URL;
                                        }

                                        if (imageSet.LargeImage != null)
                                        {
                                            item.backCoverLargeImageUrl = imageSet.LargeImage.URL;
                                        }
                                    }
                                }
                            }
                        }

                        item.Image = GetImage(webclient, details);

                        listBoxResult.Items.Add(item);

                        amazonProgressControl.progressBar.PerformStep();

                        count++;
                    }
                }

                if (totalCount > 10)
                {
                    pagerControl.NumberOfPages = (totalCount + 9) / 10;
                    pagerControl.Visible       = true;
                }
                else
                {
                    pagerControl.Visible = false;
                }
            }
            else
            {
                labelResult.Text     = String.Format(StringTable.Result, 0);
                pagerControl.Visible = false;
            }

            amazonProgressControl.Visible = false;
        }