コード例 #1
0
        private static void posterClick(object sender, EventArgs e)
        {
            PosterPictureBox pictureBox  = sender as PosterPictureBox;
            AboutPoster      aboutPoster = new AboutPoster(PanelForm, pictureBox.FilmId);

            PanelForm.Hide();
            aboutPoster.Show();
        }
コード例 #2
0
        public static void AddPostersToPanel(Panel panel, Form currentForm, CinemaEntities db)
        {
            List <Film> films = db.Films.ToList();

            PanelForm = currentForm;
            panel.Controls.Clear();

            int    leftPosition     = 10;
            int    topPosition      = 10;
            byte   countForEachRow  = 3;
            int    widthOfOnePoster = panel.Width / countForEachRow - leftPosition * 2;
            int    counter          = 1;
            string imagePath        = string.Empty;

            foreach (Film item in films)
            {
                imagePath = Path.Combine(Helper.GetPathToProjectFolder("Uploads"), item.PhotoName);
                PosterPictureBox pictureBox = new PosterPictureBox
                {
                    Cursor   = Cursors.Hand,
                    SizeMode = PictureBoxSizeMode.StretchImage,
                    Image    = Image.FromFile(imagePath),
                    Left     = leftPosition,
                    Top      = topPosition,
                    Width    = widthOfOnePoster,
                    Height   = 300,
                    FilmId   = item.Id
                };
                pictureBox.Click += new EventHandler(posterClick);
                panel.Controls.Add(pictureBox);
                leftPosition += widthOfOnePoster + 10;
                if (counter == countForEachRow)
                {
                    counter      = 0;
                    topPosition += pictureBox.Height + 10;
                    leftPosition = 10;
                }
                counter++;
            }
        }