public void StringValueParserTests() { var actual = DxfReader.TransformControlCharacters("a^G^ ^^ b"); var expected = "a\x7^\x1E b"; Assert.Equal(expected, actual); }
internal void method_9(DxfReader r, string subclass) { while (!r.method_92(subclass)) { switch (r.CurrentGroup.Code) { case 140: this.Value = (double)r.CurrentGroup.Value; break; case 305: this.Name = (string)r.CurrentGroup.Value; break; case 306: this.Description = (string)r.CurrentGroup.Value; break; case 307: this.ValueSet = r.method_37((short)96, (short)141, (short)175, (short)307); break; } r.method_85(); } }
private void method_19(DxfReader r, Class259 objectBuilder, ReferenceType referenceType) { DxfTypedObjectReference typedObjectReference = new DxfTypedObjectReference(referenceType); this.list_0.Add(typedObjectReference); objectBuilder.ChildBuilders.Add((Interface10)typedObjectReference.method_0((ulong)r.CurrentGroup.Value)); }
/// <summary> /// Opens the datasource /// </summary> public virtual void Open(string path) { // Get a Connector. The connector returned is guaranteed to be connected and ready to go. // Pooling.Connector connector = Pooling.ConnectorPool.ConnectorPoolManager.RequestConnector(this,true); if (!File.Exists(path)) { //log.Error("Could not find " + path); return; } if (!_IsOpen || this.path != path) { try { this.path = path; //string wkt = SharpMap.Converters.WellKnownText.SpatialReference.SridToWkt(32750); //"PROJCS["WGS_1984_UTM_Zone_50S",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",10000000],UNIT["Meter",1]]"; _DxfFile = new DxfFileProvider.DxfReader(path); InitializeDxf(this.path); //Read feature _CoordinateSystem = CreateUtmProjection(50); _DxfFile.Read(); _FeatureTable = _DxfFile.FeatureTable; _IsOpen = true; } catch //(IOException e) { //log.Error(e.Message); _IsOpen = false; } } }
internal override void Read(DxfReader r, Class259 objectBuilder) { while (r.CurrentGroup.Code != 0) { if (r.CurrentGroup.Code != 100) { throw new DxfException("Expected subclass marker."); } switch ((string)r.CurrentGroup.Value) { case "AcDbGeoData": if (r.ModelBuilder.Version > DxfVersion.Dxf21) { this.method_12(r, objectBuilder); continue; } this.method_8(r, objectBuilder); continue; default: r.method_85(); continue; } } }
public DxfModel Read() { string extension = Path.GetExtension(this.string_0); if (string.Compare(extension, ".dwg", StringComparison.InvariantCultureIgnoreCase) == 0) { using (DwgReader dwgReader = new DwgReader(this.string_0) { LoadUnknownObjects = this.bool_0 }) return(dwgReader.Read()); } else if (string.Compare(extension, ".dxf", StringComparison.InvariantCultureIgnoreCase) == 0) { using (DxfReader dxfReader = new DxfReader(this.string_0) { LoadUnknownObjects = this.bool_0 }) return(dxfReader.Read()); } else { if (string.Compare(extension, ".zip", StringComparison.InvariantCultureIgnoreCase) != 0 && string.Compare(extension, ".gz", StringComparison.InvariantCultureIgnoreCase) != 0 && string.Compare(extension, ".bz2", StringComparison.InvariantCultureIgnoreCase) != 0) { throw new ArgumentException("Unknown extension " + extension + ", it must be either .dxf or .dwg."); } using (DxfReader dxfReader = new DxfReader(this.string_0) { LoadUnknownObjects = this.bool_0 }) return(dxfReader.Read()); } }
internal override void Read(DxfReader r, Class259 objectBuilder) { base.Read(r, objectBuilder); while (!r.method_92("AcDbDiametricDimensionObjectContextData")) { switch (r.CurrentGroup.Code) { case 11: this.point3D_0.X = (double)r.CurrentGroup.Value; break; case 12: this.point3D_1.X = (double)r.CurrentGroup.Value; break; case 21: this.point3D_0.Y = (double)r.CurrentGroup.Value; break; case 22: this.point3D_1.Y = (double)r.CurrentGroup.Value; break; case 31: this.point3D_0.Z = (double)r.CurrentGroup.Value; break; case 32: this.point3D_1.Z = (double)r.CurrentGroup.Value; break; } r.method_85(); } }
/// <summary> /// Loads a dxf file. /// </summary> /// <param name="stream">Stream.</param> /// <returns>Returns a DxfDocument. It will return null if the file has not been able to load.</returns> /// <remarks> /// Loading dxf files prior to AutoCad 2000 is not supported.<br /> /// On Debug mode it will raise any exception that might occur during the whole process.<br /> /// The caller will be responsible of closing the stream. /// </remarks> public static DxfDocument Load(Stream stream) { // In dxf files the decimal point is always a dot. We have to make sure that this doesn't interfere with the system configuration. CultureInfo cultureInfo = CultureInfo.CurrentCulture; Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; DxfReader dxfReader = new DxfReader(); #if DEBUG DxfDocument document = dxfReader.Read(stream); Thread.CurrentThread.CurrentCulture = cultureInfo; #else DxfDocument document; try { document = dxfReader.Read(stream); } catch { return(null); } finally { Thread.CurrentThread.CurrentCulture = cultureInfo; } #endif return(document); }
public void Read(DxfReader r) { if (r.CurrentGroup.Code != 0) { throw new Exception("Unexpected group code " + (object)r.CurrentGroup.Code + "."); } if (r.CurrentGroup.Value as string != "ACDSRECORD") { throw new Exception("Unexpected group value " + r.CurrentGroup.Value + "."); } r.method_85(); while (r.CurrentGroup.Code != 0 && (r.CurrentGroup.Code != 101 && r.CurrentGroup != Struct18.struct18_0)) { switch (r.CurrentGroup.Code) { case 2: Class496 class496 = new Class496(); class496.Read(r); this.list_0.Add(class496); continue; case 90: this.uint_0 = (uint)(int)r.CurrentGroup.Value; r.method_85(); continue; default: r.method_85(); continue; } } }
private void method_7(DxfReader r, Class259 objectBuilder) { string key = (string)r.CurrentGroup.Value; DxfExtendedData dxfExtendedData; if (objectBuilder.AppIdToExtendedData.TryGetValue(key, out dxfExtendedData)) { dxfExtendedData.Values.AddRange((IEnumerable <IExtendedDataValue>)DxfExtendedData.ValueCollection.Read(objectBuilder, r)); } else { DxfAppId appId; bool flag = r.Model.AppIds.TryGetValue(key, out appId); DxfExtendedData extendedData = new DxfExtendedData(appId, DxfExtendedData.ValueCollection.Read(objectBuilder, r)); objectBuilder.AppIdToExtendedData.Add(key, extendedData); if (!flag) { objectBuilder.ChildBuilders.Add((Interface10) new Class333(this.ExtendedDataCollection, extendedData) { AppIdName = key }); } this.ExtendedDataCollection.Add(extendedData); } }
static void ReadDxf() { string file = Path.Combine(PathSamples, "bin.dxf"); DxfReader reader = new DxfReader(file, onNotification); reader.Read(); }
protected virtual bool vmethod_0(DxfReader r) { Struct18 currentGroup = r.CurrentGroup; bool flag = true; switch (currentGroup.Code) { case 2: this.string_0 = (string)currentGroup.Value; break; case 280: this.enum26_0 = (Enum26)currentGroup.Value; break; default: flag = false; break; } if (flag) { r.method_85(); } return(flag); }
/// <summary> /// Checks the AutoCAD dxf file database version. /// </summary> /// <param name="file">File name.</param> /// <param name="isBinary">Returns true if the dxf is a binary file.</param> /// <returns>String that represents the dxf file version.</returns> public static DxfVersion CheckDxfFileVersion(string file, out bool isBinary) { Stream stream = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); string value; isBinary = false; try { value = DxfReader.CheckHeaderVariable(stream, HeaderVariableCode.AcadVer, out isBinary); } catch { return(DxfVersion.Unknown); } finally { stream.Close(); } if (string.IsNullOrEmpty(value)) { return(DxfVersion.Unknown); } return((DxfVersion)StringEnum.Parse(typeof(DxfVersion), value)); }
private bool method_10(DxfReader r, Class259 objectBuilder) { switch (r.CurrentGroup.Code) { case 70: this.ImageDisplayFrameFlag = (ImageDisplayFrameFlag)r.CurrentGroup.Value; break; case 71: this.ImageDisplayQuality = (ImageDisplayQuality)r.CurrentGroup.Value; break; case 72: this.ImageInsertionUnits = (ImageInsertionUnits)r.CurrentGroup.Value; break; case 90: this.int_0 = (int)r.CurrentGroup.Value; break; default: return(this.method_6(r, objectBuilder)); } r.method_85(); return(true); }
private bool method_9(DxfReader r, Class259 objectBuilder) { switch (r.CurrentGroup.Code) { case 70: r.method_85(); return(true); case 140: this.double_0 = (double)r.CurrentGroup.Value; goto case 70; case 141: this.double_1 = (double)r.CurrentGroup.Value; goto case 70; case 290: this.bool_1 = (bool)r.CurrentGroup.Value; goto case 70; case 300: this.Name = (string)r.CurrentGroup.Value; if (this.string_0 == "") { throw new DxfException("Invalid scale name"); } goto case 70; default: return(this.method_6(r, objectBuilder)); } }
private void method_16( DxfReader r, Class285 objectBuilder, ref Interface30 binaryDataReader, ref Interface30 stringDataReader, ref long graphicsDataSizeInBytes, ref PagedMemoryStream graphicsData, ref Stream currentStream) { string subclass = (string)r.CurrentGroup.Value; r.method_85(); this.stream_0 = (Stream)null; this.stream_1 = (Stream)null; while (!r.method_92(subclass)) { if (!this.method_17(r, objectBuilder, ref graphicsDataSizeInBytes, ref graphicsData, ref currentStream)) { r.method_85(); } } if (this.stream_0 != null) { this.stream_0.Position = 0L; binaryDataReader = Class444.Create(r.ModelBuilder.Version, this.stream_0); } if (this.stream_1 == null) { return; } this.stream_1.Position = 0L; stringDataReader = Class444.Create(r.ModelBuilder.Version, this.stream_1); }
internal override void Read(DxfReader r, Class259 objectBuilder) { base.Read(r, objectBuilder); if (r.CurrentGroup.Code != 100 || (string)r.CurrentGroup.Value != "AcDbObjectContextData") { throw new DxfException("Expected subclass marker."); } r.method_85(); while (!r.method_92("AcDbObjectContextData")) { switch (r.CurrentGroup.Code) { case 70: this.Version = (short)r.CurrentGroup.Value; break; case 290: this.IsDefault = (bool)r.CurrentGroup.Value; break; default: throw new DxfException("Unexpected group code."); } r.method_85(); } }
//控制平台Form装载函数 private void MotionControlPlatform_Load(object sender, EventArgs e) { //串口参数初始化 Usart.BaudRate = 115200; Usart.DataBits = 8; Usart.StopBits = System.IO.Ports.StopBits.One; Usart.Parity = System.IO.Ports.Parity.None; Usart.ReadBufferSize = 4096; KeyPointNumLabel.Text = ""; NoticeInformation.Text = ""; //初始化背景 string filename = Directory.GetCurrentDirectory() + "\\blank.dwg"; DxfModel model; string extension = Path.GetExtension(filename); if (string.Compare(extension, ".dwg", true) == 0) { model = DwgReader.Read(filename); } else { model = DxfReader.Read(filename); } viewControl.Model = model; }
static void ReadDxf() { string file = Path.Combine(PathSamples, "dxf/ascii.dxf"); DxfReader reader = new DxfReader(file); reader.Read(); }
public void openFile(string filename) { modelTransform = Matrix4D.Identity; from2DTransform = gdiGraphics3D.To2DTransform.GetInverse(); translation = Vector3D.Zero; mouseDown = false; shiftPressed = false; lastMouseLocation.X = (int)0.5d * ClientSize.Width; lastMouseLocation.Y = (int)0.5d * ClientSize.Height; mouseClickLocation = lastMouseLocation; scaleFactor = 1d; if (filename == "" || filename == null) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "AutoCad files (*.dwg, *.dxf)|*.dxf;*.dwg"; if (dialog.ShowDialog() == DialogResult.OK) { filename = dialog.FileName; } } if (!string.IsNullOrEmpty(filename)) { // To prevent flicker. SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.UserPaint, true); ImageControl.BackColor = System.Drawing.Color.Black; try { string extension = Path.GetExtension(filename); if (string.Compare(extension, ".dwg", true) == 0) { model = DwgReader.Read(filename); } else { model = DxfReader.Read(filename); } this.Text = filename; gdiGraphics3D.CreateDrawables(model); bounds = new Bounds3D(); gdiGraphics3D.BoundingBox(bounds, modelTransform); CalculateTo2DTransform(); ImageControl.Invalidate(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public Struct18 imethod_0(DxfReader dxfReader) { if (this.int_0 < this.list_0.Count) { return(this.list_0[this.int_0++]); } return(this.struct18_0); }
public Struct18 imethod_1(DxfReader dxfReader, int baseGroupCode) { if (this.int_0 < this.list_0.Count) { return(this.list_0[this.int_0++]); } return(this.struct18_0); }
internal virtual void vmethod_11(DxfReader r, Class259 objectBuilder) { while (!r.method_92("AcDbTextObjectContextData")) { this.method_8(r.CurrentGroup); r.method_85(); } }
internal void Read(DxfReader r, int lineCount) { for (uint index = 0; (long)index < (long)lineCount; ++index) { DxfPattern.Line line = new DxfPattern.Line(); line.Read(r); this.Lines.Add(line); } }
private void method_10(DxfReader r, Class259 objectBuilder) { while (!r.method_92("AcDbGeoData") && r.CurrentGroup.Code != 4) { if (!this.method_11(r, objectBuilder)) { r.method_85(); } } }
private bool method_9(DxfReader r, Class259 objectBuilder) { if (r.CurrentGroup.Code != 70) { return(this.method_6(r, objectBuilder)); } this.short_0 = (short)r.CurrentGroup.Value; r.method_85(); return(true); }
internal void Read(DxfReader r) { bool flag1 = false; bool flag2 = true; do { switch (r.CurrentGroup.Code) { case 43: this.point2D_0.X = (double)r.CurrentGroup.Value; goto case 79; case 44: this.point2D_0.Y = (double)r.CurrentGroup.Value; goto case 79; case 45: this.vector2D_0.X = (double)r.CurrentGroup.Value; goto case 79; case 46: this.vector2D_0.Y = (double)r.CurrentGroup.Value; goto case 79; case 49: this.DashLengths.Add((double)r.CurrentGroup.Value); goto case 79; case 53: if (flag1) { flag2 = false; goto case 79; } else { this.double_0 = (double)r.CurrentGroup.Value * (System.Math.PI / 180.0); flag1 = true; goto case 79; } case 79: if (flag2) { r.method_85(); } continue; default: flag2 = false; goto case 79; } }while (flag2); }
internal override void Read(DxfReader r, Class259 objectBuilder) { base.Read(r, objectBuilder); while (!r.method_92("AcDbBlockAngularConstraintParameter")) { switch (r.CurrentGroup.Code) { case 140: this.Value = (double)r.CurrentGroup.Value; break; case 290: this.Unknown1 = (bool)r.CurrentGroup.Value; break; case 305: this.Name = (string)r.CurrentGroup.Value; break; case 306: this.Description = (string)r.CurrentGroup.Value; break; case 307: this.ValueSet = r.method_37((short)96, (short)141, (short)175, (short)307); break; case 1011: this.point3D_2.X = (double)r.CurrentGroup.Value; break; case 1012: this.point3D_3.X = (double)r.CurrentGroup.Value; break; case 1021: this.point3D_2.Y = (double)r.CurrentGroup.Value; break; case 1022: this.point3D_3.Y = (double)r.CurrentGroup.Value; break; case 1031: this.point3D_2.Z = (double)r.CurrentGroup.Value; break; case 1032: this.point3D_3.Z = (double)r.CurrentGroup.Value; break; } r.method_85(); } }
internal override void Read(DxfReader r, Class259 objectBuilder) { r.method_67((Class265)objectBuilder, false); r.method_85(); if (r.CurrentGroup.Code != 330) { throw new DxfException("Expected GC 330 here."); } ((Class266)objectBuilder).Dependency = (ulong)r.CurrentGroup.Value; r.method_85(); }
internal void method_5(DxfReader r, Class259 objectBuilder) { r.method_85(); while (r.CurrentGroup.Code != 0 && r.CurrentGroup.Code != 100) { if (!this.method_6(r, objectBuilder)) { r.method_85(); } } }
/// <summary> /// Loads a dxf file. /// </summary> /// <param name="file">File name.</param> /// <returns>Returns a DxfDocument. It will return null if the file has not been able to load.</returns> /// <exception cref="FileNotFoundException"></exception> /// <exception cref="IOException"></exception> /// <remarks> /// Loading dxf files prior to AutoCad 2000 is not supported.<br /> /// The Load method will still raise an exception if they are unable to create the FileStream.<br /> /// On Debug mode it will raise any exception that might occur during the whole process. /// </remarks> public static DxfDocument Load(string file) { FileInfo fileInfo = new FileInfo(file); if (!fileInfo.Exists) throw new FileNotFoundException(string.Format("File {0} not found.", fileInfo.FullName), fileInfo.FullName); Stream stream; try { stream = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); } catch (Exception ex) { throw new IOException(string.Format("Error trying to open the file {0} for reading.", fileInfo.FullName), ex); } DxfReader dxfReader = new DxfReader(); #if DEBUG DxfDocument document = dxfReader.Read(stream); stream.Close(); #else DxfDocument document; try { document = dxfReader.Read(stream); } catch { return null; } finally { stream.Close(); } #endif document.name = Path.GetFileNameWithoutExtension(fileInfo.FullName); return document; }
/// <summary> /// Loads a dxf file. /// </summary> /// <param name="stream">Stream.</param> /// <returns>Returns a DxfDocument. It will return null if the file has not been able to load.</returns> /// <remarks> /// Loading dxf files prior to AutoCad 2000 is not supported.<br /> /// On Debug mode it will raise any exception that might occur during the whole process.<br /> /// The caller will be responsible of closing the stream. /// </remarks> public static DxfDocument Load(Stream stream) { DxfReader dxfReader = new DxfReader(); #if DEBUG DxfDocument document = dxfReader.Read(stream); #else DxfDocument document; try { document = dxfReader.Read(stream); } catch { return null; } #endif return document; }