Ejemplo n.º 1
0
        public static void AddFontCharRemapper(string filename, CharRemapDelegate charRemapDelegate)
        {
            string key = ShxFile.smethod_4(filename);

            lock (ShxFile.dictionary_2)
                ShxFile.dictionary_2.Add(key, charRemapDelegate);
        }
Ejemplo n.º 2
0
        public override void DrawInternal(
            DrawContext.Surface context,
            ISurfaceGraphicsFactory graphicsFactory)
        {
            DxfTextStyle textStyle = this.TextStyle;

            if (textStyle == null)
            {
                return;
            }
            ShxFile shxFile = textStyle.GetShxFile();

            if (shxFile == null)
            {
                return;
            }
            ShxShape shapeByIndex = shxFile.GetShapeByIndex(this.ushort_0);

            if (shapeByIndex == null)
            {
                return;
            }
            WW.Math.Point2D endPoint;
            new Class473((DxfEntity)this, context, graphicsFactory).DrawPath(shapeByIndex.GetGlyphShape(false, out endPoint), this.Transform, this.Color.ToColor(), context.GetLineWeight((DxfEntity)this), false, false, this.double_1);
        }
Ejemplo n.º 3
0
        private ShxFile(string filename, byte[] data)
        {
            this.string_1     = filename;
            this.dictionary_3 = new Dictionary <ushort, ShxShape>();
            this.dictionary_4 = new Dictionary <char, ShxShape>();
            using (Stream input = data == null ? (Stream)File.OpenRead(filename) : (Stream) new MemoryStream(data))
            {
                using (this.binaryReader_0 = new BinaryReader(input))
                {
                    this.shxFormat_0 = this.method_9();
                    Class2 class2;
                    switch (this.shxFormat_0)
                    {
                    case ShxFormat.shx1_0:
                        CharRemapDelegate charRemapper1;
                        ShxFile.dictionary_2.TryGetValue(ShxFile.smethod_4(filename), out charRemapper1);
                        class2 = new Class2(this.binaryReader_0, ShxFile.smethod_1(filename, DrawingCodePage.Dos437), charRemapper1, this);
                        break;

                    case ShxFormat.shx1_1:
                        CharRemapDelegate charRemapper2;
                        ShxFile.dictionary_2.TryGetValue(ShxFile.smethod_4(filename), out charRemapper2);
                        class2 = new Class2(this.binaryReader_0, ShxFile.smethod_1(filename, DrawingCodePage.Ansi1252), charRemapper2, this);
                        break;

                    case ShxFormat.shxBigFont1_0:
                        this.encoding_0 = ShxFile.smethod_0(filename);
                        if (this.encoding_0 == null)
                        {
                            throw new ShxFile.ShxUnknownEncodingException("Encoding of bigfont SHX file " + filename + " is unknown!");
                        }
                        class2 = (Class2) new Class5(this.binaryReader_0, this.encoding_0, this);
                        break;

                    case ShxFormat.shxUnicode1_0:
                        class2 = (Class2) new Class3(this.binaryReader_0, Encoding.UTF8, this);
                        break;

                    default:
                        throw new InternalException("Unknown SHX file format!");
                    }
                    class2.Read();
                }
            }
            if (this.int_3 == 0)
            {
                this.int_3 = this.int_1 + this.int_0;
            }
            ShxShape shape = this.GetShape('\n');

            if (shape == null)
            {
                return;
            }
            WW.Math.Point2D endPoint;
            shape.GetGlyphShape(false, out endPoint);
            this.double_1 = endPoint.Y;
            shape.GetGlyphShape(true, out endPoint);
            this.double_0 = endPoint.X;
        }
Ejemplo n.º 4
0
        public static void AddOldShxEncoding(string filename, Encoding encoding)
        {
            string key = ShxFile.smethod_4(filename);

            lock (ShxFile.dictionary_1)
                ShxFile.dictionary_1.Add(key, encoding);
        }
