示例#1
0
        private void DrawThumbnail(Graphics g, MyImageType image)
        {
            if (image.bitmap == null)
            {
                return;
            }
            g.DrawRectangle(new Pen(Color.Tomato), image.thumbnail);
            Rectangle nr = image.thumbnail;

            nr.X     += (nr.Width - image.bitmap.Width) / 2;
            nr.Y     += 2;
            nr.Width  = image.bitmap.Width;
            nr.Height = image.bitmap.Height;
            g.DrawImage(image.bitmap, nr);


            g.DrawString(image.name, new Font("Verdana", 6), new SolidBrush(Color.Black),
                         image.thumbnail.Left, image.thumbnail.Bottom - 25);
        }
示例#2
0
        private void LoadThumbnails(String category)
        {
            if (last_cat_read == category)
            {
                this.Refresh();
                return;
            }

            last_cat_read = category;

            Cursor.Current = Cursors.WaitCursor;
            String url  = "http://tools.wikimedia.de/~daniel/WikiSense/CategoryIntersect.php?wikifam=commons.wikimedia.org&basecat=" + category + "&basedeep=1&mode=iul&go=Scan&raw=on&userlang=en";
            String text = ReadWebPage(url).Replace("_", " ");

            String[] lines = text.Split(new Char[] { '\n' });

            images.Clear();
            progressBar1.Maximum = lines.Length;
            progressBar1.Value   = 0;
            foreach (String l in lines)
            {
                progressBar1.Increment(1);
                if (l.Trim() == "")
                {
                    continue;
                }
                MyImageType image = new MyImageType();
                String[]    parts = l.Split(new Char[] { '\t' });
                image.name = parts[1];
                image.md5  = md5(image.url_name());
                if (image.MakeOrLoadThumbnail())
                {
                    images.Add(image);
                }
                this.Refresh();
            }
            Cursor.Current = Cursors.Arrow;
        }