示例#1
0
 // Methods
 internal Marker(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
     markerTransForm = new Matrix();
     brush = new SolidColor(Color.Black);
     stroke = new Stroke();
 }
示例#2
0
        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());
                }
            }
        }
示例#3
0
 // Methods
 internal GraphPath(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
     this.graphPath = new GraphicsPath();
     this.graphStroke = new Stroke();
     this.graphBrush = new SolidColor(Color.Empty);
     this.animpath = new GraphicsPath();
     //			this.startPoint = PointF.Empty;
     this.updateAttribute = true;
     this.graphStroke.OnStrokeBrushChanged += new EventHandler(this.ChangeStrokeBrush);
 }
示例#4
0
 // Methods
 public Stroke()
 {
     this.pen         = Pens.Black;
     this.brush       = new SolidColor(Color.Empty);
     this.strokeColor = Color.Empty;
     this.Width       = 1f;
     this.Linecap     = LineCap.Square;
     this.Linejoin    = LineJoin.Miter;
     this.MiterLimit  = 4;
     this.DashArray   = null;
     this.DashOffset  = 0f;
     this.Opacity     = 1f;
 }
示例#5
0
 // Methods
 public Stroke()
 {
     this.pen = Pens.Black;
     this.brush = new SolidColor(Color.Empty);
     this.strokeColor = Color.Empty;
     this.Width = 1f;
     this.Linecap = LineCap.Square;
     this.Linejoin = LineJoin.Miter;
     this.MiterLimit = 4;
     this.DashArray = null;
     this.DashOffset = 0f;
     this.Opacity = 1f;
 }
示例#6
0
 public Stroke(ISvgBrush brush)
 {
     this.pen = brush.Pen;
     //this.brush = new SolidColor(pen.Color);
     this.strokeColor = pen.Color;
     this.Width = 1f;
     this.Linecap = LineCap.Square;
     this.Linejoin = LineJoin.Miter;
     this.MiterLimit = 4;
     this.DashArray = null;
     this.DashOffset = 0f;
     this.Opacity = 1f;
     this.brush = brush.Clone();
 }
示例#7
0
 public Stroke(ISvgBrush brush)
 {
     this.pen = brush.Pen;
     //this.brush = new SolidColor(pen.Color);
     this.strokeColor = pen.Color;
     this.Width       = 1f;
     this.Linecap     = LineCap.Square;
     this.Linejoin    = LineJoin.Miter;
     this.MiterLimit  = 4;
     this.DashArray   = null;
     this.DashOffset  = 0f;
     this.Opacity     = 1f;
     this.brush       = brush.Clone();
 }
示例#8
0
        public static ISvgBrush GetSvgBrushFromGDIBrush(Brush brush, SvgDocument doc, string id)
        {
            if (brush == null)
            {
                return(new SolidColor(Color.Empty));
            }
            if (brush is SolidBrush)
            {
                Color      color1 = ((SolidBrush)brush).Color;
                SolidColor color2 = new SolidColor(Color.FromArgb(color1.R, color1.G, color1.B));
                color2.Opacity = ((float)color1.A) / 255f;
                return(color2);
            }
            ColorBlend blend1 = null;
            ISvgBrush  brush1 = null;

            if (brush is PathGradientBrush)
            {
                blend1 = ((PathGradientBrush)brush).InterpolationColors;
                brush1 = (RadialGradients)doc.CreateElement(doc.Prefix, "radialGradient", doc.NamespaceURI);
            }
            else
            {
                blend1 = ((LinearGradientBrush)brush).InterpolationColors;
                brush1 = (LinearGradient)doc.CreateElement(doc.Prefix, "linearGradient", doc.Name);
            }
            int num1 = 0;

            Color[] colorArray1 = blend1.Colors;
            for (int num2 = 0; num2 < colorArray1.Length; num2++)
            {
                Color        color3 = colorArray1[num2];
                GradientStop stop1  = (GradientStop)doc.CreateElement(doc.Prefix, "stop", doc.NamespaceURI);
                stop1.Color       = Color.FromArgb(color3.R, color3.G, color3.B);
                stop1.Opacity     = ((float)color3.A) / 255f;
                stop1.ColorOffset = blend1.Positions[num1];
                ((SvgElement)brush1).AppendChild(stop1);
                num1++;
            }
            ((SvgElement)brush1).ID = id;
            return(brush1);
        }
示例#9
0
 // Methods
 internal Group(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
     this.graphList = new SvgElementCollection();
     this.graphPath = new GraphicsPath();
     this.graphTransform = new Transf();
     this.graphBrush = new SolidColor(Color.Empty);
     this.graphStroke = new Stroke();
     this.connectPoints = new PointF[0];
     this.visible = true;
     this.showBound = false;
     this.tempOpacity = 1f;
     this.tempFillOpacity = 1f;
     this.tempStrokeOpacity = 1f;
     this.boundColor = Color.Empty;
     this.isLock = false;
     this.drawVisible = true;
     this.updateattribute = true;
     this.Changed = true;
     this.connectLines = new ItopVector.Core.SvgElementCollection();
     this.graphStroke.OnStrokeBrushChanged += new EventHandler(this.ChangeStrokeBrush);
     canSelect=true;
     this.limitSize =false;
 }
示例#10
0
        public override void Draw(Graphics g, int time)
        {
            if (base.DrawVisible)
            {
                GraphicsContainer container1 = g.BeginContainer();
//				if (this.pretime != time)
//				{
//					int num1 = 0;
//					int num2 = 0;
//					AnimFunc.CreateAnimateValues(this, time, out num1, out num2);
//				}
                Matrix matrix1 = this.Transform.Matrix.Clone();
                base.GraphTransform.Matrix.Multiply(matrix1, MatrixOrder.Prepend);
                if (!this.editMode)
                {
                    g.SmoothingMode = base.OwnerDocument.SmoothingMode;

                    if (this == this.OwnerTextElement)
                    {
                        ClipPath.Clip(g, time, this);
                    }
                    if (!base.Visible)
                    {
                        g.SetClip(Rectangle.Empty);
                    }
                    ISvgBrush brush1 = base.GraphBrush;

                    if (this == this.OwnerTextElement)
                    {
                        this.currentPostion = PointF.Empty;
                    }
                    float single1 = this.Size;
                    this.GPath = new GraphicsPath();
                    using (StringFormat format1 = this.GetGDIStringFormat())
                    {
                        using (FontFamily family1 = this.GetGDIFontFamily())
                        {
                            if (this.X == 0)
                            {
                                this.currentPostion.X = this.currentPostion.X + this.Dx;
                            }
                            else
                            {
                                this.currentPostion.X = (this.X + this.Dx);
                            }
                            if (this.Y == 0)
                            {
                                this.currentPostion.Y = this.currentPostion.Y + this.Dy;
                            }
                            else
                            {
                                this.currentPostion.Y = (this.Y + this.Dy);
                            }
                            //this.currentPostion.Y += (this.Y + this.Dy);
                            int num3 = this.GetGDIStyle();
                            base.TempFillOpacity   = Math.Min(1f, base.FillOpacity);
                            base.TempOpacity       = Math.Min(1f, base.Opacity);
                            base.TempStrokeOpacity = Math.Min(1f, base.StrokeOpacity);
                            this.old = true;
//							this.OwnerDocument.BeginPrint=true;
                            bool flag = false;
                            foreach (XmlNode node1 in this.ChildNodes)
                            {
                                GraphicsPath path1 = new GraphicsPath();
                                if (node1 is Text)
                                {
                                    ((Text)node1).currentPostion        = this.currentPostion;
                                    ((Text)node1).GraphTransform.Matrix = base.GraphTransform.Matrix.Clone();
                                    ((Text)node1).Draw(g, time);
                                    this.currentPostion = ((Text)node1).currentPostion;
                                    if (((Text)node1).GPath.PointCount > 0)
                                    {
                                        this.GPath.StartFigure();
                                        this.GPath.AddPath(((Text)node1).GPath, false);
                                    }
                                    continue;
                                }
                                if (node1.NodeType == XmlNodeType.Text)
                                {
                                    string text1 = "t";                                    //this.TrimText(node1.Value);
                                    Font   font1 = null;
                                    try
                                    {
                                        font1 = new Font(family1.Name, single1, (FontStyle)num3, GraphicsUnit.Pixel);
                                    }
                                    catch
                                    {
                                        int ii = 0;
                                        ii++;
                                    }
                                    float single2 = (((float)family1.GetCellAscent(FontStyle.Regular)) / ((float)family1.GetEmHeight(FontStyle.Regular))) * single1;
                                    SizeF ef1     = g.MeasureString(text1, font1, new PointF(this.currentPostion.X, this.currentPostion.Y - single2), format1);
                                    float single3 = ef1.Width;

                                    float single5 = (((float)family1.GetLineSpacing(FontStyle.Regular)) / ((float)family1.GetEmHeight(FontStyle.Regular))) * single1;                                        //Ðоà

                                    float offy = this.currentPostion.Y - single2;
                                    float offx = this.currentPostion.X;

                                    for (int i = 0; i < Lines.Length; i++)
                                    {
                                        if (!base.ShowBound && (this.OwnerDocument.BeginPrint || LimitSize))
                                        {
                                            GraphicsContainer gc = g.BeginContainer();
                                            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
                                            g.Transform         = base.GraphTransform.Matrix;
                                            //g.DrawString(lines[i], font1,new SolidBrush(Color.Black),100,100);
                                            Color color1 = Color.Black;
                                            if (this.SvgAttributes.Contains("stroke"))
                                            {
                                                color1 = Stroke.GetStroke(this).StrokeColor;
                                                if (color1.IsEmpty || color1 == Color.Transparent || color1 == Color.Empty)
                                                {
                                                    color1 = Color.Black;
                                                }
                                            }

                                            g.DrawString(lines[i], font1, new SolidBrush(color1), new PointF(offx, offy), format1);
                                            g.EndContainer(gc);
                                            SizeF ef2 = g.MeasureString(lines[i], font1, new PointF(offx, offy), format1);
                                            path1.AddString(lines[i], family1, num3, single1, new PointF(offx, offy), format1);
                                        }
                                        else
                                        {
                                            flag = true;
                                            path1.AddString(lines[i], family1, num3, single1, new PointF(offx, offy), format1);
                                        }
                                        if (Vertical)
                                        {
                                            offx += single5;
                                        }
                                        else
                                        {
                                            offy += single5;
                                        }
                                    }
                                    this.currentPostion.X += ((single3 * 3f) / 4f);
                                    this.GPath.StartFigure();
                                    this.GPath.AddPath(path1, false);
                                    float single4 = base.Opacity;
                                    if (this.svgAnimAttributes.ContainsKey("fill-opacity"))
                                    {
                                        single4 = Math.Min(single4, base.FillOpacity);
                                    }
                                    path1.Transform(base.GraphTransform.Matrix);
                                    if (!base.ShowBound && !(this.OwnerDocument.BeginPrint || LimitSize))
                                    {
                                        brush1.Paint(path1, g, time, single4);
                                        //								Stroke stroke1 = Stroke.GetStroke(this);
                                        //								stroke1.Paint(g, this,path1, time);
                                        base.GraphStroke.Paint(g, this, path1, 0);
                                        continue;
                                    }
                                    else if (flag)
                                    {
                                        g.DrawPath(new Pen(base.BoundColor), path1);
                                    }
                                }
                                path1.Dispose();
                            }
                        }
                    }

                    matrix1.Dispose();
                    ClipPath.DrawClip(g, time, this);
                    g.EndContainer(container1);
                    this.pretime = time;
                    this.old     = false;
                }
            }
        }
