Esempio n. 1
0
        private void PaintStretchXYTileInner(Graphics g, Rectangle paintRect)
        {
            ImageSegments visibleSegments = this.visibleSegments;

            this.visibleSegments &= ~ImageSegments.Inner;
            this.PaintSegmented(g, paintRect);
            this.visibleSegments = visibleSegments;
            if ((this.visibleSegments & ImageSegments.Inner) == (ImageSegments)0)
            {
                return;
            }
            RadImageSegment segment = this.GetSegment(ImageSegments.Inner);

            if (segment.ImagePart == null)
            {
                return;
            }
            Padding   paintMargins    = this.GetPaintMargins(paintRect);
            Rectangle destinationRect = segment.GetDestinationRect(paintRect, paintMargins);

            if (destinationRect.Width <= 0 || destinationRect.Height <= 0)
            {
                return;
            }
            if (segment.RenderMargins != paintMargins)
            {
                segment.UpdateSourceRect(this.cachedImage.Size, paintMargins);
            }
            TextureBrush textureBrush = new TextureBrush(segment.ImagePart, WrapMode.Tile);

            textureBrush.TranslateTransform((float)destinationRect.X, (float)destinationRect.Y, MatrixOrder.Prepend);
            g.FillRectangle((Brush)textureBrush, destinationRect);
            textureBrush.Dispose();
        }
Esempio n. 2
0
 private void PaintSegmented(Graphics g, Rectangle paintRect)
 {
     if (!this.useSegments)
     {
         g.DrawImage(this.cachedImage, paintRect);
     }
     else
     {
         Padding paintMargins = this.GetPaintMargins(paintRect);
         int     length       = this.segments.Length;
         for (int index = 0; index < length; ++index)
         {
             RadImageSegment segment = this.segments[index];
             if ((segment.Segment & this.visibleSegments) != (ImageSegments)0)
             {
                 Rectangle destinationRect = segment.GetDestinationRect(paintRect, paintMargins);
                 if (destinationRect.Width > 0 && destinationRect.Height > 0)
                 {
                     if (segment.RenderMargins != paintMargins)
                     {
                         segment.UpdateSourceRect(this.cachedImage.Size, paintMargins);
                     }
                     g.DrawImage(this.cachedImage, destinationRect, segment.SourceRect, GraphicsUnit.Pixel);
                 }
             }
         }
     }
 }
Esempio n. 3
0
        private void PaintStretchXYTileInner(Graphics g, Rectangle paintRect)
        {
            //exclude inner segment from painting to stretch only the borders
            ImageSegments visible = this.visibleSegments;

            this.visibleSegments &= ~ImageSegments.Inner;

            this.PaintSegmented(g, paintRect);

            //restore original segments
            this.visibleSegments = visible;

            if ((this.visibleSegments & ImageSegments.Inner) == 0)
            {
                return;
            }

            RadImageSegment segment = this.GetSegment(ImageSegments.Inner);

            if (segment.ImagePart == null)
            {
                return;
            }

            Padding paintMargins = this.GetPaintMargins(paintRect);

            Rectangle destinationRect = segment.GetDestinationRect(paintRect, paintMargins);

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

            if (segment.RenderMargins != paintMargins)
            {
                segment.UpdateSourceRect(this.cachedImage.Size, paintMargins);
            }

            //tile inner segment
            TextureBrush brush = new TextureBrush(segment.ImagePart, WrapMode.Tile);

            brush.TranslateTransform(destinationRect.X, destinationRect.Y, MatrixOrder.Prepend);
            g.FillRectangle(brush, destinationRect);
            brush.Dispose();
        }