private Brush GetBrush(GraphicsPath gp, string propPrefix) { SvgPaint fill; if (PaintType == SvgPaintType.None) { return(null); } else if (PaintType == SvgPaintType.CurrentColor) { fill = new GdiSvgPaint(_element, "color"); } else { fill = this; } if (fill.PaintType == SvgPaintType.Uri || fill.PaintType == SvgPaintType.UriCurrentColor || fill.PaintType == SvgPaintType.UriNone || fill.PaintType == SvgPaintType.UriRgbColor || fill.PaintType == SvgPaintType.UriRgbColorIccColor) { ps = getPaintServer(fill.Uri); if (ps != null) { Brush br = ps.GetBrush(gp.GetBounds()); if (br is LinearGradientBrush) { LinearGradientBrush lgb = (LinearGradientBrush)br; int opacityl = getOpacity(propPrefix); for (int i = 0; i < lgb.InterpolationColors.Colors.Length; i++) { lgb.InterpolationColors.Colors[i] = Color.FromArgb(opacityl, lgb.InterpolationColors.Colors[i]); } for (int i = 0; i < lgb.LinearColors.Length; i++) { lgb.LinearColors[i] = Color.FromArgb(opacityl, lgb.LinearColors[i]); } } else if (br is PathGradientBrush) { PathGradientBrush pgb = (PathGradientBrush)br; int opacityl = getOpacity(propPrefix); for (int i = 0; i < pgb.InterpolationColors.Colors.Length; i++) { pgb.InterpolationColors.Colors[i] = Color.FromArgb(opacityl, pgb.InterpolationColors.Colors[i]); } for (int i = 0; i < pgb.SurroundColors.Length; i++) { pgb.SurroundColors[i] = Color.FromArgb(opacityl, pgb.SurroundColors[i]); } } return(br); } else { if (PaintType == SvgPaintType.UriNone || PaintType == SvgPaintType.Uri) { return(null); } else if (PaintType == SvgPaintType.UriCurrentColor) { fill = new GdiSvgPaint(_element, "color"); } else { fill = this; } } } SolidBrush brush = new SolidBrush(((RgbColor)fill.RgbColor).GdiColor); int opacity = getOpacity(propPrefix); brush.Color = Color.FromArgb(opacity, brush.Color); return(brush); }
private Brush GetBrush(GraphicsPath gp, string propPrefix) { SvgPaint fill; if(PaintType == SvgPaintType.None) { return null; } else if(PaintType == SvgPaintType.CurrentColor) { fill = new GdiSvgPaint(_element, "color"); } else { fill = this; } if(fill.PaintType == SvgPaintType.Uri || fill.PaintType == SvgPaintType.UriCurrentColor || fill.PaintType == SvgPaintType.UriNone || fill.PaintType == SvgPaintType.UriRgbColor || fill.PaintType == SvgPaintType.UriRgbColorIccColor) { ps = getPaintServer(fill.Uri); if(ps != null) { Brush br = ps.GetBrush(gp.GetBounds()); if (br is LinearGradientBrush) { LinearGradientBrush lgb = (LinearGradientBrush)br; int opacityl = getOpacity(propPrefix); for (int i = 0; i < lgb.InterpolationColors.Colors.Length; i++) { lgb.InterpolationColors.Colors[i] = Color.FromArgb(opacityl, lgb.InterpolationColors.Colors[i]); } for (int i = 0; i < lgb.LinearColors.Length; i++) { lgb.LinearColors[i] = Color.FromArgb(opacityl, lgb.LinearColors[i]); } } else if (br is PathGradientBrush) { PathGradientBrush pgb = (PathGradientBrush)br; int opacityl = getOpacity(propPrefix); for (int i = 0; i < pgb.InterpolationColors.Colors.Length; i++) { pgb.InterpolationColors.Colors[i] = Color.FromArgb(opacityl, pgb.InterpolationColors.Colors[i]); } for (int i = 0; i < pgb.SurroundColors.Length; i++) { pgb.SurroundColors[i] = Color.FromArgb(opacityl, pgb.SurroundColors[i]); } } return br; } else { if(PaintType == SvgPaintType.UriNone || PaintType == SvgPaintType.Uri) { return null; } else if(PaintType == SvgPaintType.UriCurrentColor) { fill = new GdiSvgPaint(_element, "color"); } else { fill = this; } } } SolidBrush brush = new SolidBrush( ((RgbColor)fill.RgbColor).GdiColor ); int opacity = getOpacity(propPrefix); brush.Color = Color.FromArgb(opacity, brush.Color); return brush; }
private PaintServer getPaintServer(string uri) { string absoluteUri = _element.ResolveUri(uri); return(PaintServer.CreatePaintServer(_element.OwnerDocument, absoluteUri)); }