示例#11
0
        public override void Draw(Graphics g, int time)
        {
            int num1 = 0;
            int num2 = 0;

            AnimFunc.CreateAnimateValues(this, time, out num1, out num2);
            GraphicsContainer container1 = g.BeginContainer();

            g.SmoothingMode     = base.OwnerDocument.SmoothingMode;
            g.TextRenderingHint = base.OwnerDocument.TextRenderingHint;
            ISvgBrush brush1  = base.GraphBrush;
            float     single1 = base.Size;

            this.GPath = new GraphicsPath();
            GraphicsPath path1   = new GraphicsPath();
            StringFormat format1 = base.GetGDIStringFormat();
            FontFamily   family1 = base.GetGDIFontFamily();

            this.currentPostion.X += (base.X + base.Dx);
            this.currentPostion.Y += (base.Y + base.Dy);
            SvgElement element1 = this.RefElement;
            string     text1    = string.Empty;

            if (element1 is Text)
            {
                text1 = base.TrimText(element1.FirstChild.Value);
            }
            if (text1 != string.Empty)
            {
                float single2 = 0f;
                if (format1.Alignment == StringAlignment.Near)
                {
                    single2 = (single1 * 1f) / 6f;
                }
                else if (format1.Alignment == StringAlignment.Far)
                {
                    single2 = (-single1 * 1f) / 6f;
                }
                float single3 = (((float)family1.GetCellAscent(FontStyle.Regular)) / ((float)family1.GetEmHeight(FontStyle.Regular))) * single1;
                if (text1 != null)
                {
                    path1.AddString(text1, family1, base.GetGDIStyle(), single1, new PointF(this.currentPostion.X - single2, this.currentPostion.Y - single3), format1);
                }
                this.currentPostion.X -= single2;
                RectangleF ef1 = path1.GetBounds();
                if (!ef1.IsEmpty)
                {
                    RectangleF ef2     = path1.GetBounds();
                    float      single4 = ef2.Width;
                    if (format1.Alignment == StringAlignment.Center)
                    {
                        single4 /= 2f;
                    }
                    else if (format1.Alignment == StringAlignment.Far)
                    {
                        single4 = 0f;
                    }
                    this.currentPostion.X += (single4 + (single1 / 4f));
                }
                brush1.Paint(path1, g, time);
//                Stroke stroke1 = Stroke.GetStroke(this);
                base.GraphStroke.Paint(g, this, path1, time);
                this.GPath.StartFigure();
                this.GPath.AddPath(path1, false);
            }
            g.EndContainer(container1);
        }
示例#12
0
        // Methods
        public DrawArea()
        {
            this.components = null;
            this.mouseAreaControl = null;
            this.pageSetting = new PageSettings();
            this.drawMode = DrawModeType.ScreenImage;
            this.virtualLeft = 0f;
            this.virtualTop = 0f;
            this.scale = 1f;
            this.coordTransform = new Matrix();
            this.viewSize = new SizeF(500f, 500f);
            this.showGrid = true;
            this.showRule = true;
            this.showGuides = false;
            this.lockGuides = false;
            this.gridSize = new SizeF(10f, 10f);
            this.firstload = true;
            this.operation = ToolOperation.None;

            this.centerPoint = PointF.Empty;
            this.oldpoint = Point.Empty;
            this.prepathchanged = false;
            this.preGraph = null;
            this.UpdateRule = true;
            this.RefLines = new ArrayList(0x10);
            this.SnapToGrid = false;
            this.SnapToGuides = false;
            this.PreTextSelect = new SvgElementCollection();
            this.InitializeComponent();
            this.viewer.drawArea = this;
            this.margin = Size.Round(this.viewer.margin);
            this.mouseAreaControl.Focus();
            this.mouseAreaControl.PicturePanel = this;
            this.mouseAreaControl.DragAndDrop+=new DragEventHandler(mouseAreaControl_DragDrop);
            this.FillBrush = new SolidColor(Color.White);
            this.stroke = new Stroke(new SolidColor(Color.Black));
            this.backColor = new SolidBrush(Color.White);
            this.RatTextStyle = new ItopVector.Struct.TextStyle("����", 12, false, false, false);
            base.MouseWheel += new MouseEventHandler(this.DealMouseWheel);
            addedElements=new SvgElementCollection();
            this.viewer.ViewChanged +=new ViewChangedEventHandler(viewer_ViewChanged);
            this.mouseAreaControl.BeforeDragDrop+=new DragEventHandler(DrawArea_BeforeDragDrop);
            this.mouseAreaControl.OnPolyLineBreak += new PolyLineBreakEventHandler(mouseAreaControl_OnPolyLineBreak);
            this.mouseAreaControl.OnAddElement += new AddSvgElementEventHandler(mouseAreaControl_OnAddElement);
            this.mouseAreaControl.MouseMove += new MouseEventHandler(mouseAreaControl_MouseMove);
            this.mouseAreaControl.MouseDown += new MouseEventHandler(mouseAreaControl_MouseDown);
            this.mouseAreaControl.MouseUp += new MouseEventHandler(mouseAreaControl_MouseUp);
            this.mouseAreaControl.OnElementMove += new ElementMoveEventHandler(mouseAreaControl_OnElementMove);

            //            base.SetStyle(ControlStyles.DoubleBuffer | (ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint), true);
        }
示例#13
0
        public void OnPaint(PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
            ToolOperation operation1 = this.mouseAreaControl.CurrentOperation;
            SvgElement    element1   = this.mouseAreaControl.SVGDocument.CurrentElement;

            if (((operation1 == ToolOperation.GradientTransform) && (element1 is ISvgBrush)) && ((this.activeGraph != null) && !this.mouseAreaControl.SVGDocument.PlayAnim))
            {
                ISvgBrush  brush1 = (ISvgBrush)this.mouseAreaControl.SVGDocument.CurrentElement;
                RectangleF ef1    = RectangleF.Empty;
                if (!(brush1 is SolidColor))
                {
                    GraphicsPath path1    = new GraphicsPath();
                    PointF       tf1      = PointF.Empty;
                    PointF       tf2      = PointF.Empty;
                    PointF       tf3      = PointF.Empty;
                    PointF       tf4      = PointF.Empty;
                    PointF       tf5      = PointF.Empty;
                    PointF       tf6      = PointF.Empty;
                    PointF       tf7      = PointF.Empty;
                    PointF       tf8      = PointF.Empty;
                    PointF[]     tfArray1 = new PointF[1];
                    this.ratiomatrix.Reset();
                    this.gradientPath.Reset();
                    if (brush1 is LinearGradient)
                    {
                        LinearGradient gradient1 = (LinearGradient)brush1;
                        this.gradientPath  = (GraphicsPath)gradient1.GradientPath.Clone();
                        this.controlPoints = (PointF[])gradient1.BoundsPoints.Clone();
                        if (this.controlPoints.Length <= 0)
                        {
                            return;
                        }
                        this.graphMatrix = this.activeGraph.GraphTransform.Matrix.Clone();
                        this.graphMatrix.Multiply(gradient1.Coord);
                        this.gradientMatrix = gradient1.Transform.Matrix.Clone();
                        this.gradientPath.Transform(this.gradientMatrix);
                        this.gradientPath.Transform(this.graphMatrix);
                        e.Graphics.DrawPath(Pens.Black, this.gradientPath);
                        this.centerPoint = this.controlPoints[0];
                        this.gradientMatrix.TransformPoints(this.controlPoints);
                        this.graphMatrix.TransformPoints(this.controlPoints);
                        tf3 = this.controlPoints[0];
                        tf2 = this.controlPoints[1];
                        tf1 = this.controlPoints[2];
                        this.gradientPath = (GraphicsPath)gradient1.GradientPath.Clone();
                    }
                    else if (brush1 is RadialGradients)
                    {
                        RadialGradients gradients1 = (RadialGradients)brush1;
                        this.gradientPath  = (GraphicsPath)gradients1.GradientPath.Clone();
                        this.controlPoints = (PointF[])gradients1.BoundsPoints.Clone();
                        this.graphMatrix   = this.activeGraph.GraphTransform.Matrix.Clone();
                        this.graphMatrix.Multiply(gradients1.Coord);
                        this.gradientMatrix = gradients1.Transform.Matrix.Clone();
                        this.gradientPath.Transform(this.gradientMatrix);
                        this.gradientPath.Transform(this.graphMatrix);
                        e.Graphics.DrawPath(Pens.Black, this.gradientPath);
                        RectangleF ef3 = PathFunc.GetBounds(this.gradientPath);
                        this.gradientheight = ef3.Height;
                        this.centerPoint    = this.controlPoints[0];
                        this.gradientMatrix.TransformPoints(this.controlPoints);
                        this.graphMatrix.TransformPoints(this.controlPoints);
                        tf3 = this.controlPoints[0];
                        tf2 = this.controlPoints[2];
                        tf1 = this.controlPoints[3];
                        tf4 = this.controlPoints[1];
                        this.gradientPath = (GraphicsPath)gradients1.GradientPath.Clone();
                    }
                    else if (brush1 is Pattern)
                    {
                        Pattern pattern1 = (Pattern)brush1;
                        this.gradientPath = (GraphicsPath)pattern1.GradientPath.Clone();
                        RectangleF ef2 = this.gradientPath.GetBounds();
                        this.controlPoints  = (PointF[])pattern1.BoundsPoints.Clone();
                        this.graphMatrix    = this.activeGraph.GraphTransform.Matrix.Clone();
                        this.gradientMatrix = pattern1.Transform.Matrix.Clone();
                        this.gradientPath.Transform(this.gradientMatrix);
                        this.gradientPath.Transform(this.graphMatrix);
                        e.Graphics.DrawPath(Pens.Black, this.gradientPath);
                        RectangleF ef4 = PathFunc.GetBounds(this.gradientPath);
                        this.gradientheight = ef4.Height;
                        this.centerPoint    = this.controlPoints[0];
                        this.gradientMatrix.TransformPoints(this.controlPoints);
                        this.graphMatrix.TransformPoints(this.controlPoints);
                        tf3 = this.controlPoints[0];
                        tf1 = this.controlPoints[2];
                        tf7 = this.controlPoints[6];
                        tf5 = this.controlPoints[3];
                        tf6 = this.controlPoints[4];
                        tf2 = this.controlPoints[1];
                        tf8 = this.controlPoints[5];
                        this.gradientPath = (GraphicsPath)pattern1.GradientPath.Clone();
                    }
                    this.translatePath.Reset();
                    PointF[] tfArray2 = new PointF[4] {
                        new PointF(tf3.X, tf3.Y - 4f), new PointF(tf3.X - 4f, tf3.Y), new PointF(tf3.X, tf3.Y + 4f), new PointF(tf3.X + 4f, tf3.Y)
                    };
                    this.translatePath.AddPolygon(tfArray2);
                    e.Graphics.FillPath(Brushes.White, this.translatePath);
                    e.Graphics.DrawPath(Pens.Black, this.translatePath);
                    this.rotatePath.Reset();
                    this.rotatePath.AddEllipse((float)(tf1.X - 3f), (float)(tf1.Y - 3f), (float)6f, (float)6f);
                    this.scalePath.Reset();
                    this.scalePath.AddRectangle(new RectangleF(tf2.X - 3f, tf2.Y - 3f, 6f, 6f));
                    this.equalPath.Reset();
                    this.equalPath.AddEllipse((float)(tf4.X - 3f), (float)(tf4.Y - 3f), (float)6f, (float)6f);
                    this.skewxPath.Reset();
                    this.skewxPath.AddEllipse((float)(tf5.X - 3f), (float)(tf5.Y - 3f), (float)6f, (float)6f);
                    this.skewyPath.Reset();
                    this.skewyPath.AddEllipse((float)(tf6.X - 3f), (float)(tf6.Y - 3f), (float)6f, (float)6f);
                    this.anglescalePath.Reset();
                    this.anglescalePath.AddRectangle(new RectangleF(tf7.X - 3f, tf7.Y - 3f, 6f, 6f));
                    this.vscalPath.Reset();
                    this.vscalPath.AddRectangle(new RectangleF(tf8.X - 3f, tf8.Y - 3f, 6f, 6f));
                    e.Graphics.FillPath(Brushes.White, this.rotatePath);
                    e.Graphics.DrawPath(Pens.Black, this.rotatePath);
                    e.Graphics.FillPath(Brushes.White, this.scalePath);
                    e.Graphics.DrawPath(Pens.Black, this.scalePath);
                    e.Graphics.FillPath(Brushes.White, this.equalPath);
                    e.Graphics.DrawPath(Pens.Black, this.equalPath);
                    e.Graphics.FillPath(Brushes.White, this.skewxPath);
                    e.Graphics.DrawPath(Pens.Black, this.skewxPath);
                    e.Graphics.FillPath(Brushes.White, this.skewyPath);
                    e.Graphics.DrawPath(Pens.Black, this.skewyPath);
                    e.Graphics.FillPath(Brushes.White, this.anglescalePath);
                    e.Graphics.DrawPath(Pens.Black, this.anglescalePath);
                    e.Graphics.FillPath(Brushes.White, this.vscalPath);
                    e.Graphics.DrawPath(Pens.Black, this.vscalPath);
                }
            }
        }
