Exemple #1
0
        /// <summary>
        /// Overriden. Raises the Paint event
        /// </summary>
        /// <param name="e">Additional paint info</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            renderer.DrawBackground(e.Graphics, ClientRectangle, state, inputState);

            if (small)
            {
                if ((smallImage != null) && (showImage))
                {
                    Point location = new Point((int)((Width / 2) - (smallImage.Width / 2)),
                                               (int)((Height / 2) - (smallImage.Height / 2)));
                    renderer.DrawImage(e.Graphics, location, smallImage);
                }
            }
            else
            {
                Rectangle bounds = ClientRectangle;
                if ((largeImage != null) && showImage)
                {
                    Point location;

                    int margin = 10;
                    if (collapsed)
                    {
                        margin = 4;
                    }

                    if (RightToLeft == RightToLeft.Yes)
                    {
                        location = new Point(Width - margin - largeImage.Width, (int)((Height / 2) - (largeImage.Height / 2)));
                    }
                    else
                    {
                        location = new Point(margin, (int)((Height / 2) - (largeImage.Height / 2)));
                    }

                    renderer.DrawImage(e.Graphics, location, largeImage);

                    // Calculate bounds for text
                    if (RightToLeft == RightToLeft.No)
                    {
                        bounds.X += 32;
                    }
                    bounds.Width -= 32;
                }
                bounds.X     += 10;
                bounds.Width -= 10;
                if (!collapsed)
                {
                    renderer.DrawText(e.Graphics, bounds, Font, Text, RightToLeft == RightToLeft.Yes);
                }
            }
        }