private void buttonEditPhoto_Click(object sender, EventArgs e) { int chosenImageIndex = panelPhotoView.Controls.OfType <RadioButton>().FirstOrDefault(r => r.Checked).TabIndex; LazyPictureBox chosenLazyPictureBox = panelPhotoView.Controls.OfType <LazyPictureBox>().ElementAt(chosenImageIndex); Image chosenImage = chosenLazyPictureBox.Image; Form picEditor = new UI_EditPhoto(chosenImage); this.Close(); picEditor.ShowDialog(); }
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 loadAlbumPhotos() { const int k_Left = 40; const byte k_BottomReference = 10; int top = 5; int tabIndex = 100; foreach (Photo currentPhoto in m_CurrentAlbum.Photos) { LazyPictureBox currentLazyPictureBox = createLazyPictureBox(currentPhoto, ref tabIndex, top, k_Left); m_MyPhotosData.Add(currentLazyPictureBox.Name, currentPhoto); photosPanel.Invoke(new Action(() => photosPanel.Controls.Add(currentLazyPictureBox))); top = currentLazyPictureBox.Bottom + k_BottomReference; currentLazyPictureBox.MouseHover += this.LazyPictureBox_MouseHover; currentLazyPictureBox.MouseLeave += this.LazyPictureBox_MouseLeave; } }
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++; } }
private void lazyPictureBox_Click(object sender, EventArgs e) { LazyPictureBox clickedLazyPictureBox = sender as LazyPictureBox; photoBinding(clickedLazyPictureBox.Name); }