Beispiel #1
0
 /// <summary>
 /// Fills the interior of a rectangle specified by a RectangleF structure.
 /// </summary>
 /// <param name="g">The Graphics to draw on.</param>
 /// <param name="brush">StiBrush object that determines the characteristics of the fill.</param>
 /// <param name="rect">RectangleD structure that represents the rectangle to fill.</param>
 public static void FillRectangle(Graphics g, StiBrush brush, RectangleF rect)
 {
     using (Brush br = StiBrush.GetBrush(brush, rect))
     {
         FillRectangle(g, br, rect);
     }
 }
Beispiel #2
0
        /// <summary>
        /// Draws shadow on the indicated Graphics.
        /// </summary>
        /// <param name="g">Graphics on which a border can be drawn.</param>
        /// <param name="rect">The rectangle that indicates an area of the border drawing.</param>
        /// <param name="zoom">The scale of a border to draw.</param>
        public virtual void DrawBorderShadow(Graphics g, RectangleF rect, float zoom)
        {
            if (IsDefault)
            {
                return;
            }
            if (bits == null)
            {
                return;
            }
            if (bits.DropShadow)
            {
                float      dist  = (float)(bits.ShadowSize * zoom);
                RectangleF rect2 = new RectangleF(rect.Left + dist,
                                                  rect.Top + dist, rect.Width, rect.Height);

                using (Brush brush = StiBrush.GetBrush(ShadowBrush, rect2))
                {
                    g.FillRectangle(brush,
                                    rect.Right, rect.Top + dist, dist, rect.Height - dist);
                    g.FillRectangle(brush,
                                    rect.Left + dist, rect.Bottom, rect.Width, dist);
                }
            }
        }
Beispiel #3
0
 /// <summary>
 /// Transform a brush into a color.
 /// </summary>
 /// <param name="brush">Brush for converting.</param>
 /// <returns>Converted color.</returns>
 public static Color ToColor(StiBrush brush)
 {
     if (brush is StiEmptyBrush)
     {
         return(Color.Transparent);
     }
     if (brush is StiSolidBrush)
     {
         return(((StiSolidBrush)brush).Color);
     }
     if (brush is StiGradientBrush)
     {
         return(((StiGradientBrush)brush).StartColor);
     }
     if (brush is StiGlareBrush)
     {
         return(((StiGlareBrush)brush).StartColor);
     }
     if (brush is StiGlassBrush)
     {
         return(((StiGlassBrush)brush).Color);
     }
     if (brush is StiHatchBrush)
     {
         return(((StiHatchBrush)brush).ForeColor);
     }
     return(Color.Empty);
 }
Beispiel #4
0
 /// <summary>
 /// Creates a new instance of the StiBorder class.
 /// </summary>
 /// <param name="side">Border sides.</param>
 /// <param name="color">Border color.</param>
 /// <param name="size">Border size.</param>
 /// <param name="style">Border style.</param>
 /// <param name="dropShadow">Drop shadow or not.</param>
 /// <param name="shadowSize">Shadow size.</param>
 /// <param name="shadowBrush">Brush for drawing shadow of border.</param>
 /// <param name="topmost">Value which indicates that border sides will be drawn on top of all components.</param>
 public StiBorder(StiBorderSides side, Color color, double size, StiPenStyle style,
                  bool dropShadow, double shadowSize, StiBrush shadowBrush, bool topmost)
 {
     if (bitsBorder.IsDefault(side, color, size, style, dropShadow, shadowSize, topmost))
     {
         this.bits = null;
     }
     else
     {
         this.bits = new bitsBorder(side, color, size, style, shadowSize, dropShadow, topmost);
     }
     this.shadowBrush = shadowBrush;
 }
Beispiel #5
0
 /// <summary>
 /// Creates a new instance of the StiAdvancedBorder class.
 /// </summary>
 public StiAdvancedBorder(
     Color topSideColor, double topSideSize, StiPenStyle topSideStyle,
     Color bottomSideColor, double bottomSideSize, StiPenStyle bottomSideStyle,
     Color leftSideColor, double leftSideSize, StiPenStyle leftSideStyle,
     Color rightSideColor, double rightSideSize, StiPenStyle rightSideStyle,
     bool dropShadow, double shadowSize, StiBrush shadowBrush) :
     this(
         new StiBorderSide(topSideColor, topSideSize, topSideStyle),
         new StiBorderSide(bottomSideColor, bottomSideSize, bottomSideStyle),
         new StiBorderSide(leftSideColor, leftSideSize, leftSideStyle),
         new StiBorderSide(rightSideColor, rightSideSize, rightSideStyle),
         dropShadow, shadowSize, shadowBrush)
 {
 }
