Exemplo n.º 1
0
        public void ReadFrom(Stream stream)
        {
            byte[] numArray1 = new byte["PIAFILEVERSION_2.0,CTBVER1,compress\r\npmzlibcodec".Length];
            if (stream.Read(numArray1, 0, numArray1.Length) != numArray1.Length)
            {
                throw new IOException("CTB file format error: Wrong header!");
            }
            if ("PIAFILEVERSION_2.0,CTBVER1,compress\r\npmzlibcodec" != Encodings.Ascii.GetString(numArray1, 0, numArray1.Length))
            {
                throw new IOException("CTB file format error: Wrong header!");
            }
            int  num1 = (int)CtbFile.smethod_8(stream);
            uint num2 = CtbFile.smethod_8(stream);

            byte[] numArray2 = new byte[(IntPtr)CtbFile.smethod_8(stream)];
            if (numArray2.Length != stream.Read(numArray2, 0, numArray2.Length))
            {
                throw new IOException("CTB file format error: Compressed content is too short!");
            }
            byte[] numArray3 = new byte[(IntPtr)num2];
            using (ZlibDecompressStream decompressStream = new ZlibDecompressStream((Stream) new MemoryStream(numArray2)))
            {
                if (numArray3.Length != decompressStream.Read(numArray3, 0, numArray3.Length))
                {
                    throw new IOException("CTB file format error: Expanded content is too short!");
                }
            }
            int num3 = (int)CtbFile.smethod_0(numArray2, 0, numArray2.Length);

            this.method_0(Encodings.Ascii.GetString(numArray3, 0, numArray3.Length));
        }
Exemplo n.º 2
0
 internal ColorEntry(CtbFile parent, int index)
 {
     this.ctbFile_0 = parent;
     this.string_2  = "Color_" + (object)index;
     this.string_3  = this.string_2;
     this.string_4  = "Description_" + (object)index;
     this.int_0     = index;
 }
Exemplo n.º 3
0
 private static void smethod_2(string[] lines, ref int l)
 {
     CtbFile.Interface45 token;
     do
     {
         ;
     }while ((token = CtbFile.smethod_5(lines, ref l)).Type == CtbFile.Enum43.const_0);
     CtbFile.smethod_4(token, l);
 }
Exemplo n.º 4
0
 private void method_3(string[] lines, ref int l)
 {
     CtbFile.Interface45 token;
     while ((token = CtbFile.smethod_5(lines, ref l)).Type == CtbFile.Enum43.const_0)
     {
         CtbFile.smethod_3(this.list_1.Count, token.Key, l);
         this.list_1.Add(token.imethod_1(l));
     }
     CtbFile.smethod_4(token, l);
 }
Exemplo n.º 5
0
 private void method_2(string[] lines, ref int l)
 {
     CtbFile.Interface45 token;
     while ((token = CtbFile.smethod_5(lines, ref l)).Type == CtbFile.Enum43.const_1)
     {
         CtbFile.smethod_3(this.list_0.Count, token.Key, l);
         CtbFile.ColorEntry colorEntry = new CtbFile.ColorEntry(this, l);
         colorEntry.method_0(lines, ref l);
         this.list_0.Add(colorEntry);
     }
     CtbFile.smethod_4(token, l);
 }
Exemplo n.º 6
0
        public void WriteTo(Stream stream)
        {
            byte[] bytes = Encodings.Ascii.GetBytes("PIAFILEVERSION_2.0,CTBVER1,compress\r\npmzlibcodec");
            stream.Write(bytes, 0, bytes.Length);
            MemoryStream memoryStream1 = new MemoryStream();

            this.method_1(new CtbFile.Class1003((Stream)memoryStream1));
            MemoryStream memoryStream2 = new MemoryStream((int)memoryStream1.Length);

            using (ZlibCompressStream zlibCompressStream = new ZlibCompressStream((Stream)memoryStream2, true))
            {
                memoryStream1.WriteTo((Stream)zlibCompressStream);
                zlibCompressStream.Flush();
            }
            uint num = CtbFile.smethod_0(memoryStream2.GetBuffer(), 0, (int)memoryStream2.Length);

            CtbFile.smethod_7(stream, num);
            CtbFile.smethod_7(stream, (uint)memoryStream1.Length);
            CtbFile.smethod_7(stream, (uint)memoryStream2.Length);
            memoryStream2.WriteTo(stream);
        }
Exemplo n.º 7
0
            internal void method_0(string[] lines, ref int l)
            {
                CtbFile.Interface45 token;
                while ((token = CtbFile.smethod_5(lines, ref l)).Type == CtbFile.Enum43.const_0)
                {
                    switch (token.Key)
                    {
                    case "name":
                        this.string_2 = token.imethod_0(l);
                        continue;

                    case "localized_name":
                        this.string_3 = token.imethod_0(l);
                        continue;

                    case "description":
                        this.string_4 = token.imethod_0(l);
                        continue;

                    case "color":
                        this.struct15_0 = new CtbFile.Struct15((uint)token.imethod_2(l));
                        continue;

                    case "mode_color":
                        this.struct15_1 = new CtbFile.Struct15((uint)token.imethod_2(l));
                        continue;

                    case "color_policy":
                        this.colorPolicy_0 = (CtbFile.ColorPolicy)token.imethod_2(l);
                        continue;

                    case "physical_pen_number":
                        this.int_1 = token.imethod_2(l);
                        continue;

                    case "virtual_pen_number":
                        this.int_2 = token.imethod_2(l);
                        continue;

                    case "screen":
                        this.int_3 = token.imethod_2(l);
                        continue;

                    case "linepattern_size":
                        this.double_0 = token.imethod_1(l);
                        continue;

                    case "linetype":
                        this.simpleLineType_0 = (CtbFile.SimpleLineType)token.imethod_2(l);
                        continue;

                    case "adaptive_linetype":
                        this.bool_0 = token.imethod_3(1);
                        continue;

                    case "lineweight":
                        this.int_4 = token.imethod_2(l);
                        continue;

                    case "fill_style":
                        this.fillStyle_0 = (FillStyle)token.imethod_2(l);
                        continue;

                    case "end_style":
                        this.lineCapStyle_0 = (CtbFile.LineCapStyle)token.imethod_2(l);
                        continue;

                    case "join_style":
                        this.lineJoinStyle_0 = (CtbFile.LineJoinStyle)token.imethod_2(l);
                        continue;

                    default:
                        throw new IOException("CTB file format error: Unknown value key " + token.Key + " [line " + (object)l + "]");
                    }
                }
                CtbFile.smethod_4(token, l);
            }
