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); }
public static StiBrush LoadFromJson(JObject jObject) { var ident = jObject.Properties().FirstOrDefault(x => x.Name == "Ident"); switch (ident.Value.ToObject <string>()) { case "StiEmptyBrush": return(new StiEmptyBrush()); case "StiSolidBrush": var solid = new StiSolidBrush(); solid.LoadValuesFromJson(jObject); return(solid); case "StiGradientBrush": var gradient = new StiGradientBrush(); gradient.LoadValuesFromJson(jObject); return(gradient); case "StiGlareBrush": var glare = new StiGlareBrush(); glare.LoadValuesFromJson(jObject); return(glare); case "StiGlassBrush": var glass = new StiGlassBrush(); glass.LoadValuesFromJson(jObject); return(glass); case "StiHatchBrush": var hatch = new StiHatchBrush(); hatch.LoadValuesFromJson(jObject); return(hatch); } throw new Exception("Type is not supported!"); }
/// <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); }
protected bool Equals(StiGradientBrush other) { return(startColor.Equals(other.startColor) && endColor.Equals(other.endColor) && angle.Equals(other.angle)); }