private LazyPictureBox createLazyPictureBox(Photo i_CurrentPhoto, ref int io_TabIndex, int i_Top, int i_Left) { LazyPictureBox currentPictureBox = new LazyPictureBox(); const string k_PictureBoxName = "photoPictureBox"; const int k_PictureBoxSize = 175; currentPictureBox.Size = new Size(k_PictureBoxSize, k_PictureBoxSize); currentPictureBox.Left = i_Left; currentPictureBox.Top = i_Top; currentPictureBox.SizeMode = PictureBoxSizeMode.StretchImage; currentPictureBox.Load(i_CurrentPhoto.PictureNormalURL); currentPictureBox.Name = string.Format("{0}{1}", k_PictureBoxName, io_TabIndex++); currentPictureBox.Click += new System.EventHandler(lazyPictureBox_Click); return(currentPictureBox); }
private void listBoxAlbums_SelectedIndexChanged(object sender, EventArgs e) { panelPhotoView.Controls.Clear(); int tabIdx = 0; int top = 3; int left = 3; Album m_SelectedAlbum = (Album)listBoxAlbums.SelectedItem; foreach (Photo photo in m_SelectedAlbum.Photos) { albumPhoto = new LazyPictureBox(); photoRadio = new RadioButton(); photoRadio.TabIndex = tabIdx; this.albumPhoto.Size = new System.Drawing.Size(85, 85); this.albumPhoto.Left = left; albumPhoto.Top = top; photoRadio.SetBounds(albumPhoto.Right + 7, (albumPhoto.Top + albumPhoto.Bottom) / 2, 15, 15); albumPhoto.SizeMode = PictureBoxSizeMode.StretchImage; albumPhoto.Load(photo.PictureNormalURL); albumPhoto.Paint += new PaintEventHandler(albumPhoto_Paint); photoRadio.CheckedChanged += new System.EventHandler(photoRadio_CheckedChanged); panelPhotoView.Controls.Add(albumPhoto); panelPhotoView.Controls.Add(photoRadio); if (left > 300) { top = albumPhoto.Bottom + 5; left = 3; } else { left = albumPhoto.Right + 30; } photoRadio.Image = albumPhoto.Image; tabIdx++; } }