Exemplo n.º 8
0
 private static uint smethod_8(Stream stream)
 {
     return((uint)((int)CtbFile.smethod_9(stream) | (int)CtbFile.smethod_9(stream) << 8 | (int)CtbFile.smethod_9(stream) << 16 | (int)CtbFile.smethod_9(stream) << 24));
 }
Exemplo n.º 9
0
        private static CtbFile.Interface45 smethod_5(string[] lines, ref int l)
        {
            string str     = lines[l++].TrimStart();
            int    length1 = CtbFile.smethod_6((IEnumerable <char>)str, l);

            switch (str[length1])
            {
            case '{':
                return((CtbFile.Interface45) new CtbFile.Class1009(str.Substring(0, length1)));

            case '}':
                return((CtbFile.Interface45) new CtbFile.Class1010());

            default:
                string key = str.Substring(0, length1);
                string s1  = str.Substring(length1 + 1);
                if (s1[0] == '"')
                {
                    return((CtbFile.Interface45) new CtbFile.Class1005(key, s1.Substring(1)));
                }
                if ("TRUE".Equals(s1, StringComparison.InvariantCultureIgnoreCase))
                {
                    return((CtbFile.Interface45) new CtbFile.Class1006(key, true));
                }
                if ("FALSE".Equals(s1, StringComparison.InvariantCultureIgnoreCase))
                {
                    return((CtbFile.Interface45) new CtbFile.Class1006(key, false));
                }
                if (s1.Contains("."))
                {
                    int length2;
                    for (length2 = 0; length2 < s1.Length; ++length2)
                    {
                        char c = s1[length2];
                        if (char.IsDigit(c) || c == '.')
                        {
                            ++length2;
                            break;
                        }
                    }
                    for (; length2 < s1.Length; ++length2)
                    {
                        char c = s1[length2];
                        if (!char.IsDigit(c) && c != '.')
                        {
                            break;
                        }
                    }
                    string s2 = s1;
                    if (length2 < s1.Length)
                    {
                        s2 = s1.Substring(0, length2);
                    }
                    return((CtbFile.Interface45) new CtbFile.Class1008(key, double.Parse(s2, NumberStyles.Float, (IFormatProvider)CultureInfo.InvariantCulture.NumberFormat)));
                }
                int length3;
                for (length3 = 0; length3 < s1.Length; ++length3)
                {
                    if (char.IsDigit(s1[length3]))
                    {
                        ++length3;
                        break;
                    }
                }
                while (length3 < s1.Length && char.IsDigit(s1[length3]))
                {
                    ++length3;
                }
                if (length3 < s1.Length)
                {
                    s1.Substring(0, length3);
                }
                return((CtbFile.Interface45) new CtbFile.Class1007(key, int.Parse(s1)));
            }
        }
Exemplo n.º 10
0
        private void method_0(string content)
        {
            this.list_0.Clear();
            this.list_1.Clear();
            string[] lines = content.Split(new string[2] {
                "\n", "\r\n"
            }, StringSplitOptions.RemoveEmptyEntries);
            int l = 0;

            while (l < lines.Length)
            {
                if (CtbFile.smethod_1(lines[l]))
                {
                    ++l;
                }
                else
                {
                    CtbFile.Interface45 nterface45 = CtbFile.smethod_5(lines, ref l);
                    switch (nterface45.Type)
                    {
                    case CtbFile.Enum43.const_0:
                        switch (nterface45.Key)
                        {
                        case "description":
                            this.string_24 = nterface45.imethod_0(l);
                            continue;

                        case "aci_table_available":
                            continue;

                        case "scale_factor":
                            this.double_1 = nterface45.imethod_1(l);
                            continue;

                        case "apply_factor":
                            this.bool_0 = nterface45.imethod_3(l);
                            continue;

                        case "custom_lineweight_display_units":
                            this.displayUnit_0 = (CtbFile.DisplayUnit)nterface45.imethod_2(l);
                            continue;

                        default:
                            throw new IOException("CTB file format error: Unknown global value " + nterface45.Key + " [line " + (object)l + "]");
                        }

                    case CtbFile.Enum43.const_1:
                        switch (nterface45.Key)
                        {
                        case "aci_table":
                            CtbFile.smethod_2(lines, ref l);
                            continue;

                        case "plot_style":
                            this.method_2(lines, ref l);
                            continue;

                        case "custom_lineweight_table":
                            this.method_3(lines, ref l);
                            continue;

                        default:
                            continue;
                        }

                    case CtbFile.Enum43.const_2:
                        throw new IOException("CTB file format error: Unexpected close [line " + (object)l + "]");

                    default:
                        continue;
                    }
                }
            }
        }