private void ChangeStrokeBrush(object sender, EventArgs e) { if (this.updateattribute) { ISvgBrush brush1 = this.graphStroke.Brush; if (brush1 is SvgElement) { // SvgElement element1 = (SvgElement) brush1; string text1 = CodeFunc.CreateString(base.OwnerDocument, ((SvgElement)brush1).Name); if ((this.ParentNode != null) && (((SvgElement)brush1).ParentNode == null)) { AttributeFunc.SetAttributeValue((SvgElement)brush1, "id", text1); AttributeFunc.SetAttributeValue(this, "stroke", "url(#" + text1 + ");"); base.OwnerDocument.AddDefsElement((SvgElement)brush1); } else { this.svgAttributes["stroke"] = this.graphStroke; this.svgAnimAttributes["stroke"] = this.graphStroke; } } else if (brush1 == null) { AttributeFunc.SetAttributeValue(this, "stroke", "none"); } else { AttributeFunc.SetAttributeValue(this, "stroke", ColorFunc.GetColorString(((SolidColor)brush1).Color)); AttributeFunc.SetAttributeValue(this, "stroke-opacity", ((SolidColor)brush1).Opacity.ToString()); } } }
public Pattern(TokenList aTokens, CodeFunc aCode, string patternString) { Tokens = aTokens; Hash = aTokens.GetHashCode(); Code = aCode; PatternString = patternString; }
/// <summary>Register a collection of patterns that share a single transformation handler. /// </summary> /// <param name="aPatterns">A collection of X# lines of code. Each line of code define a /// pattern optionally using the pattern reserved syntax.</param> /// <param name="aCode">The code transformation handler that is common abmongst all the /// patterns from the collection.</param> protected void AddPattern(string[] aPatterns, CodeFunc aCode) { foreach (var xPattern in aPatterns) { AddPattern(xPattern, aCode); } }
/// <summary>Register a single pattern with its associated transformation handler.</summary> /// <param name="aPattern">A single line of X# code that define the pattern optionally using /// pattern reserved syntax.</param> /// <param name="aCode">The associated code transformation handler.</param> protected void AddPattern(string aPattern, CodeFunc aCode) { Parser xParser = null; try { xParser = new Parser(aPattern, 1, false, true); } catch (Exception e) { throw new Exception(string.Format("Invalid pattern '{0}'", aPattern ?? "NULL"), e); } var xPattern = new Pattern(xParser.Tokens, aCode, aPattern); mPatterns.Add(xPattern); }
public void OnMouseUp(MouseEventArgs e) { this.tempPath.Reset(); if (((this.graph != null) && (((SvgElement)this.graph).ParentNode != null)) && ((e.Button == MouseButtons.Left) && this.mousedown)) { this.mousedown = false; if ((this.operate == PolyOperate.MovePoint) || (this.operate == PolyOperate.MovePath)) { PointF tf1 = this.mouseAreaControl.PicturePanel.PointToView(new PointF((float)e.X, (float)e.Y)); SizeF ef1 = this.mouseAreaControl.PicturePanel.GridSize; float single1 = ef1.Height; float single2 = ef1.Width; if (this.mouseAreaControl.PicturePanel.SnapToGrid) { int num1 = (int)((tf1.X + (single2 / 2f)) / single2); int num2 = (int)((tf1.Y + (single1 / 2f)) / single1); tf1 = (PointF) new Point((int)(num1 * single2), (int)(num2 * single1)); } tf1 = this.mouseAreaControl.PicturePanel.PointToSystem(tf1); switch (this.operate) { case PolyOperate.MovePath: { PointF tf2 = this.mouseAreaControl.PicturePanel.PointToSystem(this.startpoint); Matrix matrix1 = new Matrix(); matrix1.Translate(tf1.X - tf2.X, tf1.Y - tf2.Y); matrix1.TransformPoints(this.points); break; } case PolyOperate.MovePoint: { if ((this.moveindex >= 0) && (this.moveindex < this.points.Length)) { this.points[this.moveindex] = tf1; if (this.graph is ConnectLine) { //连接线 bool flag2 = false; ConnectLine cebfd1 = this.graph as ConnectLine; if (this.connectGraph == null) { if (this.moveindex == 0) { string text3 = cebfd1.GetAttribute("start"); if ((text3 != null) && (text3.Length > 0)) { if (cebfd1.StartGraph != null) { cebfd1.StartGraph.ConnectLines.Remove(cebfd1); } AttributeFunc.SetAttributeValue(cebfd1, "start", string.Empty); flag2 = true; } float single11 = tf1.X; if (cebfd1.GetAttribute("x1") != single11.ToString()) { AttributeFunc.SetAttributeValue(cebfd1, "x1", single11.ToString()); flag2 = true; } single11 = tf1.Y; if (cebfd1.GetAttribute("y1") != single11.ToString()) { AttributeFunc.SetAttributeValue(cebfd1, "y1", single11.ToString()); flag2 = true; } } else { string text2 = cebfd1.GetAttribute("end"); if ((text2 != null) && (text2.Length > 0)) { if (cebfd1.EndGraph != null) { cebfd1.EndGraph.ConnectLines.Remove(cebfd1); } AttributeFunc.SetAttributeValue(cebfd1, "end", string.Empty); flag2 = true; } float single12 = tf1.X; if (cebfd1.GetAttribute("x2") != single12.ToString()) { AttributeFunc.SetAttributeValue(cebfd1, "x2", single12.ToString()); flag2 = true; } single12 = tf1.Y; if (cebfd1.GetAttribute("y2") != single12.ToString()) { AttributeFunc.SetAttributeValue(cebfd1, "y2", single12.ToString()); flag2 = true; } } } else { SvgElement ab1 = this.connectGraph as SvgElement; string text3 = ab1.GetAttribute("id"); if ((text3 == null) || (text3.Trim().Length == 0)) { text3 = CodeFunc.CreateString(this.mouseAreaControl.SVGDocument, ab1.LocalName); AttributeFunc.SetAttributeValue(ab1, "id", text3); } if (this.moveindex == 0) { text3 = "#" + text3; using (Matrix matrix1 = ((IGraph)ab1).GraphTransform.Matrix.Clone()) { PointF[] tfArray3 = ((IGraph)ab1).ConnectPoints.Clone() as PointF[]; matrix1.TransformPoints(tfArray3); int num1 = Array.IndexOf(tfArray3, this.connectPoint); if ((num1 >= 0) && (num1 < tfArray3.Length)) { text3 = text3 + "." + num1.ToString(); } tfArray3 = null; } if (text3 != cebfd1.GetAttribute("start")) { IGraph oldgraph = cebfd1.StartGraph; if (oldgraph != null) { oldgraph.ConnectLines.Remove(cebfd1); } AttributeFunc.SetAttributeValue(cebfd1, "start", text3); flag2 = true; } } else { text3 = "#" + text3; using (Matrix matrix3 = ((IGraph)ab1).GraphTransform.Matrix.Clone()) { PointF[] tfArray3 = ((IGraph)ab1).ConnectPoints.Clone() as PointF[]; matrix3.TransformPoints(tfArray3); int num2 = Array.IndexOf(tfArray3, this.connectPoint); if ((num2 >= 0) && (num2 < tfArray3.Length)) { text3 = text3 + "." + num2.ToString(); } tfArray3 = null; } if (text3 != cebfd1.GetAttribute("end")) { IGraph oldgraph = cebfd1.EndGraph; if (oldgraph != null) { oldgraph.ConnectLines.Remove(cebfd1); } AttributeFunc.SetAttributeValue(cebfd1, "end", text3); flag2 = true; } } } if (flag2) { this.mouseAreaControl.PicturePanel.InvalidateElement(this.connectGraph as SvgElement); } } } break; } } Matrix matrix2 = this.graph.GraphTransform.Matrix.Clone(); matrix2.Invert(); if (this.points.Length > 0) { matrix2.TransformPoints(this.points); } SvgDocument document1 = this.mouseAreaControl.SVGDocument; bool flag1 = document1.AcceptChanges; document1.AcceptChanges = true; string text1 = string.Empty; int num3 = 0; PointF[] tfArray1 = this.points; for (int num4 = 0; num4 < tfArray1.Length; num4++) { PointF tf3 = tfArray1[num4]; text1 = text1 + tf3.X.ToString() + " " + tf3.Y.ToString(); if (num3 < (this.points.Length - 1)) { text1 = text1 + ","; } num3++; } this.mouseAreaControl.PicturePanel.InvalidateElement((SvgElement)this.graph); document1.AcceptChanges = true; this.UpdateGraph(text1); document1.AcceptChanges = flag1; ((SvgElement)this.graph).pretime = -1; this.mouseAreaControl.Invalidate(); this.mouseAreaControl.PicturePanel.InvalidateElement((SvgElement)this.graph); } } }
public Pattern(TokenList aTokens, CodeFunc aCode) { Tokens = aTokens; Hash = aTokens.GetHashCode(); Code = aCode; }