Ejemplo n.º 5
0
        public override void DrawInternal(
            DrawContext.Surface context,
            Graphics graphics,
            IGraphicElementBlock parentGraphicElementBlock)
        {
            DxfTextStyle textStyle = this.TextStyle;

            if (textStyle == null)
            {
                return;
            }
            ShxFile shxFile = textStyle.GetShxFile();

            if (shxFile == null)
            {
                return;
            }
            ShxShape shapeByIndex = shxFile.GetShapeByIndex(this.ushort_0);

            if (shapeByIndex == null)
            {
                return;
            }
            ArgbColor plotColor = context.GetPlotColor((DxfEntity)this);

            if (!graphics.AddExistingGraphicElement1(parentGraphicElementBlock, (DxfEntity)this, plotColor))
            {
                return;
            }
            WW.Math.Point2D endPoint;
            new Class355((DxfEntity)this, context, graphics, parentGraphicElementBlock).DrawPath(shapeByIndex.GetGlyphShape(false, out endPoint), this.Transform, this.Color.ToColor(), context.GetLineWeight((DxfEntity)this), false, false, this.double_1);
        }
Ejemplo n.º 6
0
        public static void AddBigfontEncoding(string filename, Encoding encoding)
        {
            string key = ShxFile.smethod_4(filename);

            lock (ShxFile.dictionary_0)
                ShxFile.dictionary_0.Add(key, encoding);
        }
Ejemplo n.º 7
0
        public static ShxFile GetShxFile(string filename, string[] path)
        {
            string str = ShxFile.smethod_3(filename, path);

            if (string.IsNullOrEmpty(str))
            {
                if (!"LTYPESHP.SHX".Equals(filename, StringComparison.InvariantCultureIgnoreCase))
                {
                    return((ShxFile)null);
                }
                lock (ShxFile.byte_0)
                {
                    if (ShxFile.shxFile_0 == null)
                    {
                        ShxFile.shxFile_0 = new ShxFile("LTYPESHP.SHX", ShxFile.byte_0);
                    }
                }
                return(ShxFile.shxFile_0);
            }
            ShxFile shxFile;

            lock (ShxFile.dictionary_5)
            {
                if (!ShxFile.dictionary_5.TryGetValue(str, out shxFile))
                {
                    shxFile = new ShxFile(str);
                }
            }
            return(shxFile);
        }
Ejemplo n.º 8
0
 internal static bool smethod_2(string filename, string[] path)
 {
     if (!filename.Equals("LTYPESHP.SHX", StringComparison.InvariantCultureIgnoreCase))
     {
         return(ShxFile.Exists(filename, path));
     }
     return(true);
 }
Ejemplo n.º 9
0
        private static int smethod_7(ShxShape.Class466 plotter, byte[] geometry, int offset)
        {
            plotter.method_1();
            ShxFile shxFile = plotter.ShxFile;
            int     num1;

            if (shxFile.ShxFormat == ShxFormat.shxUnicode1_0)
            {
                char     ch           = Convert.ToChar(((int)geometry[offset + 1] << 8) + (int)geometry[offset + 2]);
                ShxShape shapeByIndex = shxFile.GetShapeByIndex((ushort)ch);
                if (shapeByIndex == null)
                {
                    throw new Exception("No shape found with id " + (object)ch + " in shx file " + shxFile.FileName + ".");
                }
                if (plotter.method_0())
                {
                    shapeByIndex.method_1(plotter);
                }
                num1 = 3;
            }
            else if (geometry[offset + 1] != (byte)0)
            {
                char     ch           = Convert.ToChar(geometry[offset + 1]);
                ShxShape shapeByIndex = shxFile.GetShapeByIndex((ushort)ch);
                if (shapeByIndex == null)
                {
                    throw new Exception("No shape found with id " + (object)ch + " in shx file " + shxFile.FileName + ".");
                }
                if (plotter.method_0())
                {
                    shapeByIndex.method_1(plotter);
                }
                num1 = 2;
            }
            else
            {
                ushort   index        = (ushort)((uint)geometry[offset + 2] << 8 | (uint)geometry[offset + 3]);
                ShxShape shapeByIndex = shxFile.GetShapeByIndex(index);
                if (shapeByIndex == null)
                {
                    throw new Exception("No shape found with id " + (object)index + " in shx file " + shxFile.FileName + ".");
                }
                if (plotter.method_0())
                {
                    ShxShape.Class466 class466       = shapeByIndex.method_0(false);
                    float             num2           = (float)geometry[offset + 4];
                    float             num3           = (float)geometry[offset + 5];
                    float             num4           = (float)geometry[offset + 6] / (float)shxFile.Width;
                    float             num5           = (float)geometry[offset + 7] / (float)shxFile.Height;
                    Matrix3D          transformation = new Matrix3D((double)num4, 0.0, (double)num2, 0.0, (double)num5, (double)num3, 0.0, 0.0, 1.0);
                    class466.Shape.TransformBy(transformation);
                    plotter.method_10((IShape2D)class466.Shape, false);
                }
                num1 = 8;
            }
            plotter.method_2();
            return(num1);
        }
