private DxfReader(DxfReader reader) { this.Code = reader.Code; this.Value = reader.Value; this.Counter = reader.Counter; this.streamReader = reader.streamReader; }
public static Dictionary <string, double> Parser(DxfReader tempReader, Dictionary <string, double> figureDictionary, out bool error) { error = false; do { tempReader.GetLineCouple(); if (!string.IsNullOrEmpty(tempReader.Value) || !string.IsNullOrEmpty(tempReader.Code)) { if (figureDictionary.ContainsKey(tempReader.Code)) { try { figureDictionary[tempReader.Code] = Double.Parse(tempReader.Value, System.Globalization.CultureInfo.InvariantCulture); // добавить форматирование } catch (Exception) { error = true; } } } } while (!(string.IsNullOrEmpty(tempReader.Value) && string.IsNullOrEmpty(tempReader.Code)) && !tempReader.Code.Equals("0")); return(figureDictionary); }
public override long ParseFigure(DxfReader reader) { bool error = false; Console.WriteLine("Parsing POINT..."); DxfReader tempReader = DxfReader.Clone(reader); Dictionary <string, double> pointDictionary = new Dictionary <string, double>() { { "10", 0 }, // x1 { "20", 0 }, // y1 }; pointDictionary = Figure.Parser(tempReader, pointDictionary, out error); Point.Create(pointDictionary["10"], pointDictionary["20"], error); return(tempReader.Counter - 2); // тут seek лучше прикрутить }
public override long ParseFigure(DxfReader reader) { Console.WriteLine("Parsing CIRCLE..."); bool error; DxfReader tempReader = DxfReader.Clone(reader); Dictionary <string, double> circleDictionary = new Dictionary <string, double>() { { "10", 0 }, // xCenter { "20", 0 }, // yCenter { "40", 0 } // radius }; circleDictionary = Figure.Parser(tempReader, circleDictionary, out error); Circle.Create(circleDictionary["10"], circleDictionary["20"], circleDictionary["40"], error); return(tempReader.Counter - 2); // тут seek лучше прикрутить }
public override long ParseFigure(DxfReader reader) { Console.WriteLine("Parsing POLYLINE..."); bool error; DxfReader tempReader = DxfReader.Clone(reader); /* Dictionary<string, double> polyLineDictionary = new Dictionary<string, double>() * { * { "90", 0 } // points' number * // { "10", 0 }, // points' x * // { "20", 0 }, // point' y * }; * // создать указанное "90" точек и таскать перо между ними без подъема */ for (;;) { } return(tempReader.Counter - 2); }
public override long ParseFigure(DxfReader reader) { bool error = false; Console.WriteLine("Parsing LINE..."); DxfReader tempReader = DxfReader.Clone(reader); Dictionary <string, double> lineDictionary = new Dictionary <string, double>() { { "10", 0 }, // x1 { "11", 0 }, // x2 { "20", 0 }, // y1 { "21", 0 } // y2 }; lineDictionary = Figure.Parser(tempReader, lineDictionary, out error); Line.Create(lineDictionary["10"], lineDictionary["20"], lineDictionary["11"], lineDictionary["21"], error); return(tempReader.Counter - 2); // тут seek лучше прикрутить }
public override long ParseFigure(DxfReader reader) { Console.WriteLine("Parsing ARC..."); bool error; DxfReader tempReader = DxfReader.Clone(reader); Dictionary <string, double> arcDictionary = new Dictionary <string, double>() { { "10", 0 }, // xCenter { "20", 0 }, // yCenter { "40", 0 }, // radius { "50", 0 }, // angleStart { "51", 0 } // angleStop }; arcDictionary = Figure.Parser(tempReader, arcDictionary, out error); Arc.Create(arcDictionary["10"], arcDictionary["20"], arcDictionary["40"], arcDictionary["50"], arcDictionary["51"], error); return(tempReader.Counter - 2); // тут seek лучше прикрутить }
private void convertButton_Click(object sender, EventArgs e) { string filePath = ""; string outFilePath = ""; try { filePath = InputFilePathText.Text; outFilePath = OutputFilePathText.Text; } catch (Exception) { } DxfReader reader = DxfReader.Create(@filePath); if (reader == null) { MessageLabel.Text = "Invalid path"; return; } reader.ParseFigures(); Converter.Convert(Figure.GetAllFigures(), outFilePath); MessageLabel.Text = "Convert Done"; }
/// <summary> /// Calling IParse implemintation to create a figure /// </summary> /// <param name="parseType"></param> /// <param name="readerPosition"></param> public static long CallParser(IParse parseType, DxfReader reader) { return(parseType.ParseFigure(reader)); }
public static DxfReader Clone(DxfReader reader) { return(new DxfReader(reader)); }
public abstract long ParseFigure(DxfReader reader);