示例#14
0
        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();
        }
示例#15
0
        public override void Draw(Graphics g, int time)
        {
            if (base.DrawVisible)
            {
                Matrix matrix1 = base.Transform.Matrix.Clone();

                GraphicsContainer container1 = g.BeginContainer();

                g.SmoothingMode = base.OwnerDocument.SmoothingMode;

                Matrix matrix2 = base.GraphTransform.Matrix.Clone();
                base.GraphTransform.Matrix.Multiply(matrix1, MatrixOrder.Prepend);


                ClipAndMask.ClipPath.Clip(g, time, this);
                bool flag1 = base.Visible;
                if (!base.Visible)
                {
                    g.SetClip(Rectangle.Empty);
                }
                float single1 = this.Opacity;
                if (this.svgAnimAttributes.ContainsKey("fill-opacity"))
                {
                    single1 = Math.Min(single1, (float)this.svgAnimAttributes["fill-opacity"]);
                }
                ISvgBrush brush1  = this.GraphBrush;
                Stroke    stroke1 = this.graphStroke;
                using (GraphicsPath path1 = (GraphicsPath)this.GPath.Clone())
                {
                    path1.Transform(base.GraphTransform.Matrix);
                    if (!base.ShowBound)
                    {
                        if (this.IsMarkerChild)
                        {
                            Marker marker = this.ParentNode as Marker;
                            this.IsChanged = false;
                            this.pretime   = time;
                            stroke1        = marker.GraphStroke;
                            if (brush1 != null && !brush1.IsEmpty())
                            {
                                brush1 = marker.GraphBrush;
                            }
                        }
                        if (((brush1 != null) && !(this is Line)) && !(this is Polyline))
                        {
                            brush1.Paint(path1, g, time, single1);
                        }

                        stroke1.Paint(g, this, path1, time);

                        if (this is Polyline)
                        {
                            if (LineType == "1")
                            {
                                //平行线,
                                using (Pen p = new Pen(brush1.Pen.Color)) {
                                    p.Width         = this.graphStroke.StrokePen.Width;
                                    p.CompoundArray = new float[] { 0f, 0.1f, 0.9f, 1f };
                                    g.DrawPath(p, path1);
                                }
                            }
                            else if (LineType == "2")   //铁路效果
                            {
                                using (Pen p = new Pen(Color.FromArgb(120, 120, 120))) {
                                    p.Width         = this.graphStroke.StrokePen.Width;
                                    p.CompoundArray = new float[] { 0f, 0.1f, 0.9f, 1f };
                                    g.DrawPath(p, path1);
                                }
                            }
                        }
                    }
                    else
                    {
                        g.DrawPath(new Pen(base.BoundColor), path1);
                    }
                    this.DrawConnect(g);
                }
                matrix1.Dispose();
                ClipAndMask.ClipPath.DrawClip(g, time, this);
                g.EndContainer(container1);
                this.pretime = time;
            }
        }
示例#16
0
        /// <summary>
        /// 马路
        /// </summary>
        /// <param name="g"></param>
        /// <param name="time"></param>
        private void Draw2(Graphics g, int time)
        {
            if (base.DrawVisible)
            {
                Matrix matrix1 = base.Transform.Matrix.Clone();

                GraphicsContainer container1 = g.BeginContainer();

                g.SmoothingMode = base.OwnerDocument.SmoothingMode;

                Matrix matrix2 = base.GraphTransform.Matrix.Clone();
                base.GraphTransform.Matrix.Multiply(matrix1, MatrixOrder.Prepend);


                ClipAndMask.ClipPath.Clip(g, time, this);
                bool flag1 = base.Visible;
                if (!base.Visible)
                {
                    g.SetClip(Rectangle.Empty);
                }
                float single1 = this.StrokeOpacity;
                if (this.svgAnimAttributes.ContainsKey("fill-opacity"))
                {
                    single1 = Math.Min(single1, (float)this.svgAnimAttributes["fill-opacity"]);
                }
                ISvgBrush brush1 = this.GraphBrush;
                using (GraphicsPath path1 = (GraphicsPath)this.GPath.Clone()) {
                    path1.Transform(base.GraphTransform.Matrix);
                    if (!base.ShowBound)
                    {
                        float  width1 = Width * GraphTransform.Matrix.Elements[0];
                        Stroke stroke = Stroke.GetStroke(this);
                        Color  color1 = Color.FromArgb(75, 75, 75);
                        if (stroke.StrokeColor.ToArgb() != Color.Black.ToArgb())
                        {
                            color1 = stroke.StrokeColor;
                        }
                        using (Pen p = new Pen(Color.FromArgb((int)(single1 * 255), color1))) {
                            p.Width = width1;
                            g.DrawPath(p, path1);
                        }
                        if (LineType == "3")
                        {
                            using (Pen p = new Pen(Color.Yellow)) {
                                if (width1 > 30)
                                {
                                    p.Width = 2;
                                }
                                else
                                {
                                    p.Width = 1;
                                }
                                //p.DashPattern = new float[] { 10, 10 };
                                g.DrawPath(p, path1);
                            }
                        }
                        else
                        {
                            //using (Pen p = new Pen(Color.Yellow)) {
                            //    if (width1 > 30)
                            //        p.Width = 2;
                            //    else
                            //        p.Width = 1;
                            //    g.DrawPath(p, path1);
                            //}
                        }
                        if (LineType == "4")
                        {
                            using (Pen p = new Pen(Color.FromArgb((int)(single1 * 255), color1))) {
                                p.Width = width1;
                                float           f22             = width1 / 4f;
                                ImageAttributes imageAttributes = new ImageAttributes();
                                ColorMatrix     cmatrix1        = new ColorMatrix();
                                cmatrix1.Matrix00 = 1f;
                                cmatrix1.Matrix11 = 1f;
                                cmatrix1.Matrix22 = 1f;
                                cmatrix1.Matrix33 = single1;//透明度
                                cmatrix1.Matrix44 = 1f;
                                //设置透明度
                                imageAttributes.SetColorMatrix(cmatrix1, ColorMatrixFlag.Default, ColorAdjustType.Default);
                                if (BackgroundImage == null)
                                {
                                    BackgroundImageFile = "road.png";
                                }
                                TextureBrush tbush = new TextureBrush(BackgroundImage, new Rectangle(0, 0, BackgroundImage.Width, BackgroundImage.Height), imageAttributes);
                                tbush.WrapMode = WrapMode.Tile;
                                for (int i = 0; i < path1.PointCount - 1; i++)
                                {
                                    float k = (path1.PathPoints[i + 1].Y - path1.PathPoints[i].Y) / (path1.PathPoints[i + 1].X - path1.PathPoints[i].X);

                                    float y1    = path1.PathPoints[i].Y - path1.PathPoints[i + 1].Y;
                                    float y2    = path1.PathPoints[i].X - path1.PathPoints[i + 1].X;
                                    float k2    = (float)Math.Abs(k);
                                    float angle = (float)Math.Atan(k2) * 180 / (float)Math.PI;
                                    if (k < 0)
                                    {
                                        angle = 360 - angle;
                                    }

                                    PointF[] pts      = new PointF[] { new PointF(path1.PathPoints[i].X, path1.PathPoints[i].Y - 26) };
                                    Matrix   matrix11 = new Matrix();
                                    matrix11.RotateAt(angle, path1.PathPoints[i]);
                                    matrix11.Translate(path1.PathPoints[i].X, path1.PathPoints[i].Y);
                                    matrix11.Scale(width1 / 50, width1 / 50);
                                    //tbush.ScaleTransform(width1 / 50, width1 / 50, MatrixOrder.Append);
                                    //tbush.RotateTransform(angle, MatrixOrder.Append);
                                    //tbush.TranslateTransform(path1.PathPoints[i].X, path1.PathPoints[i].Y , MatrixOrder.Append);
                                    tbush.Transform = matrix11;

                                    p.Brush     = tbush.Clone() as TextureBrush;
                                    p.Alignment = PenAlignment.Center;

                                    g.DrawLine(p, path1.PathPoints[i], path1.PathPoints[i + 1]);
                                    tbush.ResetTransform();
                                }
                            }
                            if (BackgroundImageFile == "road.png")
                            {
                                using (Pen p = new Pen(Color.Yellow)) {
                                    if (width1 > 30)
                                    {
                                        p.Width = 2;
                                    }
                                    else
                                    {
                                        p.Width = 1;
                                    }
                                    g.DrawPath(p, path1);
                                }
                            }
                        }
                    }
                    else
                    {
                        g.DrawPath(new Pen(base.BoundColor), path1);
                    }
                    this.DrawConnect(g);
                }
                matrix1.Dispose();
                ClipAndMask.ClipPath.DrawClip(g, time, this);
                g.EndContainer(container1);
                this.pretime = time;
            }
        }
