Beispiel #1
0
        public static int GetGDIStyle(Text text)
        {
            int    num1  = 0;
            string text1 = AttributeFunc.ParseAttribute("font-weight", text, false).ToString().Trim();

            if ((((text1 == "bold") || (text1 == "bolder")) || ((text1 == "600") || (text1 == "700"))) || ((text1 == "800") || (text1 == "900")))
            {
                num1 |= 1;
            }
            if (AttributeFunc.ParseAttribute("font-style", text, false).ToString().Trim() == "italic")
            {
                num1 |= 2;
            }
            string text2 = AttributeFunc.ParseAttribute("text-decoration", text, false).ToString().Trim();

            if (text2 == "line-through")
            {
                return(num1 | 8);
            }
            if (text2 == "underline")
            {
                num1 |= 4;
            }
            return(num1);
        }
Beispiel #2
0
        public static object ParseAttribute(string key, SvgElement node, bool isadd)
        {
            if (node == null)
            {
                return(null);
            }
            if (key == "href")
            {
                key = "xlink:href";
            }
            object obj1 = null;

            for (XmlNode node1 = node; node1 is SvgElement; node1 = node1.ParentNode)
            {
                obj1 = AttributeFunc.FindAttribute(key, (SvgElement)node1);
                if ((obj1 != null) && (obj1.ToString() != string.Empty))
                {
                    break;
                }
                if (((SvgElement)node1).UseElement != null)
                {
                    node1 = ((SvgElement)node1).UseElement;
                    continue;
                }
            }
            if (obj1 == null)
            {
                return(string.Empty);
            }
            return(obj1);
        }
Beispiel #3
0
        public static StringFormat GetGDIStringFormat(Text text)
        {
            StringFormat format1 = new StringFormat(StringFormat.GenericTypographic);

            format1.LineAlignment = StringAlignment.Near;
            bool flag1 = true;

            if (text is TSpan)
            {
                flag1 = text.doalign;
            }
            if (flag1)
            {
                string text1 = AttributeFunc.ParseAttribute("text-anchor", text, false).ToString().Trim();
                if (text1 == "middle")
                {
                    format1.Alignment = StringAlignment.Center;
                }
                if (text1 == "end")
                {
                    format1.Alignment = StringAlignment.Far;
                }
            }
            string text2 = AttributeFunc.ParseAttribute("direction", text, false).ToString().Trim();

            if (text2 == "rtl")
            {
                if (format1.Alignment == StringAlignment.Far)
                {
                    format1.Alignment = StringAlignment.Near;
                }
                else if (format1.Alignment == StringAlignment.Near)
                {
                    format1.Alignment = StringAlignment.Far;
                }
                format1.FormatFlags = StringFormatFlags.DirectionRightToLeft;
            }
            text2 = AttributeFunc.ParseAttribute("writing-mode", text, false).ToString().Trim();
            if (text2 == "tb")
            {
                format1.FormatFlags |= StringFormatFlags.DirectionVertical;
            }
            format1.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;
            return(format1);
        }
Beispiel #4
0
        public static ISvgBrush Parsing(string text, SvgDocument doc, IGraphPath path)
        {
            while (text.Trim().EndsWith(";"))
            {
                text = text.Substring(0, text.Length - 1);
            }
            if (text.Trim().StartsWith("url"))
            {
                int     num1  = text.Trim().IndexOf("#", 0, text.Trim().Length);
                int     num2  = text.Trim().IndexOf(")", 0, text.Trim().Length);
                string  text1 = text.Trim().Substring(num1 + 1, (num2 - num1) - 1);
                XmlNode node1 = NodeFunc.GetRefNode(text1, doc);
                if (node1 != null)
                {
                    if (node1.NodeType != XmlNodeType.Element)
                    {
                        return(null);
                    }
                    XmlElement element1 = (XmlElement)node1;
                    if (element1 != null)
                    {
                        return((ISvgBrush)element1);
                    }
                }
                return(null);
            }
            string text7 = "none";           // AttributeFunc.ParseAttribute("hatch-style",(SvgElement) path,false).ToString();

            if (((SvgElement)path).SvgAttributes.ContainsKey("hatch-style"))
            {
                text7 = ((SvgElement)path).SvgAttributes["hatch-style"].ToString();
            }
            if ((text7 != "") && (text7.ToLower() != "none") && (text != "none"))
            {
                Color color1 = ColorFunc.ParseColor(text);
                Color color2 = ColorFunc.ParseColor(AttributeFunc.ParseAttribute("hatch-color", (SvgElement)path, false).ToString());

                Struct.Pattern pattern = new ItopVector.Struct.Pattern(color1, (ItopVector.PatternType)Enum.Parse(typeof(ItopVector.PatternType), text7, false), color2);

                return(new RatHatchBrush(pattern));
            }

            return(new SolidColor(ColorFunc.ParseColor(text)));
        }
