Exemple #1
0
 public void AddElement(SvgElement element)
 {
     if (!this.flowChilds.Contains(element))
     {
         this.flowChilds.Add(element);
     }
     if (element.ShowParticular)
     {
         this.flowChilds.AddRange(element.AnimateList);
     }
     if (element is IGraph)
     {
         ClipPath path1 = ((IGraph)element).ClipPath;
         if (path1 != null)
         {
             this.AddElement(path1);
         }
     }
     if ((element is IContainer) && element.ShowChilds)
     {
         SvgElementCollection.ISvgElementEnumerator enumerator1 = ((IContainer)element).ChildList.GetEnumerator();
         while (enumerator1.MoveNext())
         {
             SvgElement element1 = (SvgElement)enumerator1.Current;
             this.AddElement(element1);
         }
     }
 }
Exemple #2
0
        internal ClipPath ComputeClipPath(PathUtil.PathType type)
        {
            lock (this)
            {
                if (clipPathsCache[(int)type] == null)
                {
                    clipPathsCache[(int)type] = new ClipPath(this, type);
                }
            }

            return(clipPathsCache[(int)type]);
        }
Exemple #3
0
        private static void TestProfile(EightBimProfile profile)
        {
            Assert.IsNotNull(profile);

            Assert.AreEqual(2, profile.ClipPaths.Count());

            ClipPath first = profile.ClipPaths.First();

            Assert.AreEqual("Path 1", first.Name);
            XDocument doc = XDocument.Load(first.Path.CreateNavigator().ReadSubtree());

            Assert.AreEqual(@"<svg width=""200"" height=""200""><g><path fill=""#00000000"" stroke=""#00000000"" stroke-width=""0"" stroke-antialiasing=""false"" d=""M 45 58&#xA;L 80 124&#xA;L 147 147&#xA;L 45 147&#xA;L 45 58 Z&#xA;"" /></g></svg>", doc.ToString(SaveOptions.DisableFormatting));

            ClipPath second = profile.ClipPaths.Skip(1).First();

            Assert.AreEqual("Path 2", second.Name);
            doc = XDocument.Load(second.Path.CreateNavigator().ReadSubtree());

            Assert.AreEqual(@"<svg width=""200"" height=""200""><g><path fill=""#00000000"" stroke=""#00000000"" stroke-width=""0"" stroke-antialiasing=""false"" d=""M 52 144&#xA;L 130 57&#xA;L 157 121&#xA;L 131 106&#xA;L 52 144 Z&#xA;"" /></g></svg>", doc.ToString(SaveOptions.DisableFormatting));
        }
Exemple #4
0
 public void Insert(int index, SvgElement element)
 {
     if (!this.flowChilds.Contains(element))
     {
         this.flowChilds.Insert(index, element);
     }
     index++;
     if (element.ShowParticular)
     {
         SvgElementCollection.ISvgElementEnumerator enumerator1 = element.AnimateList.GetEnumerator();
         while (enumerator1.MoveNext())
         {
             ItopVector.Core.Animate.Animate animate1 = (ItopVector.Core.Animate.Animate)enumerator1.Current;
             if (!this.flowChilds.Contains(animate1))
             {
                 this.flowChilds.Insert(index, animate1);
                 index++;
             }
         }
     }
     if (element is IGraph)
     {
         ClipPath path1 = ((IGraph)element).ClipPath;
         if (path1 != null)
         {
             this.Insert(index, path1);
         }
     }
     if (element is IContainer)
     {
         SvgElementCollection.ISvgElementEnumerator enumerator2 = ((IContainer)element).ChildList.GetEnumerator();
         while (enumerator2.MoveNext())
         {
             SvgElement element1 = (SvgElement)enumerator2.Current;
             this.Insert(index, element1);
         }
     }
 }
Exemple #5
0
 public static IEnumerable <PathWithStyle> ExtractPaths(ClipPath clipPath)
 {
     return(ExtractPaths(clipPath, StyleHelper.InitialStyles));
 }
Exemple #6
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;
                }
            }
        }
Exemple #7
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;
                }
            }
        }
 public ClipPathCanvasCommand(ClipPath clipPath, ClipOperation operation, bool antialias)
 {
     ClipPath  = clipPath;
     Operation = operation;
     Antialias = antialias;
 }
 public static AM.Geometry?ToGeometry(this ClipPath clipPath, bool isFilled)
 {
     return(null); // TODO:
 }
Exemple #10
0
        internal ClipPath ComputeClipPath(PathUtil.PathType type)
        {
            lock (this)
            {
                if (clipPathsCache[(int)type] == null)
                    clipPathsCache[(int)type] = new ClipPath(this, type);
            }

            return clipPathsCache[(int)type];
        }
        public override Widget build(BuildContext context)
        {
            Widget current = child;

            if (child == null && (constraints == null || !constraints.isTight))
            {
                current = new LimitedBox(
                    maxWidth: 0.0f,
                    maxHeight: 0.0f,
                    child: new ConstrainedBox(constraints: BoxConstraints.expand())
                    );
            }

            if (alignment != null)
            {
                current = new Align(alignment: alignment, child: current);
            }

            EdgeInsetsGeometry effetivePadding = _paddingIncludingDecoration;

            if (effetivePadding != null)
            {
                current = new Padding(padding: effetivePadding, child: current);
            }

            if (color != null)
            {
                current = new ColoredBox(color: color, child: current);
            }

            if (decoration != null)
            {
                current = new DecoratedBox(decoration: decoration, child: current);
            }

            if (foregroundDecoration != null)
            {
                current = new DecoratedBox(
                    decoration: foregroundDecoration,
                    position: DecorationPosition.foreground,
                    child: current
                    );
            }

            if (constraints != null)
            {
                current = new ConstrainedBox(constraints: constraints, child: current);
            }

            if (margin != null)
            {
                current = new Padding(padding: margin, child: current);
            }

            if (transform != null)
            {
                current = new Transform(transform: new Matrix4(transform), child: current);
            }

            if (clipBehavior != Clip.none)
            {
                current = new ClipPath(
                    clipper: new _DecorationClipper(
                        textDirection: Directionality.of(context),
                        decoration: decoration
                        ),
                    clipBehavior: clipBehavior,
                    child: current
                    );
            }

            return(current);
        }