private void PosterImage_Paint(object sender, PaintEventArgs e) { const int hspace = 5; const int vspace = 10; var image = ImageCache.GetImage(_model.PosterUrl); e.Graphics.DrawImage(image, new Rectangle() { X = hspace, Y = vspace, Width = PosterImage.Width - 2 * hspace, Height = (int)(image.Height * (PosterImage.Width / (float)image.Width) - 2 * vspace) }); }
private void MoviesList_DrawItem(object sender, DrawItemEventArgs e) { var lb = sender as ListBox; var movie = lb.Items[e.Index] as MovieViewModel; e.DrawBackground(); e.DrawFocusRectangle(); var image = ImageCache.GetImage(movie.PosterUrl); e.Graphics.DrawImage(image, new Rectangle() { X = e.Bounds.Left + 3, Y = e.Bounds.Top + 3, Width = 42, Height = 42 }, new Rectangle() { X = 0, Y = 0, Width = image.Width, Height = image.Height }, GraphicsUnit.Pixel); e.Graphics.DrawString(movie.Title, new Font(e.Font, FontStyle.Bold), Brushes.Black, e.Bounds.Left + 50, e.Bounds.Top + 8); e.Graphics.DrawString(movie.Director + ", " + movie.Year, e.Font, Brushes.Black, e.Bounds.Left + 50, e.Bounds.Top + 24); }