public RatHatchBrush(Color backcolor, ItopVector.PatternType patterntype, Color forecolor, float fillopacity) { pattern = new ItopVector.Struct.Pattern(backcolor, patterntype, forecolor); this.opacity = fillopacity; this.pen = null; this.color = forecolor; this.opacity = ((float)this.color.A) / 255f; }
public static ISvgBrush Parsing(string text, SvgDocument doc, IGraphPath path) { while (text.Trim().EndsWith(";")) { text = text.Substring(0, text.Length - 1); } if (text.Trim().StartsWith("url")) { int num1 = text.Trim().IndexOf("#", 0, text.Trim().Length); int num2 = text.Trim().IndexOf(")", 0, text.Trim().Length); string text1 = text.Trim().Substring(num1 + 1, (num2 - num1) - 1); XmlNode node1 = NodeFunc.GetRefNode(text1, doc); if (node1 != null) { if (node1.NodeType != XmlNodeType.Element) { return(null); } XmlElement element1 = (XmlElement)node1; if (element1 != null) { return((ISvgBrush)element1); } } return(null); } string text7 = "none"; // AttributeFunc.ParseAttribute("hatch-style",(SvgElement) path,false).ToString(); if (((SvgElement)path).SvgAttributes.ContainsKey("hatch-style")) { text7 = ((SvgElement)path).SvgAttributes["hatch-style"].ToString(); } if ((text7 != "") && (text7.ToLower() != "none") && (text != "none")) { Color color1 = ColorFunc.ParseColor(text); Color color2 = ColorFunc.ParseColor(AttributeFunc.ParseAttribute("hatch-color", (SvgElement)path, false).ToString()); Struct.Pattern pattern = new ItopVector.Struct.Pattern(color1, (ItopVector.PatternType)Enum.Parse(typeof(ItopVector.PatternType), text7, false), color2); return(new RatHatchBrush(pattern)); } return(new SolidColor(ColorFunc.ParseColor(text))); }
public static Brush GetGDIBrushFromPatten(ItopVector.Struct.Pattern pattern, RectangleF rect) { if (pattern.PatternType != PatternType.None) { if (pattern.PatternType < PatternType.Center) { HatchStyle style1 = (HatchStyle)System.Enum.Parse(typeof(HatchStyle), pattern.PatternType.ToString(), false); return(new HatchBrush(style1, pattern.ForeColor, pattern.BackColor)); } Brush brush1 = null; ColorBlend blend1 = new ColorBlend(); using (GraphicsPath path1 = new GraphicsPath()) { float[] singleArray1; Color[] colorArray1; switch (pattern.PatternType) { case PatternType.Center: { path1.AddEllipse(rect.X, rect.Y, rect.Width, rect.Height); brush1 = new PathGradientBrush(path1); singleArray1 = new float[2]; singleArray1[1] = 1f; blend1.Positions = singleArray1; colorArray1 = new Color[] { pattern.BackColor, pattern.ForeColor }; blend1.Colors = colorArray1; ((PathGradientBrush)brush1).InterpolationColors = blend1; ((PathGradientBrush)brush1).CenterPoint = new PointF(rect.X + (((float)rect.Width) / 2f), rect.Y + (((float)rect.Height) / 2f)); goto Label_0496; } case PatternType.DiagonalLeft: { brush1 = new LinearGradientBrush(rect, pattern.BackColor, pattern.ForeColor, LinearGradientMode.ForwardDiagonal); singleArray1 = new float[3]; singleArray1[1] = 0.5f; singleArray1[2] = 1f; blend1.Positions = singleArray1; colorArray1 = new Color[] { pattern.BackColor, pattern.ForeColor, pattern.BackColor }; blend1.Colors = colorArray1; ((LinearGradientBrush)brush1).InterpolationColors = blend1; goto Label_0496; } case PatternType.DiagonalRight: { brush1 = new LinearGradientBrush(rect, pattern.BackColor, pattern.ForeColor, LinearGradientMode.BackwardDiagonal); singleArray1 = new float[3]; singleArray1[1] = 0.5f; singleArray1[2] = 1f; blend1.Positions = singleArray1; colorArray1 = new Color[] { pattern.BackColor, pattern.ForeColor, pattern.BackColor }; blend1.Colors = colorArray1; ((LinearGradientBrush)brush1).InterpolationColors = blend1; goto Label_0496; } case PatternType.HorizontalCenter: { brush1 = new LinearGradientBrush(rect, pattern.BackColor, pattern.ForeColor, LinearGradientMode.Horizontal); singleArray1 = new float[3]; singleArray1[1] = 0.5f; singleArray1[2] = 1f; blend1.Positions = singleArray1; colorArray1 = new Color[] { pattern.BackColor, pattern.ForeColor, pattern.BackColor }; blend1.Colors = colorArray1; ((LinearGradientBrush)brush1).InterpolationColors = blend1; goto Label_0496; } case PatternType.LeftRight: { brush1 = new LinearGradientBrush(rect, pattern.BackColor, pattern.ForeColor, LinearGradientMode.Horizontal); singleArray1 = new float[2]; singleArray1[1] = 1f; blend1.Positions = singleArray1; colorArray1 = new Color[] { pattern.BackColor, pattern.ForeColor }; blend1.Colors = colorArray1; ((LinearGradientBrush)brush1).InterpolationColors = blend1; goto Label_0496; } case PatternType.TopBottom: { break; } case PatternType.VerticalCenter: { brush1 = new LinearGradientBrush(rect, pattern.BackColor, pattern.ForeColor, LinearGradientMode.Vertical); singleArray1 = new float[3]; singleArray1[1] = 0.5f; singleArray1[2] = 1f; blend1.Positions = singleArray1; colorArray1 = new Color[] { pattern.BackColor, pattern.ForeColor, pattern.BackColor }; blend1.Colors = colorArray1; ((LinearGradientBrush)brush1).InterpolationColors = blend1; goto Label_0496; } default: { goto Label_0496; } } brush1 = new LinearGradientBrush(rect, pattern.BackColor, pattern.ForeColor, LinearGradientMode.Vertical); singleArray1 = new float[2]; singleArray1[1] = 1f; blend1.Positions = singleArray1; colorArray1 = new Color[] { pattern.BackColor, pattern.ForeColor }; blend1.Colors = colorArray1; ((LinearGradientBrush)brush1).InterpolationColors = blend1; Label_0496: blend1 = null; return(brush1); } } return(null); }