Ejemplo n.º 10
0
        internal static Encoding smethod_0(string filename)
        {
            string   key = ShxFile.smethod_4(filename);
            Encoding encoding;

            lock (ShxFile.dictionary_0)
                ShxFile.dictionary_0.TryGetValue(key, out encoding);
            return(encoding);
        }
Ejemplo n.º 11
0
 internal Class466(ShxFile shxFile, bool vertical)
 {
     this.shxFile_0        = shxFile;
     this.bool_0           = vertical;
     this.stack_0          = new Stack <WW.Math.Point2D>();
     this.double_0         = 1.0;
     this.generalShape2D_0 = new GeneralShape2D();
     this.point2D_0        = WW.Math.Point2D.Zero;
     this.PenDown          = true;
 }
Ejemplo n.º 12
0
 public ShxShape(
     ShxFile shxFile,
     ushort index,
     char unicodeCharIndex,
     string description,
     byte[] geometry)
 {
     this.shxFile_0 = shxFile;
     this.ushort_0  = index;
     this.char_0    = unicodeCharIndex;
     this.string_0  = description;
     this.byte_0    = geometry;
 }
Ejemplo n.º 13
0
        internal static Encoding smethod_1(string filename, DrawingCodePage defaultCodepage)
        {
            string   key = ShxFile.smethod_4(filename);
            Encoding encoding;

            lock (ShxFile.dictionary_1)
            {
                if (!ShxFile.dictionary_1.TryGetValue(key, out encoding))
                {
                    encoding = Encodings.GetEncoding((int)defaultCodepage);
                }
            }
            return(encoding);
        }
Ejemplo n.º 14
0
        public DxfShape(DxfTextStyle textStyle, ushort shapeIndex, WW.Math.Point3D insertionPoint)
        {
            if (textStyle == null)
            {
                throw new ArgumentNullException(nameof(textStyle));
            }
            this.TextStyle = textStyle;
            this.ushort_0  = shapeIndex;
            this.point3D_0 = insertionPoint;
            ShxFile shxFile = textStyle.GetShxFile();

            if (shxFile == null)
            {
                throw new ArgumentException("Shx file with name " + textStyle.FontFilename + " not found.");
            }
            this.method_13(shxFile);
        }
Ejemplo n.º 15
0
 private void method_13(ShxFile shxFile)
 {
     if (shxFile != null)
     {
         ShxShape shapeByIndex = shxFile.GetShapeByIndex(this.ushort_0);
         if (shapeByIndex != null)
         {
             this.string_0 = shapeByIndex.Description;
         }
         else
         {
             this.string_0 = string.Empty;
         }
     }
     else
     {
         this.string_0 = string.Empty;
     }
 }
