Example #1
0
        private void SampleGallery_DrawItem(object sender, GalleryDrawItemEventArgs e)
        {
            GalleryItem galleryItem = (GalleryItem)e.Item;
            Image       image       = ApplySaturationToImage(galleryItem.Image, _CurrentSaturation);

            e.PaintScaledAndCenteredImage(image, e.ContentBounds, ImageEffect.None, e.Graphics);

            if (_CurrentSaturation == CustomSaturationValue)
            {
                int informationRectangleHeight = TextRenderer.MeasureText(galleryItem.TooltipText, Font).Height + 4;

                Rectangle backgroundRectangle = e.ContentBounds;
                backgroundRectangle.Y      = backgroundRectangle.Bottom - informationRectangleHeight;
                backgroundRectangle.Height = informationRectangleHeight;

                using (Brush b = new SolidBrush(Color.FromArgb(128, Color.White)))
                {
                    e.Graphics.FillRectangle(b, backgroundRectangle);
                }

                Rectangle textRectangle = e.RelativeContentBounds;
                textRectangle.Y      = textRectangle.Bottom - informationRectangleHeight;
                textRectangle.Height = informationRectangleHeight;

                TextRenderer.DrawText(
                    e.Graphics,
                    galleryItem.TooltipText,
                    Font,
                    textRectangle,
                    SystemColors.ControlText,
                    TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis);
            }
        }
Example #2
0
        private void SampleGallery_DrawItem(object sender, GalleryDrawItemEventArgs e)
        {
            GalleryItem galleryItem = (GalleryItem) e.Item;
            Image image = ApplySaturationToImage(galleryItem.Image, _CurrentSaturation);
            e.PaintScaledAndCenteredImage(image, e.ContentBounds, ImageEffect.None, e.Graphics);

            if(_CurrentSaturation == CustomSaturationValue)
            {
                int informationRectangleHeight = TextRenderer.MeasureText(galleryItem.TooltipText, Font).Height + 4;

                Rectangle backgroundRectangle = e.ContentBounds;
                backgroundRectangle.Y = backgroundRectangle.Bottom - informationRectangleHeight;
                backgroundRectangle.Height = informationRectangleHeight;

                using(Brush b = new SolidBrush(Color.FromArgb(128, Color.White)))
                {
                    e.Graphics.FillRectangle(b, backgroundRectangle);
                }

                Rectangle textRectangle = e.RelativeContentBounds;
                textRectangle.Y = textRectangle.Bottom - informationRectangleHeight;
                textRectangle.Height = informationRectangleHeight;

                TextRenderer.DrawText(
                        e.Graphics,
                        galleryItem.TooltipText,
                        Font,
                        textRectangle,
                        SystemColors.ControlText,
                        TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis);
            }
        }