示例#17
0
        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);
        }
示例#18
0
        private void draw2(Graphics g, int time)
        {
            if (base.DrawVisible)
            {
                GraphicsContainer container1 = g.BeginContainer();
                Matrix            matrix1    = base.Transform.Matrix.Clone();
                base.GraphTransform.Matrix.Multiply(matrix1, MatrixOrder.Prepend);
                if (!this.editMode)
                {
                    g.SmoothingMode = base.OwnerDocument.SmoothingMode;

                    if (this == this.OwnerTextElement)
                    {
                        ClipPath.Clip(g, time, this);
                    }
                    if (!base.Visible)
                    {
                        g.SetClip(Rectangle.Empty);
                    }
                    ISvgBrush brush1 = base.GraphBrush;

                    if (this == this.OwnerTextElement)
                    {
                        this.currentPostion = PointF.Empty;
                    }
                    float single1 = this.Size;
                    this.GPath = new GraphicsPath();
                    using (StringFormat format1 = this.GetGDIStringFormat())
                    {
                        using (FontFamily family1 = this.GetGDIFontFamily())
                        {
                            if (this.X == 0)
                            {
                                this.currentPostion.X = this.currentPostion.X + this.Dx;
                            }
                            else
                            {
                                this.currentPostion.X = (this.X + this.Dx);
                            }
                            if (this.Y == 0)
                            {
                                this.currentPostion.Y = this.currentPostion.Y + this.Dy;
                            }
                            else
                            {
                                this.currentPostion.Y = (this.Y + this.Dy);
                            }
                            //this.currentPostion.Y += (this.Y + this.Dy);
                            int num3 = this.GetGDIStyle();
                            base.TempFillOpacity   = Math.Min(1f, base.FillOpacity);
                            base.TempOpacity       = Math.Min(1f, base.Opacity);
                            base.TempStrokeOpacity = Math.Min(1f, base.StrokeOpacity);
                            this.old = true;
                            foreach (XmlNode node1 in this.ChildNodes)
                            {
                                GraphicsPath path1 = new GraphicsPath();
                                if (node1 is Text)
                                {
                                    ((Text)node1).currentPostion        = this.currentPostion;
                                    ((Text)node1).GraphTransform.Matrix = base.GraphTransform.Matrix.Clone();
                                    ((Text)node1).Draw(g, time);
                                    this.currentPostion = ((Text)node1).currentPostion;
                                    if (((Text)node1).GPath.PointCount > 0)
                                    {
                                        this.GPath.StartFigure();
                                        this.GPath.AddPath(((Text)node1).GPath, false);
                                    }
                                    continue;
                                }
                                if (node1.NodeType == XmlNodeType.Text)
                                {
                                    string text1   = "t";                                  //this.TrimText(node1.Value);
                                    Font   font1   = new Font(family1.Name, single1, (FontStyle)num3);
                                    float  single2 = (((float)family1.GetCellAscent(FontStyle.Regular)) / ((float)family1.GetEmHeight(FontStyle.Regular))) * single1;
                                    SizeF  ef1     = g.MeasureString(text1, font1, new PointF(this.currentPostion.X, this.currentPostion.Y - single2), format1);
                                    float  single3 = ef1.Width;

                                    float single5 = (((float)family1.GetLineSpacing(FontStyle.Regular)) / ((float)family1.GetEmHeight(FontStyle.Regular))) * single1;                                        //Ðоà

                                    float offy = this.currentPostion.Y - single2;
                                    float offx = this.currentPostion.X;
                                    for (int i = 0; i < Lines.Length; i++)
                                    {
                                        if (!base.ShowBound)
                                        {
                                            GraphicsContainer gc = g.BeginContainer();
                                            g.Transform = base.GraphTransform.Matrix;
                                            //g.DrawString(lines[i], font1,new SolidBrush(Color.Black),100,100);
                                            g.DrawString(lines[i], font1, new SolidBrush(Color.Black), new PointF(offx, offy));
                                            g.EndContainer(gc);
                                        }
                                        path1.AddString(lines[i], family1, num3, single1, new PointF(offx, offy), format1);
                                        if (Vertical)
                                        {
                                            offx += single5;
                                        }
                                        else
                                        {
                                            offy += single5;
                                        }
                                    }
                                    this.currentPostion.X += ((single3 * 3f) / 4f);
                                    this.GPath.StartFigure();
                                    this.GPath.AddPath(path1, false);
                                    float single4 = base.Opacity;
                                    if (this.svgAnimAttributes.ContainsKey("fill-opacity"))
                                    {
                                        single4 = Math.Min(single4, base.FillOpacity);
                                    }

                                    path1.Transform(base.GraphTransform.Matrix);

                                    if (!base.ShowBound)
                                    {
//										brush1.Paint(path1, g, time, single4);
//										//								Stroke stroke1 = Stroke.GetStroke(this);
//										//								stroke1.Paint(g, this,path1, time);
//										base.GraphStroke.Paint(g, this, path1, 0);
                                        continue;
                                    }
                                    else
                                    {
                                        g.DrawPath(new Pen(base.BoundColor), path1);
                                    }
                                }
                                path1.Dispose();
                            }
                        }
                    }

                    matrix1.Dispose();
                    ClipPath.DrawClip(g, time, this);
                    g.EndContainer(container1);
                    this.pretime = time;
                    this.old     = false;
                }
            }
        }
示例#19
0
        public static Brush GetGDIBrushFromSvgBrush(ISvgBrush brush)
        {
            if (brush is SolidColor)
            {
                return(new SolidBrush(((SolidColor)brush).Color));
            }
            SvgElementCollection collection1 = null;

            if (brush is LinearGradient)
            {
                collection1 = ((LinearGradient)brush).Stops;
            }
            else
            {
                collection1 = ((RadialGradients)brush).Stops;
            }
            ColorBlend blend1 = new ColorBlend(collection1.Count);

            Color[] colorArray1              = new Color[collection1.Count];
            float[] singleArray1             = new float[collection1.Count];
            SvgElementCollection collection2 = collection1;

            for (int num1 = 0; num1 < collection2.Count; num1++)
            {
                GradientStop stop1 = (GradientStop)collection2[num1];
                int          num2  = 0xff;
                if ((stop1.Opacity >= 0f) && (stop1.Opacity <= 255f))
                {
                    if (stop1.Opacity <= 1f)
                    {
                        num2 = (int)(stop1.Opacity * 255f);
                    }
                    else
                    {
                        num2 = (int)stop1.Opacity;
                    }
                }
                Color color1  = stop1.Color;
                float single1 = Math.Min((float)1f, Math.Max((float)0f, stop1.ColorOffset));
                colorArray1[num1]  = color1;
                singleArray1[num1] = single1;
            }
            float[] singleArray2 = (float[])singleArray1.Clone();
            Color[] colorArray2  = (Color[])colorArray1.Clone();
            Array.Sort(singleArray2, colorArray2);
            Color color2 = colorArray2[0];
            Color color3 = colorArray2[colorArray2.Length - 1];

            if (singleArray2[0] != 0f)
            {
                float[] singleArray3 = (float[])singleArray2.Clone();
                Color[] colorArray3  = (Color[])colorArray2.Clone();
                singleArray2 = new float[singleArray2.Length + 1];
                colorArray2  = new Color[colorArray2.Length + 1];
                colorArray3.CopyTo(colorArray2, 1);
                singleArray3.CopyTo(singleArray2, 1);
                singleArray2[0] = 0f;
                colorArray2[0]  = color2;
            }
            if (singleArray2[singleArray2.Length - 1] != 1f)
            {
                float[] singleArray4 = (float[])singleArray2.Clone();
                Color[] colorArray4  = (Color[])colorArray2.Clone();
                singleArray2 = new float[singleArray2.Length + 1];
                singleArray4.CopyTo(singleArray2, 0);
                singleArray2[singleArray2.Length - 1] = 1f;
                colorArray2 = new Color[colorArray2.Length + 1];
                colorArray4.CopyTo(colorArray2, 0);
                colorArray2[colorArray2.Length - 1] = color3;
            }
            if (brush is RadialGradients)
            {
                Array.Reverse(colorArray2);
            }
            Brush brush1 = null;

            blend1.Colors    = colorArray2;
            blend1.Positions = singleArray2;
            if (brush is LinearGradient)
            {
                brush1 = new LinearGradientBrush(new Point(0, 0), new Point(1, 0), color2, color3);
                ((LinearGradientBrush)brush1).WrapMode            = WrapMode.Tile;
                ((LinearGradientBrush)brush1).InterpolationColors = blend1;
            }
            else
            {
                GraphicsPath path1 = new GraphicsPath();
                path1.AddEllipse(0, 0, 1, 1);
                brush1 = new PathGradientBrush(path1);
                ((PathGradientBrush)brush1).WrapMode            = WrapMode.Tile;
                ((PathGradientBrush)brush1).InterpolationColors = blend1;
            }
            return(brush1);
        }
