private void atvAlbumTree_BeforeSelect(object sender, TreeViewCancelEventArgs e)
 {
     if (_currentPhoto != null)
     {
         spbxPhoto.Image = null;
         _currentPhoto.ReleaseImage();
         _currentPhoto = null;
     }
 }
Ejemplo n.º 2
0
        private void lstPhotos_DrawItem(object sender, DrawItemEventArgs e)
        {
            Graphics g = e.Graphics;

            if (e.Index < 0 || e.Index > Manager.Album.Count - 1)
            {
                return;
            }

            Photograph p = Manager.Album[e.Index];

            // Determine image rectangle
            Rectangle imageRect = ImageUtility.ScaleToFit(p.Image, DrawRect);

            imageRect.X = e.Bounds.X + 2;
            imageRect.Y = e.Bounds.Y + 1;

            // Draw text image
            g.DrawImage(p.Image, imageRect);
            g.DrawRectangle(Pens.Black, imageRect);
            p.ReleaseImage();

            // Determine text rectangle
            Rectangle textRect = new Rectangle();

            textRect.X      = imageRect.Right + 2;
            textRect.Y      = imageRect.Y + ((imageRect.Height - e.Font.Height) / 2);
            textRect.Width  = e.Bounds.Width - imageRect.Width - 4;
            textRect.Height = e.Font.Height;

            // Determine text brush (handle selection)
            Brush textBrush;

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                g.FillRectangle(SystemBrushes.Highlight, textRect);
                textBrush = SystemBrushes.HighlightText;
            }
            else
            {
                g.FillRectangle(SystemBrushes.Window, textRect);
                textBrush = SystemBrushes.WindowText;
            }

            // Draw the text
            g.DrawString(lstPhotos.GetItemText(p), e.Font, textBrush, textRect);
        }