示例#1
0
        void bwCDList_DoWork(object sender, DoWorkEventArgs e)
        {
            SafeObservableCollection <AlbumItem> items = new SafeObservableCollection <AlbumItem>();

            int count = 0;

            Big3.Hitbase.DataBaseEngine.Condition searchCondition = Big3.Hitbase.DataBaseEngine.Condition.Combine(Condition, ConditionFromTree);

            using (DataBaseView view = AlbumView.CreateView(this.DataBase, this.CdListFields.GetFields(), new SortFieldCollection(), 0, searchCondition))
            {
                object[] values;

                while ((values = view.Read()) != null)
                {
                    AlbumItem newItem = new AlbumItem();
                    newItem.ID = (int)values[0];

                    newItem.Items = new object[values.Length - 1];
                    FillRowValues(newItem, values);
                    items.AddItemFromThread(newItem);

                    count++;
                }
            }

            e.Result = items;
        }
示例#2
0
        void LoadImage(string imageUrl, string iSize, string iTitle, string mediaUrl, string id)
        {
            try
            {
                PictureSearchItem psi = new PictureSearchItem();

                BackgroundWorker bw = new BackgroundWorker();
                bw.DoWork += delegate(object s, DoWorkEventArgs args)
                {
                    try
                    {
                        WebClient wc = new WebClient();
                        wc.UseDefaultCredentials = true;
                        wc.Proxy.Credentials     = CredentialCache.DefaultCredentials;
                        byte[] imageBytes = wc.DownloadData(imageUrl);

                        MemoryStream m = new MemoryStream(imageBytes);

                        psi.BitmapImage = ImageLoader.GetBitmapImageFromMemoryStream(m);
                        psi.BitmapImage.Freeze();

                        psi.Visibility = System.Windows.Visibility.Collapsed;
                    }
                    catch
                    {
                    }
                };
                psi.Title = iTitle;
                psi.Size  = iSize;

                psi.Visibility           = System.Windows.Visibility.Visible;
                psi.ImageResult          = new ImageResult();
                psi.ImageResult.MediaUrl = mediaUrl;
                psi.Id = id;
                PictureSearchItems.AddItemFromThread(psi);
                bw.RunWorkerAsync();
            }
            catch
            {
            }
        }
示例#3
0
        void bwTrackList_DoWork(object sender, DoWorkEventArgs e)
        {
            SafeObservableCollection <MyMusicListItem> items = new SafeObservableCollection <MyMusicListItem>();

            int count = 0;

            FieldCollection fc = new FieldCollection();

            int internalFieldsCount = 0;

            foreach (Field field in internalFields)
            {
                if (this.trackListFields.SingleOrDefault(x => x.Field == field) == null)
                {
                    fc.Add(field);
                    internalFieldsCount++;
                }
            }

            fc.AddRange(this.trackListFields.GetFields());

            int soundFileIndex = fc.IndexOf(Field.TrackSoundFile);

            Big3.Hitbase.DataBaseEngine.Condition searchCondition = Big3.Hitbase.DataBaseEngine.Condition.Combine(Condition, ConditionFromTree);

            using (DataBaseView view = TrackView.CreateView(this.DataBase, fc, this.trackListSort, 0, searchCondition))
            {
                object[] values;

                while ((values = view.Read()) != null)
                {
                    MyMusicListItem newItem = new MyMusicListItem();

                    FillRowValues(newItem, values, soundFileIndex, internalFieldsCount);
                    items.AddItemFromThread(newItem);

                    count++;
                }
            }

            e.Result = items;
        }