示例#20
0
        public void OnMouseDown(MouseEventArgs e)
        {
            bool   flag2;
            bool   flag3;
            PointF tf1;

            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            this.startpoint = 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)((this.startpoint.X + (single2 / 2f)) / single2);
                int num2 = (int)((this.startpoint.Y + (single1 / 2f)) / single1);
                this.startpoint = (PointF) new Point((int)(num1 * single2), (int)(num2 * single1));
            }
            SvgDocument document1 = this.mouseAreaControl.SVGDocument;
            bool        flag1     = document1.AcceptChanges;

            document1.NumberOfUndoOperations = 200;
            this.mousedown = true;
            switch (this.operate)
            {
            case PolyOperate.Draw:
            {
                document1.AcceptChanges = false;
                flag2 = false;
                if (this.graph != null)
                {
                    if (!(this.graph is Polygon) && !(this.graph is Polyline))
                    {
                        flag2 = true;
                    }
                    break;
                }
                flag2 = true;
                break;
            }

            case PolyOperate.MovePath:
            {
                goto Label_05F5;
            }

            case PolyOperate.MovePoint:
            {
                PointF tf3;
                this.nextPoint = tf3 = PointF.Empty;
                this.prePoint  = tf3;
                if ((this.moveindex < 0) || (this.moveindex >= this.points.Length))
                {
                    goto Label_05F5;
                }
                flag3 = this.graph is Polygon;
                if ((this.moveindex - 1) < 0)
                {
                    if ((this.points.Length >= 3) && flag3)
                    {
                        this.prePoint = this.points[this.points.Length - 1];
                    }
                    goto Label_042C;
                }
                this.prePoint = this.points[this.moveindex - 1];
                goto Label_042C;
            }

            case PolyOperate.Del:
            {
                if ((this.moveindex >= 0) && (this.moveindex < this.points.Length))
                {
                    ArrayList list1 = new ArrayList(this.points);
                    list1.RemoveAt(this.moveindex);
                    this.points = new PointF[list1.Count];
                    list1.CopyTo(this.points);
                    Matrix matrix1 = this.graph.GraphTransform.Matrix.Clone();
                    matrix1.Invert();
                    if (this.points.Length > 0)
                    {
                        matrix1.TransformPoints(this.points);
                    }
                }
                goto Label_05F5;
            }

            case PolyOperate.Add:
            {
                if ((this.insertindex < 0) || (this.insertindex >= this.points.Length))
                {
                    goto Label_05F5;
                }
                this.points = new PointF[0];
                if (!(this.graph is Polygon))
                {
                    if (this.graph is Polyline)
                    {
                        this.points = ((Polyline)this.graph).Points;
                    }
                    goto Label_058D;
                }
                this.points = ((Polygon)this.graph).Points;
                goto Label_058D;
            }

            default:
            {
                goto Label_05F5;
            }
            }
            if (flag2)
            {
                IGraph graph1 = this.mouseAreaControl.PicturePanel.PreGraph;
                if (graph1 == null)
                {
                    return;
                }
                this.graph = (Graph)((SvgElement)graph1).Clone();
                this.mouseAreaControl.SVGDocument.AcceptChanges = false;
                if (this.graph != null)
                {
                    ((SvgElement)this.graph).RemoveAttribute("points");
                }
                if (((SvgElement)this.graph) is IGraphPath)
                {
                    if ((((SvgElement)graph1).GetAttribute("style") != string.Empty) && (((SvgElement)graph1).GetAttribute("style") != null))
                    {
                        this.mouseAreaControl.SVGDocument.AcceptChanges = false;
                        AttributeFunc.SetAttributeValue((SvgElement)this.graph, "style", ((SvgElement)this.graph).GetAttribute("style"));
                    }
                    ISvgBrush brush1 = ((IGraphPath)graph1).GraphBrush;
                    if (brush1 is SvgElement)
                    {
                        ISvgBrush brush2 = (ISvgBrush)((SvgElement)brush1).Clone();
                        ((IGraphPath)this.graph).GraphBrush = brush2;
                        ((SvgElement)brush2).pretime        = -1;
                    }
                    else
                    {
                        ((IGraphPath)this.graph).GraphBrush = brush1;
                    }
                    brush1 = ((IGraphPath)graph1).GraphStroke.Brush;
                    if (brush1 is SvgElement)
                    {
                        ISvgBrush brush3 = (ISvgBrush)((SvgElement)brush1).Clone();
                        ((IGraphPath)this.graph).GraphStroke = new Stroke(brush3);
                        ((SvgElement)brush3).pretime         = -1;
                    }
                    else
                    {
                        ((IGraphPath)this.graph).GraphStroke.Brush = brush1;
                    }
                }
            }
            PointF[] tfArray1 = new PointF[0];
            if (this.graph is Polygon)
            {
                tfArray1 = ((Polygon)this.graph).Points;
            }
            else if (this.graph is Polyline)
            {
                tfArray1 = ((Polyline)this.graph).Points;
            }
            this.points = new PointF[1];
            if (tfArray1 != null)
            {
                this.points = new PointF[tfArray1.Length + 1];
                tfArray1.CopyTo(this.points, 0);
            }
            this.points[this.points.Length - 1] = this.startpoint;
            goto Label_05F5;
Label_042C:
            if ((this.moveindex + 1) < this.points.Length)
            {
                this.nextPoint = this.points[this.moveindex + 1];
                goto Label_05F5;
            }
            if ((this.points.Length >= 3) && flag3)
            {
                this.nextPoint = this.points[0];
            }
            goto Label_05F5;
Label_058D:
            tf1 = this.mouseAreaControl.PicturePanel.PointToView(new PointF((float)e.X, (float)e.Y));
            ArrayList list2 = new ArrayList(this.points);

            list2.Insert(this.insertindex, tf1);
            this.points = new PointF[list2.Count];
            list2.CopyTo(this.points);
Label_05F5:
            if (((this.operate == PolyOperate.Del) || (this.operate == PolyOperate.Draw)) || (this.operate == PolyOperate.Add))
            {
                string   text1    = string.Empty;
                int      num3     = 0;
                PointF[] tfArray2 = this.points;
                for (int num4 = 0; num4 < tfArray2.Length; num4++)
                {
                    PointF tf2 = tfArray2[num4];
                    text1 = text1 + tf2.X.ToString() + " " + tf2.Y.ToString();
                    if (num3 < (this.points.Length - 1))
                    {
                        text1 = text1 + ",";
                    }
                    num3++;
                }
                this.mouseAreaControl.PicturePanel.InvalidateElement((SvgElement)this.graph);
                if (((SvgElement)this.graph).ParentNode == null)
                {
                    this.UpdateGraph(text1);
                    document1.AcceptChanges = true;
                    IGraph graph2 = this.graph;
                    this.mouseAreaControl.PicturePanel.AddElement(this.graph);
                    this.graph = graph2;
                }
                else
                {
                    document1.AcceptChanges = true;
                    this.UpdateGraph(text1);
                }
                document1.AcceptChanges = flag1;
                this.mouseAreaControl.Invalidate();
                if (this.graph != null)
                {
                    ((SvgElement)this.graph).pretime = -1;
                    this.mouseAreaControl.PicturePanel.InvalidateElement((SvgElement)this.graph);
                }
            }
            document1.NotifyUndo();
            this.reversePath.Reset();
        }