Beispiel #6
0
        /// <summary>
        /// Creates a new instance of the StiAdvancedBorder class.
        /// </summary>
        /// <param name="topSide">Top side of border.</param>
        /// <param name="bottomSide">Bottom side of border.</param>
        /// <param name="leftSide">Left side of border.</param>
        /// <param name="rightSide">Right side of border.</param>
        /// <param name="dropShadow">Drop shadow or not.</param>
        /// <param name="shadowSize">Shadow siz.</param>
        /// <param name="shadowBrush">Brush for drawing shadow of border.</param>
        /// <param name="topmost">Value which indicates that border sides will be drawn on top of all components.</param>
        public StiAdvancedBorder(StiBorderSide topSide, StiBorderSide bottomSide, StiBorderSide leftSide, StiBorderSide rightSide,
                                 bool dropShadow, double shadowSize, StiBrush shadowBrush, bool topmost)
        {
            this.topSide    = topSide;
            this.bottomSide = bottomSide;
            this.leftSide   = leftSide;
            this.rightSide  = rightSide;

            this.leftSide.side   = StiBorderSides.Left;
            this.rightSide.side  = StiBorderSides.Right;
            this.topSide.side    = StiBorderSides.Top;
            this.bottomSide.side = StiBorderSides.Bottom;

            this.ShadowBrush = shadowBrush;
            this.ShadowSize  = shadowSize;
            this.DropShadow  = dropShadow;
            this.Topmost     = topmost;
        }
Beispiel #7
0
        public static StiBrush Light(StiBrush baseBrush, byte value)
        {
            if (baseBrush is StiSolidBrush)
            {
                return(new StiSolidBrush(StiColorUtils.Light(((StiSolidBrush)baseBrush).Color, value)));
            }
            else if (baseBrush is StiGradientBrush)
            {
                StiGradientBrush gradientBrush = baseBrush as StiGradientBrush;
                return(new StiGradientBrush(
                           StiColorUtils.Light(gradientBrush.StartColor, value),
                           StiColorUtils.Light(gradientBrush.EndColor, value),
                           gradientBrush.Angle));
            }
            else if (baseBrush is StiHatchBrush)
            {
                StiHatchBrush hatchBrush = baseBrush as StiHatchBrush;
                return(new StiHatchBrush(
                           hatchBrush.Style,
                           StiColorUtils.Light(hatchBrush.ForeColor, value),
                           StiColorUtils.Light(hatchBrush.BackColor, value)));
            }
            else if (baseBrush is StiGlareBrush)
            {
                StiGlareBrush glareBrush = baseBrush as StiGlareBrush;
                return(new StiGlareBrush(
                           StiColorUtils.Light(glareBrush.StartColor, value),
                           StiColorUtils.Light(glareBrush.EndColor, value),
                           glareBrush.Angle));
            }
            else if (baseBrush is StiGlassBrush)
            {
                StiGlassBrush glassBrush = baseBrush as StiGlassBrush;
                return(new StiGlassBrush(
                           StiColorUtils.Light(glassBrush.Color, value),
                           glassBrush.DrawHatch,
                           glassBrush.Blend));
            }

            return(baseBrush);
        }
Beispiel #8
0
 /// <summary>
 /// Fills the interior of a rectangle specified by a pair of coordinates, a width, and a height.
 /// </summary>
 /// <param name="g">The Graphics to draw on.</param>
 /// <param name="brush">StiBrush object that determines the characteristics of the fill.</param>
 /// <param name="x">x-coordinate of the upper-left corner of the rectangle to fill.</param>
 /// <param name="y">y-coordinate of the upper-left corner of the rectangle to fill.</param>
 /// <param name="width">Width of the rectangle to fill.</param>
 /// <param name="height">Height of the rectangle to fill.</param>
 public static void FillRectangle(Graphics g, StiBrush brush, double x, double y, double width, double height)
 {
     FillRectangle(g, brush, new RectangleD(x, y, width, height));
 }