Beispiel #5
0
        public static object GetAnimateValue(SvgElement element, string attributename, DomType domtype, object orivalue)
        {
            PointF[]     tfArray6;
            PointF[]     tfArray7;
            PointF[]     tfArray8;
            int          num8;
            Matrix       matrix1 = new Matrix();
            string       text1   = string.Empty;
            GraphicsPath path1   = null;
            string       text2   = string.Empty;

            PointF[] tfArray1 = null;
            bool     flag1    = true;

            if (element.AnimateNameValues.ContainsKey(attributename))
            {
                AnimateInfo info1      = (AnimateInfo)element.AnimateNameValues[attributename];
                object[]    objArray1  = info1.AnimateValues;
                bool[]      flagArray1 = info1.ValueAdds;
                int         num1       = 0;
                if ((domtype == DomType.SvgString) || (domtype == DomType.SvgLink))
                {
                    for (int num2 = objArray1.Length - 1; num2 >= 0; num2--)
                    {
                        if ((objArray1[num2] is string) && (objArray1[num2].ToString() != string.Empty))
                        {
                            if (element is ItopVector.Core.Figure.Image)
                            {
                                ((ItopVector.Core.Figure.Image)element).RefImage = ImageFunc.GetImageForURL(objArray1[num2].ToString(), element);
                            }
                            return(objArray1[num2].ToString());
                        }
                    }
                    return(orivalue);
                }
                object[] objArray2 = objArray1;
                for (int num10 = 0; num10 < objArray2.Length; num10++)
                {
                    PointF[]     tfArray2;
                    float        single3;
                    GraphicsPath path2;
                    PointF[]     tfArray3;
                    PointF[]     tfArray4;
                    PointF[]     tfArray5;
                    object       obj1  = objArray2[num10];
                    bool         flag2 = flagArray1[num1];
                    switch (domtype)
                    {
                    case DomType.SvgMatrix:
                    {
                        Matrix matrix2 = new Matrix();
                        if ((obj1 != null) && (obj1.ToString() != string.Empty))
                        {
                            matrix2 = ((Matrix)obj1).Clone();
                        }
                        if (flag2)
                        {
                            matrix1.Multiply(matrix2);
                            goto Label_046F;
                        }
                        matrix1 = matrix2;
                        goto Label_046F;
                    }

                    case DomType.SvgNumber:
                    {
                        single3 = 0f;
                        if ((obj1 != null) && (obj1.ToString() != string.Empty))
                        {
                            single3 = (float)obj1;
                            if (!flag2 || (text1 == string.Empty))
                            {
                                goto Label_0246;
                            }
                            float single9 = float.Parse(text1) + single3;
                            text1 = single9.ToString();
                        }
                        goto Label_046F;
                    }

                    case DomType.SvgString:
                    {
                        goto Label_046F;
                    }

                    case DomType.SvgColor:
                    {
                        string text3 = string.Empty;
                        if ((obj1 != null) && (obj1.ToString() != string.Empty))
                        {
                            text3 = (string)obj1;
                        }
                        if (text3 != string.Empty)
                        {
                            if ((flag2 && (text2 != string.Empty)) && (!text2.Trim().StartsWith("url") && !text3.Trim().StartsWith("url")))
                            {
                                Color    color1     = ColorFunc.ParseColor(text3);
                                Color    color2     = ColorFunc.ParseColor(text2);
                                int      num4       = (color1.R + color2.R) / 2;
                                int      num5       = (color1.G + color2.G) / 2;
                                int      num6       = (color1.B + color2.B) / 2;
                                string[] textArray1 = new string[7] {
                                    "rgb(", num4.ToString(), ",", num5.ToString(), ",", num6.ToString(), ")"
                                };
                                text2 = string.Concat(textArray1);
                                goto Label_046F;
                            }
                            text2 = text3;
                        }
                        goto Label_046F;
                    }

                    case DomType.SvgPath:
                    {
                        if ((obj1 != null) && (obj1.ToString() != string.Empty))
                        {
                            path2 = (GraphicsPath)obj1;
                            if (!flag2 || (path1 == null))
                            {
                                goto Label_0460;
                            }
                            tfArray3 = path2.PathPoints;
                            tfArray4 = path1.PathPoints;
                            if (tfArray3.Length == tfArray4.Length)
                            {
                                goto Label_03B5;
                            }
                        }
                        goto Label_046F;
                    }

                    case DomType.SvgPoints:
                    {
                        tfArray2 = new PointF[0];
                        if (obj1 is PointF[])
                        {
                            tfArray2 = (PointF[])obj1;
                        }
                        if (!flag2)
                        {
                            break;
                        }
                        if (tfArray1.Length == tfArray2.Length)
                        {
                            for (int num3 = 0; num3 < tfArray2.Length; num3++)
                            {
                                PointF tf1     = tfArray1[num3];
                                PointF tf2     = tfArray2[num3];
                                float  single1 = (tf1.X + tf2.X) / 2f;
                                float  single2 = (tf1.Y + tf2.Y) / 2f;
                                tfArray1[num3] = new PointF(single1, single2);
                            }
                        }
                        goto Label_046F;
                    }

                    default:
                    {
                        goto Label_046F;
                    }
                    }
                    tfArray1 = (PointF[])tfArray2.Clone();
                    goto Label_046F;
Label_0246:
                    text1 = single3.ToString();
                    goto Label_046F;
Label_03B5:
                    tfArray5 = new PointF[tfArray4.Length];
                    Array.Copy(tfArray3, tfArray1, tfArray5.Length);
                    byte[] buffer1 = path2.PathTypes;
                    byte[] buffer2 = path1.PathTypes;
                    for (int num7 = 0; num7 < Math.Min(tfArray3.Length, tfArray4.Length); num7++)
                    {
                        PointF tf3     = tfArray3[num7];
                        PointF tf4     = tfArray4[num7];
                        float  single4 = tf3.X + tf4.X;
                        float  single5 = tf3.Y + tf4.Y;
                        tfArray5[num7] = new PointF(single4, single5);
                    }
                    path1 = new GraphicsPath(tfArray5, path2.PathTypes);
                    goto Label_046D;
Label_0460:
                    path1 = (GraphicsPath)path2.Clone();
                    Label_046D :;
                    Label_046F :;
                }
                if (flagArray1.Length > 0)
                {
                    flag1 = flagArray1[flagArray1.Length - 1];
                }
            }
            switch (domtype)
            {
            case DomType.SvgMatrix:
            {
                Matrix matrix3 = new Matrix();
                if (orivalue != null)
                {
                    matrix3 = ((Matrix)orivalue).Clone();
                }
                if (flag1)
                {
                    matrix3.Multiply(matrix1);
                }
                else
                {
                    matrix3 = matrix1.Clone();
                }
                return(matrix3.Clone());
            }

            case DomType.SvgNumber:
            {
                if ((flag1 && (orivalue != null)) && (orivalue.ToString() != string.Empty))
                {
                    float single6 = (float)orivalue;
                    if (text1 == string.Empty)
                    {
                        text1 = single6.ToString();
                        break;
                    }
                    float single10 = float.Parse(text1) + single6;
                    text1 = single10.ToString();
                }
                break;
            }

            case DomType.SvgString:
            {
                return(orivalue);
            }

            case DomType.SvgColor:
            {
                if (text2 == string.Empty)
                {
                    return(orivalue);
                }
                if ((flag1 && (orivalue != null)) && (!text2.Trim().StartsWith("url") && !((string)orivalue).Trim().StartsWith("url")))
                {
                    Color    color3     = ColorFunc.ParseColor((string)orivalue);
                    Color    color4     = ColorFunc.ParseColor(text2);
                    string[] textArray2 = new string[7];
                    textArray2[0] = "rgb(";
                    int num11 = (color3.R + color4.R) / 2;
                    textArray2[1] = num11.ToString();
                    textArray2[2] = ",";
                    int num12 = (color3.G + color4.G) / 2;
                    textArray2[3] = num12.ToString();
                    textArray2[4] = ",";
                    int num13 = (color3.B + color4.B) / 2;
                    textArray2[5] = num13.ToString();
                    textArray2[6] = ")";
                    text2         = string.Concat(textArray2);
                }
                return(text2);
            }

            case DomType.SvgPath:
            {
                if (path1 == null)
                {
                    return(orivalue);
                }
                if (!flag1 || (orivalue == null))
                {
                    return(path1);
                }
                tfArray6 = ((GraphicsPath)orivalue).PathPoints;
                tfArray7 = path1.PathPoints;
                tfArray8 = new PointF[tfArray6.Length];
                Array.Copy(tfArray6, tfArray1, tfArray8.Length);
                num8 = 0;
                goto Label_0738;
            }

            case DomType.SvgPoints:
            {
                if (tfArray1.Length > 0)
                {
                    PointF[] tfArray9 = new PointF[0];
                    if (!(orivalue is PointF[]) || !flag1)
                    {
                        return(tfArray1);
                    }
                    tfArray9 = (PointF[])orivalue;
                    if (tfArray9.Length != tfArray1.Length)
                    {
                        return(tfArray1);
                    }
                    for (int num9 = 0; num9 < tfArray1.Length; num9++)
                    {
                        tfArray1[num9] = new PointF((tfArray1[num9].X + tfArray9[num9].X) / 2f, (tfArray1[num9].Y + tfArray9[num9].Y) / 2f);
                    }
                }
                return(tfArray1);
            }

            default:
            {
                return(string.Empty);
            }
            }
            if (text1 != string.Empty)
            {
                return(float.Parse(text1));
            }
            if ((orivalue.ToString() == string.Empty) || (orivalue == null))
            {
                return((float)AttributeFunc.GetDefaultValue(element, attributename));
            }
            return((float)orivalue);

Label_0738:
            if (num8 >= Math.Min(tfArray6.Length, tfArray7.Length))
            {
                return(new GraphicsPath(tfArray8, path1.PathTypes));
            }
            PointF tf5     = tfArray6[num8];
            PointF tf6     = tfArray7[num8];
            float  single7 = tf5.X + tf6.X;
            float  single8 = tf5.Y + tf6.Y;

            tfArray8[num8] = new PointF(single7, single8);
            num8++;
            goto Label_0738;
        }