示例#4
0
        void bwAlbumView_DoWork(object sender, DoWorkEventArgs e)
        {
            PersonGroupCatalogViewDataSet personGroupsDataSet = new PersonGroupCatalogViewDataSet();
            PersonGroupTableAdapter       ta = new PersonGroupTableAdapter(DataBase);

            ta.Fill(personGroupsDataSet.PersonGroup);

            foreach (PersonGroupCatalogViewDataSet.PersonGroupRow row in personGroupsDataSet.PersonGroup)
            {
                // Leeren Interpreten nicht anzeigen. Kann schon mal angelegt werden.
                if (string.IsNullOrEmpty(row.Name))
                {
                    continue;
                }

                PersonGroupViewItem newItem = new PersonGroupViewItem();
                FillPersonGroupItem(row, newItem);
                items.AddItemFromThread(newItem);
            }

            e.Result = items;
        }
        void bwTrackList_DoWork(object sender, DoWorkEventArgs e)
        {
            string sql = "";

            Big3.Hitbase.DataBaseEngine.Condition searchCondition = Big3.Hitbase.DataBaseEngine.Condition.Combine(Condition, ConditionFromTree);

            switch (CurrentViewMode)
            {
            case MainControls.CurrentViewMode.ArtistTable:
                sql = "SELECT PersonGroup.Name, COUNT(*) AS TotalCount, SUM(Cast(Track.Length as bigint)) AS TotalLength " +
                      "FROM Track INNER JOIN " +
                      "PersonGroup ON Track.ArtistID = PersonGroup.PersonGroupID " +
                      "GROUP BY PersonGroup.Name, PersonGroup.SaveAs";
                if (searchCondition != null && searchCondition.Count > 0)
                {
                    if (searchCondition[0].Value.ToString() == "?")
                    {
                        sql += " HAVING PersonGroup.SaveAs < 'A' OR PersonGroup.SaveAs > 'ZZZZZ'";
                    }
                    else
                    {
                        sql += " HAVING PersonGroup.SaveAs >= '" + searchCondition[0].Value + "' AND PersonGroup.SaveAs < '" + searchCondition[0].Value + "ZZZZZ'";
                    }
                }

                sql += " ORDER BY PersonGroup.SaveAs";

                break;

            case MainControls.CurrentViewMode.ComposerTable:
                sql = "SELECT PersonGroup.Name, COUNT(*) AS TotalCount, SUM(Cast(Track.Length as bigint)) AS TotalLength " +
                      "FROM Track INNER JOIN " +
                      "PersonGroup ON Track.ComposerID = PersonGroup.PersonGroupID " +
                      "GROUP BY PersonGroup.Name, PersonGroup.SaveAs ";
                if (searchCondition != null && searchCondition.Count > 0)
                {
                    if (searchCondition[0].Value.ToString() == "?")
                    {
                        sql += " HAVING PersonGroup.SaveAs < 'A' OR PersonGroup.SaveAs > 'ZZZZZ'";
                    }
                    else
                    {
                        sql += " HAVING PersonGroup.SaveAs >= '" + searchCondition[0].Value + "' AND PersonGroup.SaveAs < '" + searchCondition[0].Value + "ZZZZZ'";
                    }
                }

                sql += " ORDER BY PersonGroup.SaveAs";

                break;

            case MainControls.CurrentViewMode.GenreTable:
                sql = "SELECT Category.Name, COUNT(*) AS TotalCount, SUM(Cast(Track.Length as bigint)) AS TotalLength " +
                      "FROM Track LEFT JOIN " +
                      "CD ON Track.CDID = CD.CDID LEFT JOIN " +
                      "Category ON Track.CategoryID = Category.CategoryID OR CD.CategoryID = Category.CategoryID " +
                      "GROUP BY Category.Name";
                if (searchCondition != null && searchCondition.Count > 0)
                {
                    sql += " HAVING Category.Name LIKE '" + searchCondition[0].Value + "%'";
                }
                break;

            case MainControls.CurrentViewMode.MediumTable:
                sql = "SELECT Medium.Name, COUNT(*) AS TotalCount, SUM(Cast(Track.Length as bigint)) AS TotalLength " +
                      "FROM Track INNER JOIN " +
                      "CD ON Track.CDID = CD.CDID LEFT JOIN " +
                      "Medium ON CD.MediumID = Medium.MediumID " +
                      "GROUP BY Medium.Name";
                if (searchCondition != null && searchCondition.Count > 0)
                {
                    sql += " HAVING Medium.Name LIKE '" + searchCondition[0].Value + "%'";
                }
                break;

            case MainControls.CurrentViewMode.YearTable:
                sql = "SELECT Track.YearRecorded, COUNT(*) AS TotalCount, SUM(CAST(Track.Length as bigint)) AS TotalLength " +
                      "FROM Track " +
                      "GROUP BY Track.YearRecorded";
                if (searchCondition != null && searchCondition.Count > 0)
                {
                    if (searchCondition.Count > 1)
                    {
                        sql += " HAVING Track.YearRecorded >= " + searchCondition[0].Value + " AND Track.YearRecorded < " + searchCondition[1].Value;
                    }
                    else
                    {
                        sql += " HAVING Track.YearRecorded=" + searchCondition[0].Value + "";
                    }
                }
                break;

            case MainControls.CurrentViewMode.RatingTable:
                sql = "SELECT Track.Rating, COUNT(*) AS TotalCount, SUM(CAST(Track.Length as bigint)) AS TotalLength " +
                      "FROM Track " +
                      "GROUP BY Track.Rating";
                if (searchCondition != null && searchCondition.Count > 0 && searchCondition[0].Value != null)
                {
                    sql += " HAVING Track.Rating = " + searchCondition[0].Value + "";
                }
                break;
            }

            SafeObservableCollection <TrackListItem> items     = new SafeObservableCollection <TrackListItem>();
            Dictionary <string, TrackListItem>       dictItems = new Dictionary <string, TrackListItem>(); // Für schnelleren Zugriff

            using (DataBaseView view = DataBaseView.Create(this.DataBase, sql))
            {
                object[] values;

                while ((values = view.Read()) != null)
                {
                    TrackListItem trackListItem = new TrackListItem();
                    trackListItem.Title = values[0].ToString();
                    if (CurrentViewMode == MainControls.CurrentViewMode.YearTable && trackListItem.Title == "0")
                    {
                        trackListItem.Title = StringTable.Undefined;
                    }

                    trackListItem.Count  = (int)values[1];
                    trackListItem.Length = (long)values[2];
                    trackListItem.Rating = 0;
                    dictItems.Add(trackListItem.Title, trackListItem);
                    items.AddItemFromThread(trackListItem);
                }
            }

            // Rating ermitteln
            sql = "";
            switch (CurrentViewMode)
            {
            case MainControls.CurrentViewMode.ArtistTable:
            {
                sql = "SELECT PersonGroup.Name, AVG(CAST(Track.Rating AS decimal)) AS Expr3, PersonGroup.SaveAs " +
                      "FROM Track INNER JOIN " +
                      "PersonGroup ON Track.ArtistID = PersonGroup.PersonGroupID " +
                      "WHERE (Track.Rating > 0) " +
                      "GROUP BY PersonGroup.Name, PersonGroup.SaveAs";
                break;
            }

            case MainControls.CurrentViewMode.ComposerTable:
            {
                sql = "SELECT PersonGroup.Name, AVG(CAST(Track.Rating AS decimal)) AS Expr3 " +
                      "FROM Track INNER JOIN " +
                      "PersonGroup ON Track.ComposerID = PersonGroup.PersonGroupID " +
                      "WHERE (Track.Rating > 0) " +
                      "GROUP BY PersonGroup.Name";
                break;
            }

            case MainControls.CurrentViewMode.GenreTable:
            {
                sql = "SELECT category.Name, AVG(CAST(Track.Rating AS decimal)) AS Expr3 " +
                      "FROM Track LEFT JOIN " +
                      "CD ON Track.CDID = CD.CDID LEFT JOIN " +
                      "Category AS Category ON Track.CategoryID = Category.CategoryID OR CD.CategoryID = Category.CategoryID " +
                      "WHERE        (Track.Rating > 0) " +
                      "GROUP BY Category.Name";

                break;
            }

            case MainControls.CurrentViewMode.YearTable:
            {
                sql = "SELECT Track.YearRecorded, AVG(CAST(Track.Rating AS decimal)) AS Expr3 " +
                      "FROM Track " +
                      "WHERE        (Track.Rating > 0) " +
                      "GROUP BY Track.YearRecorded";

                break;
            }
            }

            if (sql != "")
            {
                using (DataBaseView view = DataBaseView.Create(this.DataBase, sql))
                {
                    object[] values;

                    while ((values = view.Read()) != null)
                    {
                        string key = values[0].ToString();

                        if (CurrentViewMode == MainControls.CurrentViewMode.YearTable && key == "0")
                        {
                            key = StringTable.Undefined;
                        }

                        if (dictItems.ContainsKey(key))
                        {
                            TrackListItem trackListItem = dictItems[key];
                            trackListItem.Rating = (double)(decimal)values[1];
                        }
                    }
                }
            }

            e.Result = items;
        }
