Inheritance: System.Windows.Forms.UserControl
コード例 #1
0
        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;
                    }
                }
            }
        }
コード例 #2
0
        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);
                        }
                    }
                }
            }
        }
コード例 #3
0
ファイル: frmAlbumEdit.cs プロジェクト: mnarowski/inzynieria
        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;
        }
コード例 #4
0
        public void DeleteSelectedAlbum()
        {
            AlbumIcon selectedAlbum = SelectedAlbum;

            if (selectedAlbum != null)
            {
                this.GalleryObjectSource.DeleteAlbum(selectedAlbum.AlbumObject);
                RefreshAlbumsView();
            }
            else
            {
                throw new NonSelectedAlbumException();
            }
        }
コード例 #5
0
        public void RefreshPhotosView()
        {
            AlbumIcon selectedAlbumIcon = GetSelectedAlbumIcon();

            if (selectedAlbumIcon != null)
            {
                LoadPhotos(selectedAlbumIcon.AlbumObject);
            }
            else
            {
                LoadPhotos(null);
            }

            this.panelPhotos.Refresh();
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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();
        }
コード例 #8
0
ファイル: PhotoGallery.cs プロジェクト: mnarowski/inzynieria
        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();
        }
コード例 #9
0
        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;
                    }
                }
            }
        }