示例#21
0
        public void OnMouseDown(MouseEventArgs e)
        {
            bool   flag2;
            bool   flag3;
            PointF tf1;


            if (e.Button == MouseButtons.Left)
            {            //wlwl
                this.startpoint = this.mouseAreaControl.PicturePanel.PointToView(new PointF(e.X, e.Y));
                if (this.mouseAreaControl.CurrentOperation == ToolOperation.XPolyLine)
                {
                    if (points.Length > 0)
                    {
                        this.startpoint = this.mouseAreaControl.PicturePanel.PointToView(new PointF((float)e.X, points[0].Y));
                    }
                    else
                    {
                        this.startpoint = this.mouseAreaControl.PicturePanel.PointToView(new PointF((float)e.X, (float)e.Y));
                    }
                }
                if (this.mouseAreaControl.CurrentOperation == ToolOperation.YPolyLine)
                {
                    if (points.Length > 0)
                    {
                        this.startpoint = this.mouseAreaControl.PicturePanel.PointToView(new PointF(points[0].X, (float)e.Y));
                    }
                    else
                    {
                        this.startpoint = this.mouseAreaControl.PicturePanel.PointToView(new PointF((float)e.X, (float)e.Y));
                    }
                }
                if (this.mouseAreaControl.CurrentOperation == ToolOperation.PolyLine ||
                    this.mouseAreaControl.CurrentOperation == ToolOperation.Polygon ||
                    this.mouseAreaControl.CurrentOperation == ToolOperation.InterEnclosure ||
                    this.mouseAreaControl.CurrentOperation == ToolOperation.Enclosure ||
                    this.mouseAreaControl.CurrentOperation == ToolOperation.LeadLine ||
                    this.mouseAreaControl.CurrentOperation == ToolOperation.AreaPolygon)
                {
                    this.startpoint = this.mouseAreaControl.PicturePanel.PointToView(new PointF((float)e.X, (float)e.Y));
                }
                if (this.mouseAreaControl.CurrentOperation == ToolOperation.Enclosure || this.mouseAreaControl.CurrentOperation == ToolOperation.InterEnclosure)
                {
                    this.AreaPoints.Add(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)((this.startpoint.X + (single2 / 2f)) / single2);
                    int num2 = (int)((this.startpoint.Y + (single1 / 2f)) / single1);
                    this.startpoint = (PointF) new Point((int)(num1 * single2), (int)(num2 * single1));
                }
                SvgDocument document1 = this.mouseAreaControl.SVGDocument;
                bool        flag1     = document1.AcceptChanges;
                document1.NumberOfUndoOperations = 200;
                this.mousedown = true;
                switch (this.operate)
                {
                case PolyOperate.Draw:
                {
                    document1.AcceptChanges = false;
                    flag2 = false;
                    if (this.graph != null)
                    {
                        if (!(this.graph is Polygon) && !(this.graph is Polyline))
                        {
                            flag2 = true;
                        }
                        break;
                    }
                    flag2 = true;
                    break;
                }

                case PolyOperate.MovePath:
                {
                    goto Label_05F5;
                }

                case PolyOperate.MovePoint:
                {
                    PointF tf3;
                    this.nextPoint = tf3 = PointF.Empty;
                    this.prePoint  = tf3;
                    if ((this.moveindex < 0) || (this.moveindex >= this.points.Length))
                    {
                        goto Label_05F5;
                    }
                    flag3 = this.graph is Polygon;
                    if ((this.moveindex - 1) < 0)
                    {
                        if ((this.points.Length >= 3) && flag3)
                        {
                            this.prePoint = this.points[this.points.Length - 1];
                        }
                        goto Label_042C;
                    }
                    this.prePoint = this.points[this.moveindex - 1];
                    goto Label_042C;
                }

                case PolyOperate.Del:
                {
                    if ((this.moveindex >= 0) && (this.moveindex < this.points.Length))
                    {
                        ArrayList list1 = new ArrayList(this.points);
                        list1.RemoveAt(this.moveindex);
                        this.points = new PointF[list1.Count];
                        list1.CopyTo(this.points);
                        Matrix matrix1 = this.graph.GraphTransform.Matrix.Clone();
                        matrix1.Invert();
                        if (this.points.Length > 0)
                        {
                            matrix1.TransformPoints(this.points);
                        }
                    }
                    goto Label_05F5;
                }

                case PolyOperate.Break:                        //线路断开
                {
                    if ((this.moveindex > 0) && (this.moveindex < this.points.Length - 1))
                    {
                        ArrayList list1   = new ArrayList(this.points);
                        PointF[]  points2 = new PointF[this.points.Length - moveindex];

                        this.points = new PointF[moveindex + 1];
                        list1.CopyTo(0, this.points, 0, this.moveindex + 1);
                        list1.CopyTo(moveindex, points2, 0, list1.Count - moveindex);

                        Matrix matrix1 = this.graph.GraphTransform.Matrix.Clone();
                        matrix1.Invert();
                        if (points2.Length > 0)
                        {
                            matrix1.TransformPoints(points2);
                            SvgElement copyEelement = (this.graph as XmlNode).CloneNode(true) as SvgElement;
                            IGraph     graph1       = this.graph;

                            copyEelement.SetAttribute("info-name", ((SvgElement)graph1).GetAttribute("info-name") + "-2");
                            ((SvgElement)graph).SetAttribute("info-name", ((SvgElement)graph1).GetAttribute("info-name") + "-1");
                            copyEelement = this.mouseAreaControl.PicturePanel.AddElement(copyEelement);
                            this.mouseAreaControl.SVGDocument.CurrentElement = graph1 as SvgElement;
                            copyEelement.RemoveAttribute("points");
                            UpdateGraph(copyEelement, points2);
                            this.mouseAreaControl.PicturePanel.InvalidateElement(copyEelement);
                            BreakElementEventArgs copy = new BreakElementEventArgs(copyEelement);
                            if (OnPolyLineBreak != null && copyEelement != null)
                            {
                                OnPolyLineBreak(this.mouseAreaControl.SVGDocument.CurrentElement, copy);
                            }
                        }
                        if (this.points.Length > 0)
                        {
                            matrix1.TransformPoints(this.points);
                        }
                    }
                    else
                    {
                        return;
                    }
                    goto Label_05F5;
                }

                case PolyOperate.Add:
                {
                    if ((this.insertindex < 0) || (this.insertindex >= this.points.Length))
                    {
                        goto Label_05F5;
                    }
                    this.points = new PointF[0];
                    if (!(this.graph is Polygon))
                    {
                        if (this.graph is Polyline)
                        {
                            this.points = ((Polyline)this.graph).Points;
                        }
                        goto Label_058D;
                    }
                    this.points = ((Polygon)this.graph).Points;
                    goto Label_058D;
                }

                default:
                {
                    goto Label_05F5;
                }
                }
                if (flag2)
                {
                    IGraph graph1 = this.mouseAreaControl.PicturePanel.PreGraph;
                    if (graph1 == null)
                    {
                        return;
                    }
                    this.graph = (Graph)((SvgElement)graph1).Clone();
                    this.mouseAreaControl.SVGDocument.AcceptChanges = false;
                    if (this.graph != null)
                    {
                        ((SvgElement)this.graph).RemoveAttribute("points");
                    }
                    if (((SvgElement)this.graph) is IGraphPath)
                    {
                        if ((((SvgElement)graph1).GetAttribute("style") != string.Empty) && (((SvgElement)graph1).GetAttribute("style") != null))
                        {
                            this.mouseAreaControl.SVGDocument.AcceptChanges = false;
                            AttributeFunc.SetAttributeValue((SvgElement)this.graph, "style", ((SvgElement)this.graph).GetAttribute("style"));
                        }
                        ISvgBrush brush1 = ((IGraphPath)graph1).GraphBrush;
                        if (brush1 is SvgElement)
                        {
                            ISvgBrush brush2 = (ISvgBrush)((SvgElement)brush1).Clone();
                            ((IGraphPath)this.graph).GraphBrush = brush2;
                            ((SvgElement)brush2).pretime        = -1;
                        }
                        else
                        {
                            ((IGraphPath)this.graph).GraphBrush = brush1;
                        }
                        brush1 = ((IGraphPath)graph1).GraphStroke.Brush;
                        if (brush1 is SvgElement)
                        {
                            ISvgBrush brush3 = (ISvgBrush)((SvgElement)brush1).Clone();
                            ((IGraphPath)this.graph).GraphStroke = new Stroke(brush3);
                            ((SvgElement)brush3).pretime         = -1;
                        }
                        else
                        {
                            ((IGraphPath)this.graph).GraphStroke.Brush = brush1;
                        }
                    }
                }
                PointF[] tfArray1 = new PointF[0];
                if (this.graph is Polygon)
                {
                    tfArray1 = ((Polygon)this.graph).Points;
                }
                else if (this.graph is Polyline)
                {
                    tfArray1 = ((Polyline)this.graph).Points;
                }
                this.points = new PointF[1];
                int insertIndex = 0;
                if (tfArray1 != null)
                {
                    ;
                    this.points = new PointF[tfArray1.Length + 1];

                    if (addBegin)
                    {
                        tfArray1.CopyTo(this.points, 1);
                    }
                    else
                    {
                        tfArray1.CopyTo(this.points, 0);
                        insertIndex = tfArray1.Length;
                    }
                }
                if (addBegin || addEnd)
                {
                    Matrix matrix1 = this.graph.GraphTransform.Matrix.Clone();
                    matrix1.Invert();
                    PointF[] points2 = new PointF[1] {
                        new PointF(e.X, e.Y)
                    };
                    matrix1.TransformPoints(points2);
                    this.startpoint = points2[0];
                }

                this.points[insertIndex] = this.startpoint;
                goto Label_05F5;
Label_042C:
                if ((this.moveindex + 1) < this.points.Length)
                {
                    this.nextPoint = this.points[this.moveindex + 1];
                    goto Label_05F5;
                }
                if ((this.points.Length >= 3) && flag3)
                {
                    this.nextPoint = this.points[0];
                }
                goto Label_05F5;
Label_058D:
                Matrix matrix2 = this.graph.GraphTransform.Matrix.Clone();
                matrix2.Invert();
                //tf1 = this.mouseAreaControl.PicturePanel.PointToView(new PointF((float)e.X, (float)e.Y));//new PointF((float) e.X, (float) e.Y)
                PointF[] tfTemp = new PointF[1] {
                    new PointF(e.X, e.Y)
                };
                matrix2.TransformPoints(tfTemp);
                ArrayList list2 = new ArrayList(this.points);
                list2.Insert(this.insertindex, tfTemp[0]);
                this.points = new PointF[list2.Count];
                list2.CopyTo(this.points);

Label_05F5:
                //2006-10-23 设置围栏初始颜色
//				if(this.mouseAreaControl.CurrentOperation == ToolOperation.Enclosure || this.mouseAreaControl.CurrentOperation == ToolOperation.InterEnclosure)
//				{
//					((XmlElement) this.graph).SetAttribute("style","fill:#C0C0FF;fill-opacity:0.3;stroke:#000000;stroke-opacity:1;");
//				}


                if (((this.operate == PolyOperate.Del) || (this.operate == PolyOperate.Draw)) || (this.operate == PolyOperate.Add) || (this.operate == PolyOperate.Break))
                {
                    StringBuilder text1    = new StringBuilder();
                    int           num3     = 0;
                    PointF[]      tfArray2 = this.points;
                    for (int num4 = 0; num4 < tfArray2.Length; num4++)
                    {
                        PointF tf2 = tfArray2[num4];
                        text1.Append(tf2.X.ToString() + " " + tf2.Y.ToString());
                        if (num3 < (this.points.Length - 1))
                        {
                            text1.Append(",");
                        }
                        num3++;
                    }
                    this.mouseAreaControl.PicturePanel.InvalidateElement((SvgElement)this.graph);
                    if (((SvgElement)this.graph).ParentNode == null)
                    {
                        this.UpdateGraph(text1.ToString());
                        document1.AcceptChanges = true;
                        IGraph graph2 = this.graph;
                        this.mouseAreaControl.PicturePanel.AddElement(this.graph);
                        this.graph = graph2;
                    }
                    else
                    {
                        document1.AcceptChanges = true;
                        this.UpdateGraph(text1.ToString());
                    }
                    document1.AcceptChanges = flag1;
                    this.mouseAreaControl.Invalidate();
                    if (this.graph != null)
                    {
                        ((SvgElement)this.graph).pretime = -1;
                        this.mouseAreaControl.PicturePanel.InvalidateElement((SvgElement)this.graph);
                    }
                }
                document1.NotifyUndo();
                this.reversePath.Reset();
            }
            else if (e.Button == MouseButtons.Right)           //任务1
            {
                if (this.mouseAreaControl.CurrentOperation == ToolOperation.Enclosure || this.mouseAreaControl.CurrentOperation == ToolOperation.InterEnclosure)
                {
                    //this.AreaPoints.Add(new PointF((float) e.X, (float) e.Y));

//					this.mouseAreaControl.GoBottom((SvgElement)this.graph);
//					((SvgElement)this.graph).Clone();
                    PointF[] tfArray1 = new PointF[this.AreaPoints.Count];
                    this.AreaPoints.CopyTo(tfArray1, 0);
                    this.AreaPoints.Clear();

                    Matrix matrix1 = new Matrix();
                    if (tfArray1.Length < 3)
                    {
                        this.mouseAreaControl.CurrentOperation = ToolOperation.Select;
                        return;
                    }
                    this.selectAreaPath = new GraphicsPath();
                    this.selectAreaPath.AddLines(tfArray1);
                    this.selectAreaPath.CloseFigure();


                    Region region1 = new Region(this.selectAreaPath);

                    RectangleF r1 = selectAreaPath.GetBounds();
                    /* 2005环境 当前区域需要手动添加进集合*/
                    XmlNode    node1  = ((SvgElement)this.graph).Clone();
                    SvgElement svgele = (SvgElement)node1;

                    this.mouseAreaControl.SVGDocument.ClearSelects();

                    using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
                    {
                        foreach (ILayer layer1 in mouseAreaControl.SVGDocument.Layers)
                        {
                            if (!layer1.Visible)
                            {
                                continue;
                            }

                            SvgElementCollection.ISvgElementEnumerator enumerator1 = layer1.GraphList.GetEnumerator();
                            while (enumerator1.MoveNext())
                            {
                                IGraph graph1 = (IGraph)enumerator1.Current;
                                if (!graph1.Visible || !graph1.DrawVisible || this.graph == graph1)
                                {
                                    continue;
                                }
                                GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone();
                                path1.Transform(graph1.GraphTransform.Matrix);
                                Region ef1 = null;
                                if (graph1 is Use)
                                {
                                    ef1 = new Region(PathFunc.GetBounds(path1));
                                }
                                else if (graph1 is Line)
                                {
                                    ef1 = new Region(PathFunc.GetBounds(path1));
                                }
                                else
                                {
                                    ef1 = new Region(path1);
                                }

                                // 设置围栏选择方式为完全包含才能选中
                                if (this.mouseAreaControl.CurrentOperation == ToolOperation.Enclosure)
                                {
                                    RectangleF rt1 = ef1.GetBounds(g);
                                    ef1.Intersect(region1);
                                    if (ef1.GetBounds(g) == rt1)
                                    {
                                        this.mouseAreaControl.SVGDocument.AddSelectElement(graph1);
                                    }
                                    continue;
                                }

                                // 设置围栏选择方式为搭边即选中
                                if (this.mouseAreaControl.CurrentOperation == ToolOperation.InterEnclosure)
                                {
                                    ef1.Intersect(region1);

                                    if (!ef1.GetBounds(g).IsEmpty)
                                    //if ((region1.IsVisible(ef1/*new System.Drawing.Rectangle((int) ef1.X, (int) ef1.Y, (int) ef1.Width, (int) ef1.Height)*/) && !graph1.IsLock) && (graph1.DrawVisible /*&& (AnimFunc.GetKeyIndex((SvgElement) graph1, this.mouseAreaControl.SVGDocument.ControlTime, true) >= 0)*/))
                                    {
                                        this.mouseAreaControl.SVGDocument.AddSelectElement(graph1);
                                    }
                                }
                            }
                        }
                        this.mouseAreaControl.SVGDocument.AddSelectElement(graph);
                    }

                    GraphicsPath path2 = new GraphicsPath();
                    path2.AddLines(tfArray1);
                    RectangleF ef2 = path2.GetBounds();
                    /* 2005 环境下使用,2003环境下需删除否则出现重复.原因不明.*/
                    if (this.mouseAreaControl.CurrentOperation == ToolOperation.Enclosure)
                    {
                        this.mouseAreaControl.SVGDocument.AddSelectElement(svgele);
                    }
                    this.mouseAreaControl.Invalidate(new System.Drawing.Rectangle(((int)ef2.X) - 10, ((int)ef2.Y) - 10, ((int)ef2.Width) + 20, ((int)ef2.Height) + 20));
                    return;
                }
            }             //鼠标右键抬起
        }
