Beispiel #1
0
        private void Form1_Shown(object sender, EventArgs e)
        {
            DirectoryInfo dir = new DirectoryInfo(Folder);

            JpgFiles = dir.EnumerateFiles("*.jpg", SearchOption.AllDirectories).ToArray();

            MyControls = new List <PictureControl>();
            foreach (FileInfo picture in JpgFiles)
            {
                PictureControl PicControl = new PictureControl();
                PicControl.Build(picture);
                MyControls.Add(PicControl);
            }
            for (int i = 0, x = 0, y = 0; i < MyControls.Count; i++)
            {
                PictureControl pic = MyControls[i];
                pic.Location = new Point(x + 10, y + 10);
                this.panel1.Controls.Add(pic);
                x += pic.Width;
                if (x > this.Width - pic.Width - 10)
                {
                    x  = 0;
                    y += pic.Height;
                }
            }
        }
Beispiel #2
0
        private void Form1_Resize(object sender, EventArgs e)
        {
            this.SuspendLayout();
            for (int i = 0, x = 0, y = 0; i < MyControls.Count; i++)
            {
                PictureControl pic = MyControls[i];
                pic.Location = new Point(x + 10, y + 10);
                x           += pic.Width;
                if (x > this.Width - pic.Width - 10)
                {
                    x  = 0;
                    y += pic.Height;
                }
            }

            this.ResumeLayout();
        }