private LazyPictureBox createAndFillPictBox(string i_PictureURL) { LazyPictureBox pictBox = new LazyPictureBox(); pictBox.Load(i_PictureURL); pictBox.SizeMode = PictureBoxSizeMode.StretchImage; return(pictBox); }
private void fillPanelByPhotos(IAlbumOperable i_FormToFill) { int index = 0; LazyPictureBox[] albumPictureBoxes = new LazyPictureBox[i_FormToFill.PhotosAlbum.Photos.Count]; double panelWidth = i_FormToFill.PhotosPanel.Width; int pictureWidth = (int)(panelWidth / 3); int pictureHeigt = pictureWidth; Point currPictureLocation = new Point(i_FormToFill.PhotosPanel.Location.X, i_FormToFill.PhotosPanel.Location.Y); i_FormToFill.PhotosPanel.Controls.Clear(); UILogicHelper.MakeControlsVisible(i_FormToFill.PhotosPanel, i_FormToFill.AlbumNameLabel); i_FormToFill.PhotosPanel.AutoScroll = true; i_FormToFill.AlbumNameLabel.Text = i_FormToFill.PhotosAlbum.Name; foreach (Photo photo in i_FormToFill.PhotosAlbum.Photos) { //check with static index: this for delete photoSerialNum albumPictureBoxes[index] = new LazyPictureBox(); int photoSerialNum = index; albumPictureBoxes[index].Click += (sender, e) => RunPictureShower(i_FormToFill.PhotosAlbum, (sender as PictureBox).Image, photoSerialNum); albumPictureBoxes[index].Location = currPictureLocation; albumPictureBoxes[index].Size = new Size(pictureWidth, pictureHeigt); albumPictureBoxes[index].SizeMode = PictureBoxSizeMode.StretchImage; i_FormToFill.PhotosPanel.Controls.Add(albumPictureBoxes[index]); currPictureLocation = new Point(currPictureLocation.X + pictureWidth, currPictureLocation.Y); index++; if ((index) % 3 == 0) { currPictureLocation = new Point(i_FormToFill.PhotosPanel.Location.X, currPictureLocation.Y + pictureHeigt); } } index = 0; new Thread(() => { foreach (Photo photo in i_FormToFill.PhotosAlbum.Photos) { albumPictureBoxes[index++].Load(photo.PictureNormalURL); } }).Start(); }