Beispiel #9
0
 /// <summary>
 /// Creates a new instance of the StiBorder class.
 /// </summary>
 /// <param name="side">Border sides.</param>
 /// <param name="color">Border color.</param>
 /// <param name="size">Border size.</param>
 /// <param name="style">Border style.</param>
 /// <param name="dropShadow">Drop shadow or not.</param>
 /// <param name="shadowSize">Shadow size.</param>
 /// <param name="shadowBrush">Brush for drawing shadow of border.</param>
 public StiBorder(StiBorderSides side, Color color, double size, StiPenStyle style,
                  bool dropShadow, double shadowSize, StiBrush shadowBrush) :
     this(side, color, size, style, dropShadow, shadowSize, shadowBrush, false)
 {
 }
Beispiel #10
0
        /// <summary>
        /// Returns the standard brush from the report brush.
        /// </summary>
        /// <param name="brush">Report brush.</param>
        /// <param name="rect">Rectangle for gradient.</param>
        /// <returns>Gdi brush.</returns>
        public static Brush GetBrush(StiBrush brush, RectangleD rect)
        {
            if (brush is StiEmptyBrush)
            {
                return(new SolidBrush(Color.Transparent));
            }
            else if (brush is StiSolidBrush)
            {
                return(new SolidBrush(((StiSolidBrush)brush).Color));
            }
            else if (brush is StiGradientBrush)
            {
                RectangleF rectF = rect.ToRectangleF();
                if (rectF.Width < 1)
                {
                    rectF.Width = 1;
                }
                if (rectF.Height < 1)
                {
                    rectF.Height = 1;
                }

                StiGradientBrush gradientBrush = brush as StiGradientBrush;
                return(new LinearGradientBrush(rectF,
                                               gradientBrush.StartColor, gradientBrush.EndColor, (float)gradientBrush.Angle));
            }
            else if (brush is StiHatchBrush)
            {
                StiHatchBrush hatchBrush = brush as StiHatchBrush;
                return(new HatchBrush(hatchBrush.Style,
                                      hatchBrush.ForeColor, hatchBrush.BackColor));
            }
            else if (brush is StiGlareBrush)
            {
                RectangleF rectF = rect.ToRectangleF();
                if (rectF.Width < 1)
                {
                    rectF.Width = 1;
                }
                if (rectF.Height < 1)
                {
                    rectF.Height = 1;
                }

                StiGlareBrush       glareBrush = brush as StiGlareBrush;
                LinearGradientBrush br         = new LinearGradientBrush(rectF,
                                                                         glareBrush.StartColor, glareBrush.EndColor, (float)glareBrush.Angle);
                br.SetSigmaBellShape(glareBrush.Focus, glareBrush.Scale);
                return(br);
            }
            else if (brush is StiGlassBrush)
            {
                Bitmap bmp = new Bitmap((int)rect.Width + 1, (int)rect.Height + 1);
                using (Graphics gg = Graphics.FromImage(bmp))
                {
                    ((StiGlassBrush)brush).Draw(gg, new RectangleF(0, 0, (float)rect.Width + 1, (float)rect.Height + 1));
                }

                TextureBrush textureBrush = new TextureBrush(bmp);
                textureBrush.TranslateTransform((float)rect.X, (float)rect.Y);
                return(textureBrush);
            }
            return(null);
        }
Beispiel #11
0
 /// <summary>
 /// Returns the gdi brush from the report brush.
 /// </summary>
 /// <param name="brush">Report brush.</param>
 /// <param name="rect">Rectangle for gradient.</param>
 /// <returns>Gdi brush.</returns>
 public static Brush GetBrush(StiBrush brush, RectangleF rect)
 {
     return(GetBrush(brush, RectangleD.CreateFromRectangle(rect)));
 }
Beispiel #12
0
 /// <summary>
 /// Creates a new instance of the StiAdvancedBorder class.
 /// </summary>
 /// <param name="topSide">Top side of border.</param>
 /// <param name="bottomSide">Bottom side of border.</param>
 /// <param name="leftSide">Left side of border.</param>
 /// <param name="rightSide">Right side of border.</param>
 /// <param name="dropShadow">Drop shadow or not.</param>
 /// <param name="shadowSize">Shadow siz.</param>
 /// <param name="shadowBrush">Brush for drawing shadow of border.</param>
 public StiAdvancedBorder(StiBorderSide topSide, StiBorderSide bottomSide, StiBorderSide leftSide, StiBorderSide rightSide,
                          bool dropShadow, double shadowSize, StiBrush shadowBrush) : this(topSide, bottomSide, leftSide, rightSide,
                                                                                           dropShadow, shadowSize, shadowBrush, false)
 {
 }