Exemplo n.º 1
0
        /// <summary>
        /// Does the glyph painting.
        /// </summary>
        /// <param name="pe"></param>
        /// <returns></returns>
        protected sealed override bool OnItemPaint(PaintEventArgs pe)
        {
            if (pe.ClipRectangle.Width <= 0 || pe.ClipRectangle.Height <= 0)
            {
                return(false);
            }

            GraphicsState state = pe.Graphics.Save();

            try
            {
                // clear own bound rectangle
                pe.Graphics.SetClip(pe.ClipRectangle, CombineMode.Intersect);
                // add gaps to avoid artifacts on left and bottom borders due to clipping
                const int SideGap = 1;
                Rectangle bounds  = pe.ClipRectangle;
                bounds.Width  -= SideGap;
                bounds.Height -= SideGap;
                bounds         = ConversionService.ReverseScale(bounds);
                if (bounds.Width <= 0 || bounds.Height <= 0)
                {
                    return(false);
                }
                //Case 36389: In some cases, the appointment text was not displaying underlined when it should have been.  Work around is to
                // use the graphics of a bitmap and then draw the bitmap to the original designers graphics.
                using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
                {
                    using (Graphics graphics = Graphics.FromImage(bitmap))
                    {
                        //Offset the graphics to compensate for the clip bounds if they are not (0,0).
                        graphics.TranslateTransform(
                            -RenderUtils.ConvertPixelsToTwips(bounds.Left, pe.Graphics.DpiX),
                            -RenderUtils.ConvertPixelsToTwips(bounds.Top, pe.Graphics.DpiY));
                        DrawGlyph(graphics, bounds);
                    }

                    float scaleFactor = ConversionService.ScalingFactor;
                    pe.Graphics.ScaleTransform(scaleFactor, scaleFactor);

                    pe.Graphics.DrawImageUnscaled(bitmap, bounds);
                }
            }
            finally
            {
                pe.Graphics.Restore(state);
            }
            return(true);
        }