示例#6
0
        void bwTrackList_DoWork(object sender, DoWorkEventArgs e)
        {
            string sql = "";

            switch (CurrentViewMode)
            {
            case MainControls.CurrentViewMode.ArtistDetails:
            case MainControls.CurrentViewMode.ComposerDetails:
                sql = GetArtistDetailsSql();
                if (Condition != null && Condition.Count > 0 && Condition[0].Value != null)
                {
                    sql += " HAVING PersonGroup.Name LIKE '" + Condition[0].Value + "%'";
                }
                break;

                //case MainControls.CurrentViewMode.ComposerTable:
                //    sql = "SELECT PersonGroup.Name, COUNT(*) AS TotalCount, SUM(Cast(Track.Length as bigint)) AS TotalLength " +
                //        "FROM Track INNER JOIN " +
                //        "PersonGroup ON Track.ComposerID = PersonGroup.PersonGroupID " +
                //        "GROUP BY PersonGroup.Name";
                //    if (Condition != null && Condition.Count > 0)
                //    {
                //        sql += " HAVING PersonGroup.Name LIKE '" + Condition[0].Value + "%'";
                //    }
                //    break;

                //case MainControls.CurrentViewMode.GenreTable:
                //    sql = "SELECT Category.Name, COUNT(*) AS TotalCount, SUM(Cast(Track.Length as bigint)) AS TotalLength " +
                //        "FROM Track INNER JOIN " +
                //        "Category ON Track.CategoryID = Category.CategoryID " +
                //        "GROUP BY Category.Name";
                //    if (Condition != null && Condition.Count > 0)
                //    {
                //        sql += " HAVING Category.Name LIKE '" + Condition[0].Value + "%'";
                //    }
                //    break;
                //case MainControls.CurrentViewMode.YearTable:
                //    sql = "SELECT Track.YearRecorded, COUNT(*) AS TotalCount, SUM(CAST(Track.Length as bigint)) AS TotalLength " +
                //        "FROM Track " +
                //        "GROUP BY Track.YearRecorded";
                //    break;
                //case MainControls.CurrentViewMode.RatingTable:
                //    sql = "SELECT Track.Rating, COUNT(*) AS TotalCount, SUM(CAST(Track.Length as bigint)) AS TotalLength " +
                //        "FROM Track " +
                //        "GROUP BY Track.Rating";
                //    if (Condition != null && Condition.Count > 0)
                //    {
                //        sql += " HAVING Track.Rating = " + Condition[0].Value + "";
                //    }
                //    break;
            }

            SafeObservableCollection <TrackListItem> items = new SafeObservableCollection <TrackListItem>();

            using (DataBaseView view = DataBaseView.Create(this.DataBase, sql))
            {
                object[] values;

                while ((values = view.Read()) != null)
                {
                    TrackListItem trackListItem = new TrackListItem();

                    ReadValues(values, trackListItem);

                    items.AddItemFromThread(trackListItem);
                }
            }

            e.Result = items;
        }
