Example #1
0
        protected override void PaintChildren(IGraphics graphics, Rectangle clipRectange, float angle, SizeF scale, bool useRelativeTransformation)
        {
            if (this.Opacity < 1)
            {
                this.saveGraphicsOpacity = graphics.Opacity;
                graphics.ChangeOpacity(this.Opacity * graphics.Opacity);
            }

            base.PaintChildren(graphics, clipRectange, angle, scale, useRelativeTransformation);

            if (saveGraphicsOpacity != null && saveGraphicsOpacity.HasValue)
            {
                graphics.ChangeOpacity(this.saveGraphicsOpacity.Value);
            }
        }
Example #2
0
        protected override void PrePaintElement(IGraphics graphics)
        {
            base.PrePaintElement(graphics);

            Graphics rawGraphics = (Graphics)graphics.UnderlayGraphics;

            graphicsCurrentSmoothingMode = rawGraphics.SmoothingMode;
            graphics.ChangeSmoothingMode(this.SmoothingMode);

            graphicsCurrentTextRenderingHint = rawGraphics.TextRenderingHint;
            if (this.Enabled)
            {
                rawGraphics.TextRenderingHint = this.TextRenderingHint;
            }
            else
            {
                rawGraphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
            }

            if (this.Opacity < 1)
            {
                this.saveGraphicsOpacity = graphics.Opacity;
                graphics.ChangeOpacity(this.Opacity * graphics.Opacity);
            }
        }
Example #3
0
 protected override void PaintChildren(
     IGraphics graphics,
     Rectangle clipRectange,
     float angle,
     SizeF scale,
     bool useRelativeTransformation)
 {
     if (this.Opacity < 1.0)
     {
         this.saveGraphicsOpacity = new double?(graphics.Opacity);
         graphics.ChangeOpacity(this.Opacity * graphics.Opacity);
     }
     base.PaintChildren(graphics, clipRectange, angle, scale, useRelativeTransformation);
     if (!this.saveGraphicsOpacity.HasValue || !this.saveGraphicsOpacity.HasValue)
     {
         return;
     }
     graphics.ChangeOpacity(this.saveGraphicsOpacity.Value);
 }
Example #4
0
        protected override void PostPaintElement(IGraphics graphics)
        {
            base.PostPaintElement(graphics);
            Graphics underlayGraphics = (Graphics)graphics.UnderlayGraphics;

            graphics.ChangeSmoothingMode(this.graphicsCurrentSmoothingMode);
            if (!this.saveGraphicsOpacity.HasValue || !this.saveGraphicsOpacity.HasValue)
            {
                return;
            }
            graphics.ChangeOpacity(this.saveGraphicsOpacity.Value);
        }
Example #5
0
 protected override void PrePaintElement(IGraphics graphics)
 {
     base.PrePaintElement(graphics);
     this.graphicsCurrentSmoothingMode = ((Graphics)graphics.UnderlayGraphics).SmoothingMode;
     graphics.ChangeSmoothingMode(this.SmoothingMode);
     if (this.Opacity >= 1.0)
     {
         return;
     }
     this.saveGraphicsOpacity = new double?(graphics.Opacity);
     graphics.ChangeOpacity(this.Opacity * graphics.Opacity);
 }
Example #6
0
        protected override void PostPaintElement(IGraphics graphics)
        {
            base.PostPaintElement(graphics);

            Graphics rawGraphics = (Graphics)graphics.UnderlayGraphics;

            graphics.ChangeSmoothingMode(this.graphicsCurrentSmoothingMode);
            rawGraphics.TextRenderingHint = this.graphicsCurrentTextRenderingHint;

            if (saveGraphicsOpacity != null && saveGraphicsOpacity.HasValue)
            {
                graphics.ChangeOpacity(this.saveGraphicsOpacity.Value);
            }
        }