示例#22
0
        private void Update(IGraphPath path)
        {
            Pen       pen1   = null;
            string    text1  = AttributeFunc.ParseAttribute("stroke", (SvgElement)path, false).ToString();
            ISvgBrush brush1 = new SolidColor(Color.Black);

            if ((text1 != null) && (text1 != string.Empty))
            {
                brush1 = BrushManager.Parsing(text1, ((SvgElement)path).OwnerDocument);
            }
            text1 = AttributeFunc.ParseAttribute("stroke-opacity", (SvgElement)path, false).ToString();
            float single1 = 1f;

            if ((text1 != string.Empty) && (text1 != null))
            {
                single1 = Math.Max((float)0f, Math.Min((float)255f, ItopVector.Core.Func.Number.ParseFloatStr(text1)));
            }
            if (single1 > 1f)
            {
                single1 /= 255f;
            }
            single1 = Math.Min(path.Opacity, path.StrokeOpacity);
            float  single2 = 1f;
            object obj1    = AttributeFunc.ParseAttribute("stroke-width", (SvgElement)path, false);

            if (obj1 is float)
            {
                single2 = (float)obj1;
            }
            pen1           = new Pen(Color.Empty, single2);
            pen1.Alignment = PenAlignment.Outset;
            string text2 = AttributeFunc.FindAttribute("stroke-linecap", (SvgElement)path).ToString();

            if (text2 == "round")
            {
                LineCap cap1;
                pen1.EndCap   = cap1 = LineCap.Round;
                pen1.StartCap = cap1;
            }
            else if (text2 == "square")
            {
                LineCap cap2;
                pen1.EndCap   = cap2 = LineCap.Square;
                pen1.StartCap = cap2;
            }
            else
            {
                LineCap cap3;
                pen1.EndCap   = cap3 = LineCap.Flat;
                pen1.StartCap = cap3;
            }
            string text3 = AttributeFunc.FindAttribute("stroke-linejoin", (SvgElement)path).ToString();

            if (text3 == "round")
            {
                pen1.LineJoin = LineJoin.Round;
            }
            else if (text3 == "bevel")
            {
                pen1.LineJoin = LineJoin.Bevel;
            }
            else
            {
                pen1.LineJoin = LineJoin.Miter;
            }
            string text4 = AttributeFunc.FindAttribute("stroke-miterlimit", (SvgElement)path).ToString();

            if (text4 == "")
            {
                text4 = "4";
            }
            float single3 = ItopVector.Core.Func.Number.parseToFloat(text4, (SvgElement)path, SvgLengthDirection.Horizontal);

            if (single3 < 1f)
            {
                throw new Exception("stroke-miterlimit " + ItopVector.Core.Config.Config.GetLabelForName("notlowerstr") + " 1:" + text4);
            }
            pen1.MiterLimit = single3;
            string text5 = AttributeFunc.FindAttribute("stroke-dasharray", (SvgElement)path).ToString();

            if ((text5 != "") && (text5 != "none"))
            {
                Regex regex1 = new Regex(@"[\s\,]+");
                text5 = regex1.Replace(text5, ",");
                char[] chArray1 = new char[1] {
                    ','
                };
                string[] textArray1   = text5.Split(chArray1);
                float[]  singleArray1 = new float[textArray1.GetLength(0)];
                for (int num1 = 0; num1 < textArray1.GetLength(0); num1++)
                {
                    singleArray1[num1] = ItopVector.Core.Func.Number.parseToFloat(textArray1[num1], (SvgElement)path, SvgLengthDirection.Horizontal) / pen1.Width;
                }
                if ((singleArray1.GetLength(0) % 2) == 1)
                {
                    float[] singleArray2 = new float[singleArray1.GetLength(0) * 2];
                    singleArray1.CopyTo(singleArray2, 0);
                    singleArray1.CopyTo(singleArray2, singleArray1.GetLength(0));
                    singleArray1 = singleArray2;
                }
                pen1.DashPattern = singleArray1;
            }
            string text6   = AttributeFunc.FindAttribute("stroke-dashoffset", (SvgElement)path).ToString();
            float  single4 = 0f;

            if (text6 != "")
            {
                single4 = ItopVector.Core.Func.Number.parseToFloat(text6, (SvgElement)path, SvgLengthDirection.Horizontal);
            }
            float single5 = Math.Abs((float)AnimFunc.GetAnimateValue((SvgElement)path, "stroke-dashoffset", DomType.SvgNumber, single4)) / pen1.Width;

            pen1.DashOffset = single5 / single2;

            this.pen   = pen1;
            this.Width = pen1.Width;
            if (brush1 != null)
            {
                brush1.Pen = pen1;
            }
            this.Opacity = single1;
            this.brush   = brush1;
        }
示例#23
0
 private void PostBrush(object sender, ISvgBrush brush)
 {
     if (this.PostBrushEvent != null)
     {
         this.PostBrushEvent(this, brush);
     }
 }
