private void RefreshAlbumsView() { foreach (Control ctrl in this.panelAlbums.Controls) { if (ctrl is AlbumIcon) { this.panelAlbums.Controls.Remove(ctrl); } } if (this.GalleryObjectSource != null) { if (this.GalleryObjectSource.Albums != null) { int nextLocation = topMargin; foreach (Album alb in this.GalleryObjectSource.Albums) { AlbumIcon albico = new AlbumIcon(); albico.Size = new Size(widthAlbumObject, heightAlbumObject); albico.Location = new Point(leftMargin, nextLocation); albico.Visible = true; albico.AlbumClick += new AlbumIcon.AlbumIconClick(AlbumIcon_Click); albico.AlbumObject = alb; this.panelAlbums.Controls.Add(albico); nextLocation += heightAlbumObject + topMargin; } } } }
private void toolStripMenuItem2_Click(object sender, EventArgs e) { ToolStripMenuItem menuItem = sender as ToolStripMenuItem; if (menuItem != null) { ContextMenuStrip albumMenu = menuItem.Owner as ContextMenuStrip; if (albumMenu != null) { Control controlSelected = albumMenu.SourceControl; if (controlSelected is PhotoIcon) { Photo photoToDelete = ((PhotoIcon)controlSelected).PhotoObject; if (MessageBox.Show(string.Concat("Czy na pewno chcesz usunąć zdjęcie \"", photoToDelete.vtitle, "\"?"), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { AlbumIcon selectedAlbumIco = GetSelectedAlbumIcon(); selectedAlbumIco.AlbumObject.DeletePhoto(photoToDelete); LoadPhotos(selectedAlbumIco.AlbumObject); } } } } }
public frmAlbumEdit(AlbumIcon albumToEdit, PhotoGallery parentPhotoGallery) { InitializeComponent(); album = albumToEdit; this.txtTitle.Text = this.Text = album.Title; this.txtAuthor.Text = album.AlbumObject.vauthor; this.txtDescription.Text = album.AlbumObject.vdescribe; this.pbMainPhoto.Image = album.MainImage; parentGallery = parentPhotoGallery; }
public void DeleteSelectedAlbum() { AlbumIcon selectedAlbum = SelectedAlbum; if (selectedAlbum != null) { this.GalleryObjectSource.DeleteAlbum(selectedAlbum.AlbumObject); RefreshAlbumsView(); } else { throw new NonSelectedAlbumException(); } }
public void RefreshPhotosView() { AlbumIcon selectedAlbumIcon = GetSelectedAlbumIcon(); if (selectedAlbumIcon != null) { LoadPhotos(selectedAlbumIcon.AlbumObject); } else { LoadPhotos(null); } this.panelPhotos.Refresh(); }
public AlbumIcon GetSelectedAlbumIcon() { AlbumIcon ico = null; foreach (Control ctrl in this.panelAlbums.Controls) { if (ctrl is AlbumIcon) { if (((AlbumIcon)ctrl).Selected == true) { ico = (AlbumIcon)ctrl; return(ico); } } } return(ico); }
public void RefreshAlbumsView() { foreach (Control ctrl in this.panelAlbums.Controls) { if (ctrl is AlbumIcon) { this.panelAlbums.Controls.Remove(ctrl); } } this.panelAlbums.AutoScrollPosition = new Point(0, 0); if (this.GalleryObjectSource != null) { this.GalleryObjectSource.Albums = DbService.GetAll <Album>().ToList <Album>(); if (this.GalleryObjectSource.Albums != null) { int nextLocation = topMargin; foreach (Album alb in this.GalleryObjectSource.Albums) { AlbumIcon albico = new AlbumIcon(); albico.Size = new Size(widthAlbumObject, heightAlbumObject); albico.Location = new Point(leftMargin, nextLocation); albico.Visible = true; albico.AlbumClick += new AlbumIcon.AlbumIconClick(AlbumIcon_Click); albico.ContextMenuStrip = this.cmAlbum; albico.AlbumObject = alb; this.panelAlbums.Controls.Add(albico); nextLocation += heightAlbumObject + topMargin * 2; } } } this.panelAlbums.Refresh(); }
public void RefreshAlbumsView() { foreach (Control ctrl in this.panelAlbums.Controls) { if (ctrl is AlbumIcon) { this.panelAlbums.Controls.Remove(ctrl); } } this.panelAlbums.AutoScrollPosition = new Point(0, 0); if (this.GalleryObjectSource != null) { this.GalleryObjectSource.Albums = DbService.GetAll<Album>().ToList<Album>(); if (this.GalleryObjectSource.Albums != null) { int nextLocation = topMargin; foreach (Album alb in this.GalleryObjectSource.Albums) { AlbumIcon albico = new AlbumIcon(); albico.Size = new Size(widthAlbumObject, heightAlbumObject); albico.Location = new Point(leftMargin, nextLocation); albico.Visible = true; albico.AlbumClick += new AlbumIcon.AlbumIconClick(AlbumIcon_Click); albico.ContextMenuStrip = this.cmAlbum; albico.AlbumObject = alb; this.panelAlbums.Controls.Add(albico); nextLocation += heightAlbumObject + topMargin * 2; } } } this.panelAlbums.Refresh(); }