Ejemplo n.º 16
0
 static ShxFile()
 {
     try
     {
         ShxFile.AddBigfontEncoding("@EXTFONT2", Encodings.Dos932);
         ShxFile.AddBigfontEncoding("EXTFONT2", Encodings.Dos932);
         ShxFile.AddBigfontEncoding("BIGFONT", Encodings.Dos932);
         ShxFile.AddBigfontEncoding("EXTFONT", Encodings.Dos932);
     }
     catch (Exception ex)
     {
         Console.WriteLine((object)ex);
     }
     try
     {
         ShxFile.AddBigfontEncoding("CHINESET", Encodings.Ansi950);
     }
     catch (Exception ex)
     {
         Console.WriteLine((object)ex);
     }
     try
     {
         ShxFile.AddBigfontEncoding("GBCBIG", Encodings.Gb2312);
         ShxFile.AddBigfontEncoding("HZTXT", Encodings.Gb2312);
     }
     catch (Exception ex)
     {
         Console.WriteLine((object)ex);
     }
     try
     {
         ShxFile.AddBigfontEncoding("WHGDTXT", Encodings.Ksc5601);
         ShxFile.AddBigfontEncoding("WHGTXT", Encodings.Ksc5601);
         ShxFile.AddBigfontEncoding("WHTGTXT", Encodings.Ksc5601);
         ShxFile.AddBigfontEncoding("WHTMTXT", Encodings.Ksc5601);
     }
     catch (Exception ex)
     {
         Console.WriteLine((object)ex);
     }
     try
     {
         Encoding encoding = Encodings.GetEncoding(437);
         ShxFile.AddOldShxEncoding("COMPLEX", encoding);
         ShxFile.AddOldShxEncoding("COMPLEX8", encoding);
         ShxFile.AddOldShxEncoding("GOTHICE", encoding);
         ShxFile.AddOldShxEncoding("GOTHICG", encoding);
         ShxFile.AddOldShxEncoding("GOTHICI", encoding);
         ShxFile.AddOldShxEncoding("GREEKC", encoding);
         ShxFile.AddOldShxEncoding("GREEKS", encoding);
         ShxFile.AddOldShxEncoding("ISOCP", encoding);
         ShxFile.AddOldShxEncoding("ISOCP2", encoding);
         ShxFile.AddOldShxEncoding("ISOCP3", encoding);
         ShxFile.AddOldShxEncoding("ISOCT", encoding);
         ShxFile.AddOldShxEncoding("ISOCT2", encoding);
         ShxFile.AddOldShxEncoding("ISOCT3", encoding);
         ShxFile.AddOldShxEncoding("ITALIC", encoding);
         ShxFile.AddOldShxEncoding("ITALICC", encoding);
         ShxFile.AddOldShxEncoding("ITALICT", encoding);
         ShxFile.AddOldShxEncoding("MONOTXT", encoding);
         ShxFile.AddOldShxEncoding("ROMANC", encoding);
         ShxFile.AddOldShxEncoding("ROMAND", encoding);
         ShxFile.AddOldShxEncoding("ROMANS", encoding);
         ShxFile.AddOldShxEncoding("ROMANT", encoding);
         ShxFile.AddOldShxEncoding("SCRIPTC", encoding);
         ShxFile.AddOldShxEncoding("SCRIPTS", encoding);
         ShxFile.AddOldShxEncoding("SIMPLEX", encoding);
         ShxFile.AddOldShxEncoding("SIMPLEX8", encoding);
         ShxFile.AddOldShxEncoding("SYASTRO", encoding);
         ShxFile.AddOldShxEncoding("SYMAP", encoding);
         ShxFile.AddOldShxEncoding("SYMATH", encoding);
         ShxFile.AddOldShxEncoding("SYMETEO", encoding);
         ShxFile.AddOldShxEncoding("SYMUSIC", encoding);
         ShxFile.AddOldShxEncoding("TXT", encoding);
         ShxFile.AddOldShxEncoding("TXT8", encoding);
         ShxFile.AddOldShxEncoding("ATIR", Encodings.GetEncoding(862));
         ShxFile.AddFontCharRemapper("ATIR", new CharRemapDelegate(new FontCharRemapper(Encodings.GetEncoding(862), Encodings.GetEncoding(1255)).Remap));
         ShxFile.AddOldShxEncoding("HEBTXT", Encodings.GetEncoding(862));
         ShxFile.AddFontCharRemapper("HEBTXT", new CharRemapDelegate(new FontCharRemapper(Encodings.GetEncoding(862), Encodings.GetEncoding(1255)).Remap));
     }
     catch (Exception ex)
     {
         Console.WriteLine((object)ex);
     }
     try
     {
         ShxFile.AddOldShxEncoding("P131", Encodings.Ansi1251);
     }
     catch (Exception ex)
     {
         Console.WriteLine((object)ex);
     }
 }
Ejemplo n.º 17
0
 public static bool Exists(string filename, string[] path)
 {
     return(ShxFile.smethod_3(filename, path) != null);
 }