public void OnMouseUp(MouseEventArgs e) { if ((this.activeGraph == null) || (this.mouseAreaControl.Cursor == this.mouseAreaControl.DefaultCursor)) { return; } if (e.Button != MouseButtons.Left) { return; } if (!(this.mouseAreaControl.SVGDocument.CurrentElement is ITransformBrush)) { return; } ISvgBrush brush1 = (ISvgBrush)this.mouseAreaControl.SVGDocument.CurrentElement; if (brush1 is SolidColor) { return; } SizeF ef1 = this.mouseAreaControl.PicturePanel.GridSize; float single1 = ef1.Width; float single2 = ef1.Height; this.win32.hdc = this.win32.W32GetDC(this.mouseAreaControl.Handle); this.win32.W32SetROP2(6); this.win32.W32PolyDraw(this.reversePath); this.win32.ReleaseDC(); float single3 = this.mouseAreaControl.PicturePanel.ScaleUnit; PointF tf1 = this.mouseAreaControl.PicturePanel.PointToView(this.startPoint); PointF tf2 = this.mouseAreaControl.PicturePanel.PointToView(new PointF((float)e.X, (float)e.Y)); if (this.mouseAreaControl.PicturePanel.SnapToGrid) { int num1 = (int)((tf1.X + (single1 / 2f)) / single1); int num2 = (int)((tf1.Y + (single2 / 2f)) / single2); tf1 = (PointF) new Point((int)(num1 * single1), (int)(num2 * single2)); num1 = (int)((tf2.X + (single1 / 2f)) / single1); num2 = (int)((tf2.Y + (single2 / 2f)) / single2); tf2 = (PointF) new Point((int)(num1 * single1), (int)(single2 * num2)); } tf1 = this.mouseAreaControl.PicturePanel.PointToSystem(tf1); tf2 = this.mouseAreaControl.PicturePanel.PointToSystem(tf2); this.win32.hdc = this.win32.W32GetDC(this.mouseAreaControl.Handle); this.win32.W32SetROP2(6); this.win32.W32PolyDraw(this.reversePath); this.win32.ReleaseDC(); Transf transf1 = new Transf(); transf1 = ((ITransformBrush)brush1).Transform; SvgElement element1 = (SvgElement)brush1; ITransformBrush brush2 = (ITransformBrush)brush1; bool flag1 = brush2.Units == Units.UserSpaceOnUse; SvgDocument document1 = this.mouseAreaControl.SVGDocument; if (((((this.mouseAreaControl.Cursor == SpecialCursors.VScaleCursor) | (this.mouseAreaControl.Cursor == SpecialCursors.HScaleCursor)) | (this.mouseAreaControl.Cursor == SpecialCursors.TopRightScaleCursor)) | (this.mouseAreaControl.Cursor == SpecialCursors.EqualScaleCursor)) && (this.controlPoints.Length >= 6)) { //string text11; PointF[] tfArray5 = new PointF[5] { tf1, tf2, this.controlPoints[0], this.controlPoints[1], this.controlPoints[5] }; PointF[] tfArray1 = tfArray5; Matrix matrix1 = this.graphMatrix.Clone(); matrix1.Multiply(this.gradientMatrix); matrix1.Invert(); matrix1.TransformPoints(tfArray1); float single4 = 1f; if (tfArray1[3].X != tfArray1[2].X) { single4 = 1f + ((tfArray1[1].X - tfArray1[0].X) / (tfArray1[3].X - tfArray1[2].X)); } float single5 = 1f; if (tfArray1[4].Y != tfArray1[2].Y) { single5 = 1f + ((tfArray1[1].Y - tfArray1[0].Y) / (tfArray1[4].Y - tfArray1[2].Y)); } if (this.mouseAreaControl.Cursor == SpecialCursors.VScaleCursor) { single5 = 1f; } else if (this.mouseAreaControl.Cursor == SpecialCursors.HScaleCursor) { single4 = 1f; } else if (this.mouseAreaControl.Cursor == SpecialCursors.EqualScaleCursor) { single5 = single4; } if ((element1.InfoList.Count == 1)) { if (flag1) { transf1.setTranslate(this.centerPoint.X, this.centerPoint.Y); } else { transf1.setTranslate(0.5f, 0.5f); } transf1.setScale(single4, single5); if (flag1) { transf1.setTranslate(-this.centerPoint.X, -this.centerPoint.Y); } else { transf1.setTranslate(-0.5f, -0.5f); } string text1 = transf1.ToString(); string text2 = "gradientTransform"; if (brush2 is Pattern) { text2 = "patternTransform"; } bool flag2 = document1.AcceptChanges; document1.AcceptChanges = true; document1.NumberOfUndoOperations = 1; AttributeFunc.SetAttributeValue(element1, text2, text1); document1.AcceptChanges = flag2; element1.pretime = -1; goto Label_1771; } } if ((this.mouseAreaControl.Cursor == SpecialCursors.SkewXCursor) || (this.mouseAreaControl.Cursor == SpecialCursors.SkewYCursor)) { //string text16; PointF[] tfArray6 = new PointF[5] { tf1, tf2, this.controlPoints[0], this.controlPoints[3], this.controlPoints[4] }; PointF[] tfArray2 = tfArray6; Matrix matrix2 = this.graphMatrix.Clone(); matrix2.Multiply(this.gradientMatrix); matrix2.Invert(); matrix2.TransformPoints(tfArray2); float single6 = 0f; if (tfArray2[3].Y != tfArray2[2].Y) { single6 = ((tfArray2[1].X - tfArray2[0].X) / (tfArray2[3].Y - tfArray2[2].Y)) * 0.5f; } float single7 = 0f; if (tfArray2[4].X != tfArray2[2].X) { single7 = ((tfArray2[1].Y - tfArray2[0].Y) / (tfArray2[4].X - tfArray2[2].X)) * 0.5f; } if (this.mouseAreaControl.Cursor == SpecialCursors.SkewXCursor) { single7 = 0f; } else if (this.mouseAreaControl.Cursor == SpecialCursors.SkewYCursor) { single6 = 0f; } if ((element1.InfoList.Count == 1)) { if (flag1) { transf1.setTranslate(this.centerPoint.X, this.centerPoint.Y); } else { transf1.setTranslate(0.5f, 0.5f); } transf1.Matrix.Shear(single6, single7); if (flag1) { transf1.setTranslate(-this.centerPoint.X, -this.centerPoint.Y); } else { transf1.setTranslate(-0.5f, -0.5f); } string text3 = transf1.ToString(); string text4 = "gradientTransform"; if (brush2 is Pattern) { text4 = "patternTransform"; } bool flag4 = document1.AcceptChanges; document1.AcceptChanges = true; document1.NumberOfUndoOperations = 1; AttributeFunc.SetAttributeValue(element1, text4, text3); document1.AcceptChanges = flag4; element1.pretime = -1; goto Label_1771; } } if (this.mouseAreaControl.Cursor == SpecialCursors.RotateCursor) { //string text19; PointF tf3 = this.controlPoints[0]; float single8 = (float)Math.Atan((double)((tf1.Y - tf3.Y) / (tf1.X - tf3.X))); float single9 = (float)Math.Atan((double)((tf2.Y - tf3.Y) / (tf2.X - tf3.X))); float single10 = ((float)(((double)(single9 - single8)) / 3.1415926535897931)) * 180f; if (((tf2.X - tf3.X) * (tf1.X - tf3.X)) < 0f) { single10 += 180f; } if (single10 < 0f) { single10 += 360f; } PointF[] tfArray7 = new PointF[1] { new PointF(0.5f, 0.5f) }; PointF[] tfArray3 = tfArray7; if (flag1) { PointF[] tfArray8 = new PointF[1] { this.centerPoint }; tfArray3 = tfArray8; } this.gradientMatrix.TransformPoints(tfArray3); if ((element1.InfoList.Count == 1)) { transf1.Matrix.RotateAt(single10, tfArray3[0], MatrixOrder.Append); string text5 = transf1.ToString(); string text6 = "gradientTransform"; if (brush2 is Pattern) { text6 = "patternTransform"; } bool flag6 = document1.AcceptChanges; document1.AcceptChanges = true; AttributeFunc.SetAttributeValue(element1, text6, text5); document1.AcceptChanges = flag6; element1.pretime = -1; goto Label_1771; } } else if (this.mouseAreaControl.Cursor == SpecialCursors.GradientTranslateCursor) { PointF[] tfArray9 = new PointF[5] { tf1, tf2, this.controlPoints[0], this.controlPoints[1], this.controlPoints[4] }; PointF[] tfArray4 = tfArray9; Matrix matrix3 = this.graphMatrix.Clone(); matrix3.Multiply(this.gradientMatrix); matrix3.Invert(); matrix3.TransformPoints(tfArray4); float single11 = tfArray4[1].X - tfArray4[0].X; if (!flag1) { single11 /= (tfArray4[3].X - tfArray4[2].X); } else { single11 *= 2f; } float single12 = tfArray4[1].Y - tfArray4[0].Y; if (!flag1) { single12 /= (tfArray4[4].Y - tfArray4[2].Y); } else { single12 *= 2f; } single11 /= 2f; single12 /= 2f; if (element1.InfoList.Count == 1) { transf1.setTranslate(single11, single12); string text7 = transf1.ToString(); string text8 = "gradientTransform"; if (brush2 is Pattern) { text8 = "patternTransform"; } bool flag7 = document1.AcceptChanges; document1.AcceptChanges = true; AttributeFunc.SetAttributeValue(element1, text8, text7); document1.AcceptChanges = flag7; element1.pretime = -1; } } Label_1771: this.mouseAreaControl.Invalidate(); }
public SvgElement AddElement(ISvgElement mypath) { // AttributeFunc.SetAttributeValue((XmlElement)mypath,"layer",SvgDocument.currentLayer); XmlNode node1 = OwnerDocument.RootElement; XmlNode newNode = null; Matrix matrix1 = new Matrix(); // if (node1 is IGraph) // { // matrix1 = ((IGraph) node1).GraphTransform.Matrix.Clone(); // Matrix matrix2 = this.coordTransform.Clone(); // matrix2.Invert(); // matrix1.Multiply(matrix2, MatrixOrder.Append); // } // matrix1.Invert(); // matrix1 = TransformFunc.RoundMatrix(matrix1, 2); bool flag1 = OwnerDocument.AcceptChanges; // OwnerDocument.AcceptChanges = false; OwnerDocument.AcceptChanges = true; if (mypath is IGraphPath) { ISvgBrush brush1 = ((IGraphPath)mypath).GraphBrush; if ((brush1 is ITransformBrush) && (((SvgElement)brush1).ParentNode == null)) { bool flag2 = OwnerDocument.AcceptChanges; OwnerDocument.AcceptChanges = true; OwnerDocument.NumberOfUndoOperations++; XmlNode node2 = OwnerDocument.AddDefsElement((SvgElement)brush1); OwnerDocument.AcceptChanges = false; if (node2 is ITransformBrush) { string text1 = ((SvgElement)node2).ID; AttributeFunc.SetAttributeValue((SvgElement)mypath, "fill", "url(#" + text1 + ")"); } OwnerDocument.AcceptChanges = flag2; } brush1 = ((IGraphPath)mypath).GraphStroke.Brush; if ((brush1 is ITransformBrush) && (((SvgElement)brush1).ParentNode == null)) { bool flag3 = OwnerDocument.AcceptChanges; OwnerDocument.AcceptChanges = true; OwnerDocument.NumberOfUndoOperations++; XmlNode node3 = OwnerDocument.AddDefsElement((SvgElement)brush1); OwnerDocument.AcceptChanges = false; if (node3 is ITransformBrush) { string text2 = ((SvgElement)node3).ID; AttributeFunc.SetAttributeValue((SvgElement)mypath, "stroke", "url(#" + text2 + ")"); } OwnerDocument.AcceptChanges = flag3; } } if (!matrix1.IsIdentity && (mypath is IGraph)) { bool flag4 = OwnerDocument.AcceptChanges; OwnerDocument.AcceptChanges = false; Matrix matrix3 = ((IGraph)mypath).Transform.Matrix.Clone(); matrix1.Multiply(matrix3); Transf transf1 = new Transf(); transf1.setMatrix(matrix1); AttributeFunc.SetAttributeValue((SvgElement)mypath, "transform", transf1.ToString()); OwnerDocument.AcceptChanges = flag4; } if (((SvgElement)mypath).ParentNode != node1) { if (((ContainerElement)node1).IsValidChild((SvgElement)mypath)) { // node1.AppendChild((SvgElement) mypath); SvgElement element1 = (SvgElement)mypath; //(SvgElement)OwnerDocument.ImportNode((SvgElement) mypath,true); newNode = node1.AppendChild(element1); OwnerDocument.Render(element1); } } OwnerDocument.AcceptChanges = flag1; return(newNode != null?newNode as SvgElement:null); }