示例#7
0
        // searchText = Search for Text
        // count = number of images per search request
        private SearchResponse SearchImageRequest(string searchText, int count)
        {
            tableLayoutPanel.Controls.Clear();

            if (count > 0)
            {
                request = new SearchRequest();
                // Common request fields (required)
                //request.AppId = AppId;
                request.Query   = searchText;
                request.Sources = new SourceType[] { SourceType.Image };

                // Common request fields (optional)
                //request.Version = "2.1";
                request.Market         = "en-us";
                request.Adult          = AdultOption.Moderate;
                request.AdultSpecified = true;

                // Image-specific request fields (optional)
                request.Image                 = new ImageRequest();
                request.Image.Count           = (uint)count;
                request.Image.CountSpecified  = true;
                request.Image.Offset          = (uint)currentPage * (uint)count;
                request.Image.OffsetSpecified = true;

                if (comboBoxSize.SelectedIndex == 1)
                {
                    request.Image.Filters = new String[] { "Size:Small" }
                }
                ;
                if (comboBoxSize.SelectedIndex == 2)
                {
                    request.Image.Filters = new String[] { "Size:Medium" }
                }
                ;
                if (comboBoxSize.SelectedIndex == 3)
                {
                    request.Image.Filters = new String[] { "Size:Large" }
                }
                ;

                //request.Image.Filters = new String[] { "Face:Portrait", "Size:Medium" };

                lastCount = (uint)count;
            }
            else
            {
                request.Image.Offset = request.Image.Offset + lastCount;
            }

            // Send the request; display the response.
            //if (liveSearchService == null)
            //    liveSearchService = new LiveSearchService();
            //SearchResponse response = liveSearchService.Search(request);
            PictureSearchItems.Clear();
            SearchImages(searchText, 20);
            int col = 0;
            int row = 0;

            foreach (PictureSearchItem psi in PictureSearchItems)
            {
                Panel panel = new Panel();
                panel.BackColor = Color.White;
                panel.Dock      = DockStyle.Fill;
                panel.Padding   = new Padding(10);
                panel.Tag       = psi.ImageResult;

                PictureBox pb = new PictureBox();
                pb.Tag               = psi.ImageResult.Url;
                pb.Image             = null;
                pb.SizeMode          = PictureBoxSizeMode.Zoom;
                pb.Dock              = DockStyle.Fill;
                pb.MouseEnter       += new EventHandler(panel_MouseEnter);
                pb.MouseLeave       += new EventHandler(panel_MouseLeave);
                pb.MouseClick       += new MouseEventHandler(item_MouseClick);
                pb.MouseDoubleClick += new MouseEventHandler(item_MouseDoubleClick);

                panel.Controls.Add(pb);

                Label lbl = new Label();
                lbl.AutoSize          = false;
                lbl.Height            = 20;
                lbl.BackColor         = Color.Transparent;
                lbl.TextAlign         = ContentAlignment.MiddleCenter;
                lbl.Text              = psi.ImageResult.Title;
                lbl.Dock              = DockStyle.Bottom;
                lbl.MouseEnter       += new EventHandler(panel_MouseEnter);
                lbl.MouseLeave       += new EventHandler(panel_MouseLeave);
                lbl.MouseClick       += new MouseEventHandler(item_MouseClick);
                lbl.MouseDoubleClick += new MouseEventHandler(item_MouseDoubleClick);
                panel.Controls.Add(lbl);

                Label lblSize = new Label();
                lblSize.AutoSize  = false;
                lblSize.Height    = 20;
                lblSize.BackColor = Color.Transparent;
                lblSize.TextAlign = ContentAlignment.MiddleCenter;
                if (psi.Size != "" || psi.ImageResult.FileSize != 0)
                {
                    lblSize.Text = string.Format("{0} · {1} KB", psi.Size, psi.ImageResult.FileSize);
                }
                else
                {
                    lblSize.Text = "";
                }
                lblSize.Dock              = DockStyle.Bottom;
                lblSize.MouseEnter       += new EventHandler(panel_MouseEnter);
                lblSize.MouseLeave       += new EventHandler(panel_MouseLeave);
                lblSize.MouseClick       += new MouseEventHandler(item_MouseClick);
                lblSize.MouseDoubleClick += new MouseEventHandler(item_MouseDoubleClick);
                panel.Controls.Add(lblSize);

                tableLayoutPanel.Controls.Add(panel);
                tableLayoutPanel.SetCellPosition(panel, new TableLayoutPanelCellPosition(col, row));
                Console.WriteLine(psi.ImageResult.MediaUrl);
                Console.WriteLine("Page Title: " + psi.ImageResult.Title);
                Console.WriteLine("Page URL: " + psi.ImageResult.Url);
                Console.WriteLine(
                    "Dimensions: "
                    + psi.ImageResult.Width
                    + "x"
                    + psi.ImageResult.Height);
                Console.WriteLine("Thumbnail URL: " + psi.ImageResult.DisplayUrl);
                Console.WriteLine();
                col++;
                if (col == 5)
                {
                    col = 0;
                    row++;
                }

                LoadImage(pb);
                // LoadImage(psi.ImageResult.Url, psi.Size, psi.Title, psi.ImageResult.MediaUrl);
                //Thread thread = new Thread(new ParameterizedThreadStart(LoadImage));
                //thread.Start(pb);
            }

            pagerControl.NumberOfPages = 2;// (int)PictureSearchItems.Count / count;

            /*if (response.Image != null && response.Image.Results != null)
             * {
             *  int col = 0;
             *  int row = 0;
             *  foreach (ImageResult result in response.Image.Results)
             *  {
             *      Panel panel = new Panel();
             *      panel.BackColor = Color.White;
             *      panel.Dock = DockStyle.Fill;
             *      panel.Padding = new Padding(10);
             *      panel.Tag = result;
             *
             *      PictureBox pb = new PictureBox();
             *      pb.Tag = result.Thumbnail.Url;
             *      pb.Image = null;
             *      pb.SizeMode = PictureBoxSizeMode.Zoom;
             *      pb.Dock = DockStyle.Fill;
             *      pb.MouseEnter += new EventHandler(panel_MouseEnter);
             *      pb.MouseLeave += new EventHandler(panel_MouseLeave);
             *      pb.MouseClick += new MouseEventHandler(item_MouseClick);
             *      pb.MouseDoubleClick += new MouseEventHandler(item_MouseDoubleClick);
             *
             *      panel.Controls.Add(pb);
             *
             *      Label lbl = new Label();
             *      lbl.AutoSize = false;
             *      lbl.Height = 20;
             *      lbl.BackColor = Color.Transparent;
             *      lbl.TextAlign = ContentAlignment.MiddleCenter;
             *      lbl.Text = result.Title;
             *      lbl.Dock = DockStyle.Bottom;
             *      lbl.MouseEnter += new EventHandler(panel_MouseEnter);
             *      lbl.MouseLeave += new EventHandler(panel_MouseLeave);
             *      lbl.MouseClick += new MouseEventHandler(item_MouseClick);
             *      lbl.MouseDoubleClick += new MouseEventHandler(item_MouseDoubleClick);
             *      panel.Controls.Add(lbl);
             *
             *      Label lblSize = new Label();
             *      lblSize.AutoSize = false;
             *      lblSize.Height = 20;
             *      lblSize.BackColor = Color.Transparent;
             *      lblSize.TextAlign = ContentAlignment.MiddleCenter;
             *      lblSize.Text = string.Format("{0} x {1} · {2} KB", result.Width.ToString(), result.Height.ToString(), (result.FileSize + 1023) / 1024);
             *      lblSize.Dock = DockStyle.Bottom;
             *      lblSize.MouseEnter += new EventHandler(panel_MouseEnter);
             *      lblSize.MouseLeave += new EventHandler(panel_MouseLeave);
             *      lblSize.MouseClick += new MouseEventHandler(item_MouseClick);
             *      lblSize.MouseDoubleClick += new MouseEventHandler(item_MouseDoubleClick);
             *      panel.Controls.Add(lblSize);
             *
             *      tableLayoutPanel.Controls.Add(panel);
             *      tableLayoutPanel.SetCellPosition(panel, new TableLayoutPanelCellPosition(col, row));
             *      Console.WriteLine(result.MediaUrl);
             *      Console.WriteLine("Page Title: " + result.Title);
             *      Console.WriteLine("Page URL: " + result.Url);
             *      Console.WriteLine(
             *          "Dimensions: "
             + result.Width
             + "x"
             + result.Height);
             +      Console.WriteLine("Thumbnail URL: " + result.Thumbnail.Url);
             +      Console.WriteLine();
             +      col++;
             +      if (col == 5)
             +      {
             +          col = 0;
             +          row++;
             +      }
             +
             +      LoadImage(pb);
             +      //Thread thread = new Thread(new ParameterizedThreadStart(LoadImage));
             +      //thread.Start(pb);
             +  }
             +
             +  pagerControl.NumberOfPages = (int)response.Image.Total / count;
             + }
             + else
             + {
             +  pagerControl.NumberOfPages = 0;
             + }
             +
             + return response;
             * */
            return(null);
        }

        void SearchImages(string searchText, int maxCount)
        {
            WebClient wc = new WebClient();

            string[] allimages;

            // TODO OFFSET!!!
            string result = wc.DownloadString("http://www.bing.com/images/search?q=" + Uri.EscapeUriString(searchText));

            int index = 0;

            var m = Regex.Match(result, "(?<=img+.+src\\=[\x27\x22])(?<Url>[^\x27\x22]*)(?=[\x27\x22])", RegexOptions.IgnoreCase);

            int matchCount = 0;

            while (m.Success && matchCount < currentPage * 20 + 20)
            {
                for (int i = 1; i <= 2; i++)
                {
                    Group             g  = m.Groups[i];
                    CaptureCollection cc = g.Captures;
                    for (int j = 0; j < cc.Count; j++)
                    {
                        Capture c    = cc[j];
                        string  turl = c.ToString();
                        if (turl.StartsWith("http://"))
                        {
                            if (matchCount >= currentPage * 20)
                            {
                                LoadImage(turl, "", "", 0, turl, "");
                            }
                            matchCount++;
                        }
                    }
                }
                m = m.NextMatch();
            }
            return;

            for (int i = 0; i < currentPage * 20 + 20; i++)
            {
                int imageindex    = result.IndexOf("mid=", index + 1);
                int imageindexEnd = result.IndexOf("mid=", imageindex + 10);
                if (imageindex < 1)
                {
                    continue;
                }

                if (imageindexEnd < imageindex)
                {
                    imageindexEnd = imageindex + 1000;
                }
                string foundimage = result.Substring(imageindex, imageindexEnd - imageindex);

                index = imageindexEnd - 10;

                int    tindex    = foundimage.IndexOf("img src=");
                int    tindexEnd = foundimage.IndexOf("\"", tindex + 10);
                string turl      = foundimage.Substring(tindex + 9, tindexEnd - tindex - 9);

                int nextindex = result.IndexOf("imgurl:&quot;", index + 13);

                // Größe, Ausmaße, Name, etc. ermitteln
                int indextitleend = 0;
                int indexsize     = 0;
                int indexsizeend  = 0;

                int indextitle = foundimage.IndexOf("t1=");
                indextitleend = foundimage.IndexOf("\"", indextitle + 4);
                string imageTitle = foundimage.Substring(indextitle + 4, indextitleend - indextitle - 4);

                indexsize    = foundimage.IndexOf("t2=");
                indexsizeend = foundimage.IndexOf("\"", indexsize + 4);
                string imageSize2 = foundimage.Substring(indexsize + 4, indexsizeend - indexsize - 4);

                int    sizewidthEnd  = foundimage.IndexOf("x", indexsize + 4);
                int    sizeheightEnd = foundimage.IndexOf(" ", sizewidthEnd + 2);
                string imageSize     = foundimage.Substring(indexsize + 4, sizeheightEnd - indexsize - 4);

                int    indexsizeFile    = foundimage.IndexOf(" ", sizeheightEnd + 1);
                int    indexsizeFileEnd = foundimage.IndexOf(" ", indexsizeFile + 1);
                string sizeFile         = foundimage.Substring(indexsizeFile + 1, indexsizeFileEnd - indexsizeFile);
                uint   kSize            = Convert.ToUInt32(sizeFile);

                int    indexurl    = foundimage.IndexOf("t3=");
                int    indexurlend = foundimage.IndexOf("\"", indexurl + 4);
                string orgurl      = foundimage.Substring(indexurl + 4, indexurlend - indexurl - 4);

                int    idurl    = foundimage.IndexOf("mid=");
                int    idurlend = foundimage.IndexOf("\"", idurl + 5);
                string id       = foundimage.Substring(idurl + 5, idurlend - idurl - 5);

                int    nPos   = 0;
                string iSize  = "";
                string iTitle = "";

                if (i < currentPage * 20)
                {
                    continue;
                }

                if (indexsize > 0)
                {
                    if (imageSize.Length > 4)
                    {
                        LoadImage(turl, imageSize, imageTitle, kSize, orgurl, id);
                    }
                }

                if (index < 0)
                {
                    break;
                }
            }
        }

        void LoadImage(string imageUrl, string iSize, string iTitle, uint kSize, string mediaUrl, string id)
        {
            try
            {
                PictureSearchItem psi = new PictureSearchItem();

                BackgroundWorker bw = new BackgroundWorker();
                bw.DoWork += delegate(object s, DoWorkEventArgs args)
                {
                    try
                    {
                        WebClient wc = new WebClient();
                        wc.UseDefaultCredentials = true;
                        wc.Proxy.Credentials     = CredentialCache.DefaultCredentials;
                        byte[] imageBytes = wc.DownloadData(imageUrl);

                        MemoryStream m = new MemoryStream(imageBytes);

                        psi.BitmapImage = ImageLoader.GetBitmapImageFromMemoryStream(m);
                        psi.BitmapImage.Freeze();

                        psi.Visibility = System.Windows.Visibility.Collapsed;
                    }
                    catch
                    {
                    }
                };
                psi.Title = iTitle;
                psi.Size  = iSize;

                psi.Visibility                = System.Windows.Visibility.Visible;
                psi.ImageResult               = new ImageResult();
                psi.ImageResult.MediaUrl      = mediaUrl;
                psi.ImageResult.DisplayUrl    = imageUrl;
                psi.ImageResult.Url           = imageUrl;
                psi.ImageResult.Thumbnail     = new Thumbnail();
                psi.ImageResult.Thumbnail.Url = imageUrl;
                psi.ImageResult.FileSize      = kSize;
                //psi.ImageResult.Id = id;
                psi.Id = id;
                PictureSearchItems.AddItemFromThread(psi);
                bw.RunWorkerAsync();
            }
            catch
            {
            }
        }

        void item_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            //PictureSearchItem pictureSearchItem = PictureSearchItems[0];

            if (!DownloadSelectedImage())
            {
                return;
            }

            DialogResult = DialogResult.OK;
            Close();
        }

        void item_MouseClick(object sender, MouseEventArgs e)
        {
            Control c = (Control)sender;

            if (!(c is Panel))
            {
                Panel       p      = (Panel)c.Parent;
                ImageResult imgRes = (ImageResult)p.Tag;
                selectedImageResult = imgRes;
                if (selectedPanel != null)
                {
                    selectedPanel.BackColor = Color.White;
                }
                selectedPanel      = p;
                c.Parent.BackColor = Color.FromArgb(162, 199, 235);
                UpdateWindowState();
            }
        }

        void LoadImage(object data)
        {
            try
            {
                BackgroundWorker bw = new BackgroundWorker();
                bw.DoWork += delegate(object s, DoWorkEventArgs args)
                {
                    try
                    {
                        PictureBox pb  = (PictureBox)data;
                        string     url = (string)pb.Tag;
                        WebClient  wc  = new WebClient();
                        wc.UseDefaultCredentials = true;
                        wc.Proxy.Credentials     = CredentialCache.DefaultCredentials;
                        byte[] imageBytes = wc.DownloadData(url);

                        MemoryStream m     = new MemoryStream(imageBytes);
                        Image        image = Image.FromStream(m);

                        args.Result = image;
                    }
                    catch
                    {
                    }
                };
                bw.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args)
                {
                    PictureBox pb = (PictureBox)data;
                    pb.Image = args.Result as Image;
                };
                bw.RunWorkerAsync();
            }
            catch
            {
            }
        }

        void panel_MouseLeave(object sender, EventArgs e)
        {
            Control c = (Control)sender;

            if (!(c is Panel))
            {
                Panel       p      = (Panel)c.Parent;
                ImageResult imgRes = (ImageResult)p.Tag;
                if (selectedImageResult == imgRes)
                {
                    p.BackColor = Color.FromArgb(162, 199, 235);
                }
                else
                {
                    p.BackColor = Color.White;
                }
            }
        }

        void panel_MouseEnter(object sender, EventArgs e)
        {
            Control c = (Control)sender;

            if (!(c is Panel))
            {
                Panel       p      = (Panel)c.Parent;
                ImageResult imgRes = (ImageResult)p.Tag;
                if (selectedImageResult != imgRes)
                {
                    c.Parent.BackColor = Color.WhiteSmoke;
                }
            }
        }