示例#24
0
        public void OnMouseMove(MouseEventArgs e)
        {
            SizeF         ef1        = this.mouseAreaControl.PicturePanel.GridSize;
            float         single1    = ef1.Width;
            float         single2    = ef1.Height;
            ToolOperation operation1 = this.mouseAreaControl.CurrentOperation;

            if (operation1 == ToolOperation.GradientTransform)
            {
                this.mouseAreaControl.PicturePanel.ToolTip(this.gradientstr, 1);
            }
            else if (operation1 == ToolOperation.ColorPicker)
            {
                this.mouseAreaControl.PicturePanel.ToolTip(this.colorpickerstr, 1);
            }
            if ((operation1 == ToolOperation.GradientTransform) && (this.activeGraph != null))
            {
                ISvgBrush brush1 = this.activeGraph.GraphBrush;
                if (!(brush1 is SolidColor))
                {
                    ITransformBrush brush2 = (ITransformBrush)brush1;
                    bool            flag1  = brush2.Units == Units.UserSpaceOnUse;
                    if (e.Button == MouseButtons.None)
                    {
                        Pen pen1 = new Pen(Color.Blue, 4f);
                        pen1.Alignment = PenAlignment.Center;
                        PointF tf1 = new PointF((float)e.X, (float)e.Y);
                        if (this.translatePath.IsVisible(tf1) || this.translatePath.IsOutlineVisible(tf1, pen1))
                        {
                            this.mouseAreaControl.Cursor = SpecialCursors.GradientTranslateCursor;
                        }
                        else if (this.scalePath.IsVisible(tf1) || this.scalePath.IsOutlineVisible(tf1, pen1))
                        {
                            this.mouseAreaControl.Cursor = SpecialCursors.VScaleCursor;
                        }
                        else if (this.rotatePath.IsOutlineVisible(tf1, pen1) || this.rotatePath.IsVisible(tf1))
                        {
                            this.mouseAreaControl.Cursor = SpecialCursors.RotateCursor;
                        }
                        else if (this.equalPath.IsOutlineVisible(tf1, pen1) || this.equalPath.IsVisible(tf1))
                        {
                            this.mouseAreaControl.Cursor = SpecialCursors.EqualScaleCursor;
                        }
                        else if (this.vscalPath.IsOutlineVisible(tf1, pen1) || this.vscalPath.IsVisible(tf1))
                        {
                            this.mouseAreaControl.Cursor = SpecialCursors.HScaleCursor;
                        }
                        else if (this.skewxPath.IsOutlineVisible(tf1, pen1) || this.skewxPath.IsVisible(tf1))
                        {
                            this.mouseAreaControl.Cursor = SpecialCursors.SkewXCursor;
                        }
                        else if (this.skewyPath.IsOutlineVisible(tf1, pen1) || this.skewyPath.IsVisible(tf1))
                        {
                            this.mouseAreaControl.Cursor = SpecialCursors.SkewYCursor;
                        }
                        else if (this.anglescalePath.IsOutlineVisible(tf1, pen1) || this.anglescalePath.IsVisible(tf1))
                        {
                            this.mouseAreaControl.Cursor = SpecialCursors.TopRightScaleCursor;
                        }
                        else
                        {
                            this.mouseAreaControl.Cursor = this.mouseAreaControl.DefaultCursor;
                        }
                    }
                    else if ((e.Button == MouseButtons.Left) && (this.mouseAreaControl.Cursor != this.mouseAreaControl.DefaultCursor))
                    {
                        PointF tf2 = this.mouseAreaControl.PicturePanel.PointToView(this.startPoint);
                        PointF tf3 = this.mouseAreaControl.PicturePanel.PointToView(new PointF((float)e.X, (float)e.Y));
                        if (this.mouseAreaControl.PicturePanel.SnapToGrid)
                        {
                            int num1 = (int)((tf2.X + (single1 / 2f)) / single1);
                            int num2 = (int)((tf2.Y + (single2 / 2f)) / single2);
                            tf2  = (PointF) new Point((int)(num1 * single1), (int)(num2 * single2));
                            num1 = (int)((tf3.X + (single1 / 2f)) / single1);
                            num2 = (int)((tf3.Y + (single2 / 2f)) / single2);
                            tf3  = (PointF) new Point((int)(num1 * single1), (int)(single2 * num2));
                        }
                        tf2            = this.mouseAreaControl.PicturePanel.PointToSystem(tf2);
                        tf3            = this.mouseAreaControl.PicturePanel.PointToSystem(tf3);
                        this.win32.hdc = this.win32.W32GetDC(this.mouseAreaControl.Handle);
                        this.win32.W32SetROP2(6);
                        this.win32.W32PolyDraw(this.reversePath);
                        Matrix matrix1 = this.gradientMatrix.Clone();
                        if (((this.mouseAreaControl.Cursor == SpecialCursors.VScaleCursor) || (this.mouseAreaControl.Cursor == SpecialCursors.HScaleCursor)) || (this.mouseAreaControl.Cursor == SpecialCursors.TopRightScaleCursor))
                        {
                            PointF[] tfArray6 = new PointF[5] {
                                tf2, tf3, this.controlPoints[0], this.controlPoints[1], this.controlPoints[5]
                            };
                            PointF[] tfArray1 = tfArray6;
                            Matrix   matrix2  = this.graphMatrix.Clone();
                            matrix2.Multiply(this.gradientMatrix);
                            matrix2.Invert();
                            matrix2.TransformPoints(tfArray1);
                            float single3 = 1f;
                            if (tfArray1[3].X != tfArray1[2].X)
                            {
                                single3 = 1f + ((tfArray1[1].X - tfArray1[0].X) / (tfArray1[3].X - tfArray1[2].X));
                            }
                            float single4 = 1f;
                            if (tfArray1[4].Y != tfArray1[2].Y)
                            {
                                single4 = 1f + ((tfArray1[1].Y - tfArray1[0].Y) / (tfArray1[4].Y - tfArray1[2].Y));
                            }
                            if (flag1)
                            {
                                matrix1.Translate(this.centerPoint.X, this.centerPoint.Y);
                            }
                            else
                            {
                                matrix1.Translate(0.5f, 0.5f);
                            }
                            if (this.mouseAreaControl.Cursor == SpecialCursors.VScaleCursor)
                            {
                                single4 = 1f;
                            }
                            else if (this.mouseAreaControl.Cursor == SpecialCursors.HScaleCursor)
                            {
                                single3 = 1f;
                            }
                            matrix1.Scale(single3, single4);
                            if (flag1)
                            {
                                matrix1.Translate(-this.centerPoint.X, -this.centerPoint.Y);
                            }
                            else
                            {
                                matrix1.Translate(-0.5f, -0.5f);
                            }
                        }
                        else if ((this.mouseAreaControl.Cursor == SpecialCursors.SkewXCursor) || (this.mouseAreaControl.Cursor == SpecialCursors.SkewYCursor))
                        {
                            PointF[] tfArray7 = new PointF[5] {
                                tf2, tf3, this.controlPoints[0], this.controlPoints[3], this.controlPoints[4]
                            };
                            PointF[] tfArray2 = tfArray7;
                            Matrix   matrix3  = this.graphMatrix.Clone();
                            matrix3.Multiply(this.gradientMatrix);
                            matrix3.Invert();
                            matrix3.TransformPoints(tfArray2);
                            float single5 = 0f;
                            if (tfArray2[3].Y != tfArray2[2].Y)
                            {
                                single5 = ((tfArray2[1].X - tfArray2[0].X) / (tfArray2[3].Y - tfArray2[2].Y)) * 0.5f;
                            }
                            float single6 = 0f;
                            if (tfArray2[4].X != tfArray2[2].X)
                            {
                                single6 = ((tfArray2[1].Y - tfArray2[0].Y) / (tfArray2[4].X - tfArray2[2].X)) * 0.5f;
                            }
                            if (this.mouseAreaControl.Cursor == SpecialCursors.SkewXCursor)
                            {
                                single6 = 0f;
                            }
                            else if (this.mouseAreaControl.Cursor == SpecialCursors.SkewYCursor)
                            {
                                single5 = 0f;
                            }
                            if (flag1)
                            {
                                matrix1.Translate(this.centerPoint.X, this.centerPoint.Y);
                            }
                            else
                            {
                                matrix1.Translate(0.5f, 0.5f);
                            }
                            matrix1.Shear(single5, single6);
                            if (flag1)
                            {
                                matrix1.Translate(-this.centerPoint.X, -this.centerPoint.Y);
                            }
                            else
                            {
                                matrix1.Translate(-0.5f, -0.5f);
                            }
                        }
                        else if (this.mouseAreaControl.Cursor == SpecialCursors.RotateCursor)
                        {
                            PointF tf4     = this.controlPoints[0];
                            float  single7 = (float)Math.Atan((double)((tf2.Y - tf4.Y) / (tf2.X - tf4.X)));
                            float  single8 = (float)Math.Atan((double)((tf3.Y - tf4.Y) / (tf3.X - tf4.X)));
                            float  single9 = ((float)(((double)(single8 - single7)) / 3.1415926535897931)) * 180f;
                            if (((tf3.X - tf4.X) * (tf2.X - tf4.X)) < 0f)
                            {
                                single9 += 180f;
                            }
                            matrix1 = this.gradientMatrix.Clone();
                            PointF[] tfArray8 = new PointF[1] {
                                new PointF(0.5f, 0.5f)
                            };
                            PointF[] tfArray3 = tfArray8;
                            if (flag1)
                            {
                                PointF[] tfArray9 = new PointF[1] {
                                    this.centerPoint
                                };
                                tfArray3 = tfArray9;
                            }
                            this.gradientMatrix.TransformPoints(tfArray3);
                            matrix1.RotateAt(single9, tfArray3[0], MatrixOrder.Append);
                        }
                        else if (this.mouseAreaControl.Cursor == SpecialCursors.GradientTranslateCursor)
                        {
                            PointF[] tfArray10 = new PointF[5] {
                                tf2, tf3, this.controlPoints[0], this.controlPoints[1], this.controlPoints[4]
                            };
                            PointF[] tfArray4 = tfArray10;
                            bool     flag2    = tfArray4[4].IsEmpty;
                            Matrix   matrix4  = this.graphMatrix.Clone();
                            matrix4.Multiply(this.gradientMatrix);
                            matrix4.Invert();
                            matrix4.TransformPoints(tfArray4);
                            float single10 = tfArray4[1].X - tfArray4[0].X;
                            if (!flag1)
                            {
                                single10 /= (tfArray4[3].X - tfArray4[2].X);
                            }
                            else
                            {
                                single10 *= 2f;
                            }
                            float single11 = tfArray4[1].Y - tfArray4[0].Y;
                            if (!flag1)
                            {
                                single11 /= (tfArray4[4].Y - tfArray4[2].Y);
                            }
                            else
                            {
                                single11 *= 2f;
                            }
                            single10 /= 2f;
                            single11 /= 2f;
                            matrix1.Translate(single10, single11);
                        }
                        else if (this.mouseAreaControl.Cursor == SpecialCursors.EqualScaleCursor)
                        {
                            PointF[] tfArray11 = new PointF[5] {
                                tf2, tf3, this.controlPoints[0], this.controlPoints[1], this.controlPoints[4]
                            };
                            PointF[] tfArray5 = tfArray11;
                            Matrix   matrix5  = this.graphMatrix.Clone();
                            matrix5.Multiply(this.gradientMatrix);
                            matrix5.Invert();
                            matrix5.TransformPoints(tfArray5);
                            float single12 = 1f + ((tfArray5[1].X - tfArray5[0].X) / (tfArray5[3].X - tfArray5[2].X));
                            if (flag1)
                            {
                                matrix1.Translate(this.centerPoint.X, this.centerPoint.Y);
                            }
                            else
                            {
                                matrix1.Translate(0.5f, 0.5f);
                            }
                            matrix1.Scale(single12, single12);
                            if (flag1)
                            {
                                matrix1.Translate(-this.centerPoint.X, -this.centerPoint.Y);
                            }
                            else
                            {
                                matrix1.Translate(-0.5f, -0.5f);
                            }
                        }
                        if (this.mouseAreaControl.Cursor == SpecialCursors.RotateCursor)
                        {
                            this.reversePath = (GraphicsPath)this.gradientPath.Clone();
                            Matrix matrix6 = this.graphMatrix.Clone();
                            matrix6.Multiply(matrix1);
                            this.reversePath.Transform(matrix6);
                        }
                        else
                        {
                            this.reversePath = (GraphicsPath)this.gradientPath.Clone();
                            this.reversePath.Transform(matrix1);
                            this.reversePath.Transform(this.graphMatrix);
                        }
                        this.win32.W32PolyDraw(this.reversePath);
                        this.win32.ReleaseDC();
                    }
                }
            }
        }
示例#25
0
        private void Update(IGraphPath path)
        {
            Pen pen1 = null;
            string text1 = AttributeFunc.ParseAttribute("stroke", (SvgElement) path, false).ToString();
            ISvgBrush brush1 = new SolidColor(Color.Black);
            if ((text1 != null) && (text1 != string.Empty))
            {
                brush1 = BrushManager.Parsing(text1, ((SvgElement) path).OwnerDocument);
            }
            text1 = AttributeFunc.ParseAttribute("stroke-opacity", (SvgElement) path, false).ToString();
            float single1 = 1f;
            if ((text1 != string.Empty) && (text1 != null))
            {
                single1 = Math.Max((float) 0f, Math.Min((float) 255f, ItopVector.Core.Func.Number.ParseFloatStr(text1)));
            }
            if (single1 > 1f)
            {
                single1 /= 255f;
            }
            single1 = Math.Min(path.Opacity, path.StrokeOpacity);
            float single2 = 1f;
            object obj1 = AttributeFunc.ParseAttribute("stroke-width", (SvgElement) path, false);
            if (obj1 is float)
            {
                single2 = (float) obj1;
            }
            pen1 = new Pen(Color.Empty, single2);
            pen1.Alignment = PenAlignment.Outset;
            string text2 = AttributeFunc.FindAttribute("stroke-linecap", (SvgElement) path).ToString();
            if (text2 == "round")
            {
                LineCap cap1;
                pen1.EndCap = cap1 = LineCap.Round;
                pen1.StartCap = cap1;
            }
            else if (text2 == "square")
            {
                LineCap cap2;
                pen1.EndCap = cap2 = LineCap.Square;
                pen1.StartCap = cap2;
            }
            else
            {
                LineCap cap3;
                pen1.EndCap = cap3 = LineCap.Flat;
                pen1.StartCap = cap3;
            }
            string text3 = AttributeFunc.FindAttribute("stroke-linejoin", (SvgElement) path).ToString();
            if (text3 == "round")
            {
                pen1.LineJoin = LineJoin.Round;
            }
            else if (text3 == "bevel")
            {
                pen1.LineJoin = LineJoin.Bevel;
            }
            else
            {
                pen1.LineJoin = LineJoin.Miter;
            }
            string text4 = AttributeFunc.FindAttribute("stroke-miterlimit", (SvgElement) path).ToString();
            if (text4 == "")
            {
                text4 = "4";
            }
            float single3 = ItopVector.Core.Func.Number.parseToFloat(text4, (SvgElement) path, SvgLengthDirection.Horizontal);
            if (single3 < 1f)
            {
                throw new Exception("stroke-miterlimit " + ItopVector.Core.Config.Config.GetLabelForName("notlowerstr") + " 1:" + text4);
            }
            pen1.MiterLimit = single3;
            string text5 = AttributeFunc.FindAttribute("stroke-dasharray", (SvgElement) path).ToString();
            if ((text5 != "") && (text5 != "none"))
            {
                Regex regex1 = new Regex(@"[\s\,]+");
                text5 = regex1.Replace(text5, ",");
                char[] chArray1 = new char[1] { ',' } ;
                string[] textArray1 = text5.Split(chArray1);
                float[] singleArray1 = new float[textArray1.GetLength(0)];
                for (int num1 = 0; num1 < textArray1.GetLength(0); num1++)
                {
                    singleArray1[num1] = ItopVector.Core.Func.Number.parseToFloat(textArray1[num1], (SvgElement) path, SvgLengthDirection.Horizontal) / pen1.Width;
                }
                if ((singleArray1.GetLength(0) % 2) == 1)
                {
                    float[] singleArray2 = new float[singleArray1.GetLength(0) * 2];
                    singleArray1.CopyTo(singleArray2, 0);
                    singleArray1.CopyTo(singleArray2, singleArray1.GetLength(0));
                    singleArray1 = singleArray2;
                }
                pen1.DashPattern = singleArray1;
            }
            string text6 = AttributeFunc.FindAttribute("stroke-dashoffset", (SvgElement) path).ToString();
            float single4 = 0f;
            if (text6 != "")
            {
                single4 = ItopVector.Core.Func.Number.parseToFloat(text6, (SvgElement) path, SvgLengthDirection.Horizontal);
            }
            float single5 = Math.Abs((float) AnimFunc.GetAnimateValue((SvgElement) path, "stroke-dashoffset", DomType.SvgNumber, single4)) / pen1.Width;
            pen1.DashOffset = single5 / single2;

            this.pen=pen1;
            this.Width=pen1.Width;
            if (brush1 != null)
            {
                brush1.Pen = pen1;
            }
            this.Opacity = single1;
            this.brush = brush1;
        }