Example #7
0
        public void PaintFill(IGraphics graphics, float angle, SizeF scale, RectangleF paintRect)
        {
            if (this.IsTransparent())
            {
                return;
            }
            Size desired = Size.Round(paintRect.Size);

            if (desired.Width <= 0 || desired.Height <= 0)
            {
                return;
            }
            graphics.ChangeSmoothingMode(this.fillElement.SmoothingMode);
            this.lastScale = scale;
            ElementShape elementShape = (ElementShape)null;

            if (this.primitiveElement != null)
            {
                elementShape = this.primitiveElement.GetCurrentShape();
            }
            else if (this.shapedElement != null)
            {
                elementShape = this.shapedElement.GetCurrentShape();
            }
            FillElementPaintBuffer elementPaintBuffer = this.FillElementPaintBuffer;

            if (elementShape != null && elementPaintBuffer != null)
            {
                string str       = elementShape.SerializeProperties();
                int    shapeHash = string.IsNullOrEmpty(str) ? elementShape.GetHashCode() : str.GetHashCode();
                elementPaintBuffer.SetShapeHash(shapeHash);
            }
            bool flag = elementPaintBuffer != null && !elementPaintBuffer.IsDisabled && elementPaintBuffer.ShouldUsePaintBuffer() && this.primitiveElement.ShouldUsePaintBuffer();

            try
            {
                if (flag)
                {
                    if (!this.primitiveElement.IsDesignMode && elementPaintBuffer.PaintFromBuffer(graphics, scale, desired))
                    {
                        graphics.RestoreSmoothingMode();
                        return;
                    }
                    graphics.ChangeOpacity(1.0);
                    if (!this.primitiveElement.IsDesignMode)
                    {
                        elementPaintBuffer.SetGraphics(graphics, scale);
                    }
                }
            }
            catch
            {
                flag = false;
            }
            GraphicsPath path = (GraphicsPath)null;

            if (elementShape != null)
            {
                path = elementShape.CreatePath(paintRect);
                graphics.PushCurrentClippingPath(path);
            }
            this.FillRectangle(graphics, paintRect);
            if (path != null)
            {
                graphics.PopCurrentClippingPath();
                path.Dispose();
            }
            if (flag)
            {
                graphics.RestoreOpacity();
                if (!this.primitiveElement.IsDesignMode)
                {
                    elementPaintBuffer.ResetGraphics(graphics, scale);
                }
            }
            graphics.RestoreSmoothingMode();
        }
Example #8
0
        public void PaintFill(IGraphics graphics, float angle, SizeF scale, RectangleF paintRect)
        {
            if (this.IsTransparent())
            {
                return;
            }

            Size size = Size.Round(paintRect.Size);

            if ((size.Width <= 0) || (size.Height <= 0))
            {
                return;
            }

            this.lastScale = scale;

            ElementShape currentShape = this.primitiveElement.GetCurrentShape();

            //Check if we have already painded in PaintBuffer with this shape
            FillElementPaintBuffer paintBuffer = this.FillElementPaintBuffer;

            if (currentShape != null && paintBuffer != null)
            {
                string shapeProps = currentShape.SerializeProperties();
                int    shapeHash;
                if (!string.IsNullOrEmpty(shapeProps))
                {
                    shapeHash = shapeProps.GetHashCode();
                }
                else
                {
                    shapeHash = currentShape.GetHashCode();
                }

                paintBuffer.SetShapeHash(shapeHash);
            }

            //Graphics graphics = null;
            bool usePaintBuffer = paintBuffer != null && paintBuffer.ShouldUsePaintBuffer() && this.primitiveElement.ShouldUsePaintBuffer();

            try
            {
                if (usePaintBuffer)
                {
                    if (!this.primitiveElement.IsDesignMode && paintBuffer.PaintFromBuffer(graphics, scale, size))
                    {
                        return;
                    }
                    graphics.ChangeOpacity(1d);
                    if (!this.primitiveElement.IsDesignMode)
                    {
                        paintBuffer.SetGraphics(graphics, scale);
                    }
                }
            }
            catch
            {
                usePaintBuffer = false;
            }

            GraphicsPath clippingPath = null;

            if (currentShape != null)
            {
                clippingPath = currentShape.CreatePath(paintRect);
                graphics.PushCurrentClippingPath(clippingPath);
            }

            this.FillRectangle(graphics, paintRect);

            if (clippingPath != null)
            {
                graphics.PopCurrentClippingPath();
                clippingPath.Dispose();
            }

            if (usePaintBuffer)
            {
                graphics.RestoreOpacity();
                if (!this.primitiveElement.IsDesignMode)
                {
                    paintBuffer.ResetGraphics(graphics, scale);
                }
            }
        }