public virtual void ParseGroupCode(DXFDocument doc, int groupcode, string value) { switch (groupcode) { case 0: createRecord(doc); break; case 5: currentRecord.Handle = value; break; case 70: currentRecord.Flags = int.Parse(value); break; case 105: currentRecord.DimStyleHandle = value; break; case 100: currentRecord.Classhierarchy.Add(value); break; } }
public void ParseGroupCode(DXFDocument doc, int groupcode, string value) { switch (groupcode) { case 0: currentClass = new DXFClass(); doc.Classes.Add(currentClass); break; case 1: currentClass.DXFRecord = value; break; case 2: currentClass.ClassName = value; break; case 3: currentClass.AppName = value; break; case 90: currentClass.ClassProxyCapabilities = (DXFClass.Caps)Enum.Parse(typeof(DXFClass.Caps), value); break; case 280: if (int.Parse(value) != 0) currentClass.WasProxy = true; else currentClass.WasProxy = false; break; case 281: if (int.Parse(value) != 0) currentClass.IsEntity = true; else currentClass.IsEntity = false; break; } }
public override void ParseGroupCode(DXFDocument doc, int groupcode, string value) { base.ParseGroupCode(doc, groupcode, value); switch (groupcode) { case 2: _record.StyleName = value; break; case 40: _record.FixedHeight = double.Parse(value); break; case 41: _record.WidthFactor = double.Parse(value); break; case 50: _record.ObliqueAngle = double.Parse(value); break; case 71: _record.GenerationFlags = (DXFStyleRecord.TextGenerationFlags)Enum.Parse(typeof(DXFStyleRecord.TextGenerationFlags), value); break; case 42: _record.LastUsedHeight = double.Parse(value); break; case 3: _record.FontFileName = value; break; case 4: _record.BigFontFileName = value; break; } }
public void ParseGroupCode(DXFDocument doc, int groupcode, string value) { if (groupcode == 0) { if (current == null) { groups.Add(value + " OUTSIDE"); } else { groups.Add(value); } } if (current == null) { if (groupcode == 0 && value == "BLOCK") { current = new DXFBlock(); container = new DXFDocument(); parsingBlock = true; } } else { if (parsingBlock) { if (groupcode == 0 && value == "ENDBLK") { current.Children.AddRange(container.Entities); doc.Blocks.Add(current); current = null; container = null; } else if (groupcode == 0) { parsingBlock = false; parser.ParseGroupCode(container, groupcode, value); } else { current.ParseGroupCode(groupcode, value); } } else { if (groupcode == 0 && value == "ENDBLK") { current.Children.AddRange(container.Entities); doc.Blocks.Add(current); current = null; container = null; } else { parser.ParseGroupCode(container, groupcode, value); } } } }
public override void ParseGroupCode(DXFDocument doc, int groupcode, string value) { base.ParseGroupCode(doc, groupcode, value); if (groupcode == 2) { _currentRecord.BlockName = value; } }
public void ParseGroupCode(DXFDocument doc, int groupcode, string value) { if (Entities.Count == 0) { foreach (Type t in Assembly.GetCallingAssembly().GetTypes()) { if (t.IsClass && !t.IsAbstract) { object[] attrs = t.GetCustomAttributes(false); foreach (object attr in attrs) { EntityAttribute casted = attr as EntityAttribute; if (casted != null) { Entities.Add(casted.EntityName, t); } } } } } if (groupcode == 0) { if (value == "SEQEND") { if (stack.Count != 0) { currentEntity = stack.Pop(); } } if (Entities.ContainsKey(value)) { if (currentEntity != null && currentEntity.HasChildren) { stack.Push(currentEntity); } currentEntity = Activator.CreateInstance(Entities[value]) as DXFEntity; if (stack.Count > 0 && stack.Peek().HasChildren) { stack.Peek().Children.Add(currentEntity); } else { doc.Entities.Add(currentEntity); } } else { currentEntity = null; //TODO: warning } } if (currentEntity != null) { currentEntity.ParseGroupCode(groupcode, value); } }
public override void ParseGroupCode(DXFDocument doc, int groupcode, string value) { base.ParseGroupCode(doc, groupcode, value); switch (groupcode) { case 2: _currentRecord.ApplicationName = value; break; } }
public void ParseGroupCode(DXFDocument doc, int groupcode, string value) { if (Entities.Count == 0) { foreach (Type t in Assembly.GetCallingAssembly().GetTypes()) { if (t.IsClass && !t.IsAbstract) { object[] attrs = t.GetCustomAttributes(false); foreach(object attr in attrs) { EntityAttribute casted = attr as EntityAttribute; if (casted != null) { Entities.Add(casted.EntityName, t); } } } } } if (groupcode == 0) { if (value == "SEQEND") { if (stack.Count != 0) currentEntity = stack.Pop(); } if (Entities.ContainsKey(value)) { if (currentEntity!=null && currentEntity.HasChildren) { stack.Push(currentEntity); } currentEntity = Activator.CreateInstance(Entities[value]) as DXFEntity; if (stack.Count>0 && stack.Peek().HasChildren) { stack.Peek().Children.Add(currentEntity); } else { doc.Entities.Add(currentEntity); } } else { currentEntity = null; //TODO: warning } } if (currentEntity != null) { currentEntity.ParseGroupCode(groupcode, value); } }
public void ParseGroupCode(DXFDocument doc, int groupcode, string value) { if (groupcode == 0) { if (current == null) groups.Add(value + " OUTSIDE"); else groups.Add(value); } if (current == null) { if (groupcode == 0 && value == "BLOCK") { current = new DXFBlock(); container = new DXFDocument(); parsingBlock = true; } } else { if (parsingBlock) { if (groupcode == 0 && value == "ENDBLK") { current.Children.AddRange(container.Entities); doc.Blocks.Add(current); current = null; container = null; } else if (groupcode == 0) { parsingBlock = false; parser.ParseGroupCode(container, groupcode, value); } else current.ParseGroupCode(groupcode, value); } else { if (groupcode == 0 && value == "ENDBLK") { current.Children.AddRange(container.Entities); doc.Blocks.Add(current); current = null; container = null; } else { parser.ParseGroupCode(container, groupcode, value); } } } }
public void ParseGroupCode(DXFDocument doc, int groupcode, string value) { switch (groupcode) { case 0: currentClass = new DXFClass(); doc.Classes.Add(currentClass); break; case 1: currentClass.DXFRecord = value; break; case 2: currentClass.ClassName = value; break; case 3: currentClass.AppName = value; break; case 90: currentClass.ClassProxyCapabilities = (DXFClass.Caps)Enum.Parse(typeof(DXFClass.Caps), value); break; case 280: if (int.Parse(value) != 0) { currentClass.WasProxy = true; } else { currentClass.WasProxy = false; } break; case 281: if (int.Parse(value) != 0) { currentClass.IsEntity = true; } else { currentClass.IsEntity = false; } break; } }
public override void ParseGroupCode(DXFDocument doc, int groupcode, string value) { base.ParseGroupCode(doc, groupcode, value); switch (groupcode) { case 2: _record.LayerName = value; break; case 62: _record.Color = int.Parse(value); break; case 6: _record.LineType = value; break; } }
public override void ParseGroupCode(DXFDocument doc, int groupcode, string value) { base.ParseGroupCode(doc, groupcode, value); switch (groupcode) { case 2: _record.UCSName = value; break; case 10: _record.Origin.X = double.Parse(value); break; case 20: _record.Origin.Y = double.Parse(value); break; case 30: _record.Origin.Z = double.Parse(value); break; case 11: _record.XAxis.X = double.Parse(value); break; case 21: _record.XAxis.Y = double.Parse(value); break; case 31: _record.XAxis.Z = double.Parse(value); break; case 12: _record.YAxis.X = double.Parse(value); break; case 22: _record.YAxis.Y = double.Parse(value); break; case 32: _record.YAxis.Z = double.Parse(value); break; } }
public override void ParseGroupCode(DXFDocument doc, int groupcode, string value) { base.ParseGroupCode(doc, groupcode, value); switch (groupcode) { case 2: _record.VPortName = value; break; case 10: _record.LowerLeftCorner.X = double.Parse(value); break; case 20: _record.LowerLeftCorner.Y = double.Parse(value); break; case 11: _record.UpperRightCorner.X = double.Parse(value); break; case 21: _record.UpperRightCorner.Y = double.Parse(value); break; case 12: _record.Center.X = double.Parse(value); break; case 22: _record.Center.Y = double.Parse(value); break; case 13: _record.SnapBase.X = double.Parse(value); break; case 23: _record.SnapBase.Y = double.Parse(value); break; case 14: _record.SnapSpacing.X = double.Parse(value); break; case 24: _record.SnapSpacing.Y = double.Parse(value); break; case 15: _record.GridSpacing.X = double.Parse(value); break; case 25: _record.GridSpacing.Y = double.Parse(value); break; case 16: _record.Direction.X = double.Parse(value); break; case 26: _record.Direction.Y = double.Parse(value); break; case 36: _record.Direction.Z = double.Parse(value); break; case 17: _record.Target.X = double.Parse(value); break; case 27: _record.Target.Y = double.Parse(value); break; case 37: _record.Target.Z = double.Parse(value); break; case 40: _record.Height = double.Parse(value); break; case 41: _record.AspectRatio = double.Parse(value); break; case 42: _record.LensLength = double.Parse(value); break; case 43: _record.FrontClippingPlane = double.Parse(value); break; case 44: _record.BackClippingPlane = double.Parse(value); break; case 50: _record.SnapRotationAngle = double.Parse(value); break; case 51: _record.TwistAngle = double.Parse(value); break; case 71: _record.ViewMode = int.Parse(value); break; case 72: _record.CircleZoomPercent = int.Parse(value); break; case 73: _record.FastZoomSetting = int.Parse(value); break; case 74: _record.UCSICONSetting = int.Parse(value); break; case 75: _record.SnapEnabled = int.Parse(value); break; case 76: _record.GridEnabled = int.Parse(value); break; case 77: _record.SnapStyle = int.Parse(value); break; case 78: _record.SnapIsoPair = int.Parse(value); break; } }
public void ParseGroupCode(DXFDocument doc, int groupcode, string value) { if (fields.Count == 0) { Type header = doc.Header.GetType(); foreach (PropertyInfo info in header.GetProperties(BindingFlags.Public | BindingFlags.Instance)) { if (info.CanWrite && info.CanRead) { object[] attrs = info.GetCustomAttributes(true); foreach (object attr in attrs) { HeaderAttribute casted = attr as HeaderAttribute; if (casted != null) { fields[casted.Name] = info; } } } } } if (groupcode == 9) { string name = value.Trim(); if (fields.ContainsKey(name)) { currentVar = fields[name]; } else { currentVar = null; } } else if (currentVar != null) { //at first we need to differentiate the types: nullable vs string and nullable vs rest if (currentVar.PropertyType.Equals(typeof(string))) { currentVar.SetValue(doc.Header, value, null); } else if (currentVar.PropertyType.IsGenericType && currentVar.PropertyType.GetGenericTypeDefinition().Equals(typeof(Nullable <>))) { Type boxedType = currentVar.PropertyType.GetGenericArguments()[0]; if (boxedType.Equals(typeof(int))) { int?parsed; if (value.ToLower().Contains('a') || value.ToLower().Contains('b') || value.ToLower().Contains('c') || value.ToLower().Contains('d') || value.ToLower().Contains('e') || value.ToLower().Contains('f')) { parsed = int.Parse(value, System.Globalization.NumberStyles.HexNumber); } else { parsed = int.Parse(value, System.Globalization.NumberStyles.Any); } currentVar.SetValue(doc.Header, parsed, null); } else if (boxedType.Equals(typeof(double))) { double?parsed = double.Parse(value); currentVar.SetValue(doc.Header, parsed, null); } else if (boxedType.Equals(typeof(bool))) { int?parsed = int.Parse(value); if (parsed != 0) { currentVar.SetValue(doc.Header, (bool?)true, null); } else { currentVar.SetValue(doc.Header, (bool?)false, null); } } else if (boxedType.IsEnum) { object parsed = Enum.Parse(boxedType, value); currentVar.SetValue(doc.Header, parsed, null); } } else if (currentVar.PropertyType.Equals(typeof(DXFPoint))) { DXFPoint p = (DXFPoint)currentVar.GetValue(doc.Header, null); if (p == null) { p = new DXFPoint(); currentVar.SetValue(doc.Header, p, null); } switch (groupcode) { case 10: p.X = double.Parse(value); break; case 20: p.Y = double.Parse(value); break; case 30: p.Z = double.Parse(value); break; default: break; } } } }
public override void ParseGroupCode(DXFDocument doc, int groupcode, string value) { base.ParseGroupCode(doc, groupcode, value); switch (groupcode) { case 2: _record.ViewPortName = value; break; case 40: _record.Height = double.Parse(value); break; case 41: _record.Width = double.Parse(value); break; case 10: _record.Center.X = double.Parse(value); break; case 20: _record.Center.Y = double.Parse(value); break; case 11: _record.Direction.X = double.Parse(value); break; case 21: _record.Direction.Y = double.Parse(value); break; case 31: _record.Direction.Z = double.Parse(value); break; case 12: _record.Target.X = double.Parse(value); break; case 22: _record.Target.Y = double.Parse(value); break; case 32: _record.Target.Z = double.Parse(value); break; case 42: _record.LensLength = double.Parse(value); break; case 43: _record.FrontClippingPlane = double.Parse(value); break; case 44: _record.BackClippingPlane = double.Parse(value); break; case 50: _record.TwistAngle = double.Parse(value); break; case 71: _record.ViewMode = int.Parse(value); break; } }
public void ParseGroupCode(DXFDocument doc, int groupcode, string value) { if (tablehandlers.Count == 0) { foreach (PropertyInfo info in doc.Tables.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)) { object[] attrs = info.GetCustomAttributes(true); foreach (object attr in attrs) { TableAttribute casted = attr as TableAttribute; if (casted != null) { tablehandlers[casted.TableName] = (ISectionParser)Activator.CreateInstance(casted.TableParser); } } } } if (currentParser == null) { if (groupcode == 0 && value.Trim() == "TABLE") { waitingtableheader = true; } else if (waitingtableheader && groupcode == 2 && !ignoretable) { if (tablehandlers.ContainsKey(value.Trim())) { currentParser = tablehandlers[value.Trim()]; waitingtableheader = false; ignoretable = false; firstrecordfound = false; } else { //TODO: generate warning ignoretable = true; } } else if (waitingtableheader && groupcode == 0 && value.Trim() == "ENDTAB") { waitingtableheader = false; ignoretable = false; } } else { if (groupcode == 0 && value.Trim() == "ENDTAB") { currentParser = null; } else { if (groupcode == 0) { firstrecordfound = true; } if (firstrecordfound) currentParser.ParseGroupCode(doc, groupcode, value); } } }
protected override void createRecord(DXFDocument doc) { _record = new DXFUCSRecord(); doc.Tables.UCS.Add(_record); }
public override void ParseGroupCode(DXFDocument doc, int groupcode, string value) { base.ParseGroupCode(doc, groupcode, value); switch (groupcode) { case 2: _record.LineTypeName = value; break; case 3: _record.Description = value; break; case 72: _record.AlignmentCode = int.Parse(value); break; case 73: _record.ElementCount = int.Parse(value); break; case 40: _record.PatternLength = double.Parse(value); break; case 49: _subrecord = new DXFLineTypeRecord.LineTypeElement(); _record.Elements.Add(_subrecord); _subrecord.Length = double.Parse(value); break; case 74: _subrecord.Flags = (DXFLineTypeRecord.ElementFlags)Enum.Parse(typeof(DXFLineTypeRecord.ElementFlags), value); break; case 75: _subrecord.ShapeNumber = int.Parse(value); break; case 340: _subrecord.Shape = value; break; case 46: _subrecord.Scalings.Add(double.Parse(value)); break; case 50: _subrecord.Rotation = double.Parse(value); break; case 44: _subrecord.XOffsets.Add(double.Parse(value)); break; case 45: _subrecord.YOffsets.Add(double.Parse(value)); break; case 9: _subrecord.Text = value; break; } }
protected override void createRecord(DXFDocument doc) { _currentRecord = new DXFAppIDRecord(); doc.Tables.AppIDs.Add(_currentRecord); }
protected override void createRecord(DXFDocument doc) { _record = new DXFLineTypeRecord(); doc.Tables.LineTypes.Add(_record); }
protected override void createRecord(DXFDocument doc) { _record = new DXFLayerRecord(); doc.Tables.Layers.Add(_record); }
protected override void createRecord(DXFDocument doc) { _record = new DXFDimStyleRecord(); doc.Tables.DimStyles.Add(_record); }
//[TestMethod] public void TestMethod3() { DXFDocument doc = new DXFDocument(); doc.Load(new MemoryStream(Properties.Resources.Untitled_2)); }
protected override void createRecord(DXFDocument doc) { _record = new DXFStyleRecord(); doc.Tables.Styles.Add(_record); }
public void ParseGroupCode(DXFDocument doc, int groupcode, string value) { if (tablehandlers.Count == 0) { foreach (PropertyInfo info in doc.Tables.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)) { object[] attrs = info.GetCustomAttributes(true); foreach (object attr in attrs) { TableAttribute casted = attr as TableAttribute; if (casted != null) { tablehandlers[casted.TableName] = (ISectionParser)Activator.CreateInstance(casted.TableParser); } } } } if (currentParser == null) { if (groupcode == 0 && value.Trim() == "TABLE") { waitingtableheader = true; } else if (waitingtableheader && groupcode == 2 && !ignoretable) { if (tablehandlers.ContainsKey(value.Trim())) { currentParser = tablehandlers[value.Trim()]; waitingtableheader = false; ignoretable = false; firstrecordfound = false; } else { //TODO: generate warning ignoretable = true; } } else if (waitingtableheader && groupcode == 0 && value.Trim() == "ENDTAB") { waitingtableheader = false; ignoretable = false; } } else { if (groupcode == 0 && value.Trim() == "ENDTAB") { currentParser = null; } else { if (groupcode == 0) { firstrecordfound = true; } if (firstrecordfound) { currentParser.ParseGroupCode(doc, groupcode, value); } } } }
protected override void createRecord(DXFDocument doc) { _record = new DXFViewRecord(); doc.Tables.Views.Add(_record); }
protected abstract void createRecord(DXFDocument doc);
//[TestMethod] public void TestMethod1() { DXFDocument doc = new DXFDocument(); doc.Load(new MemoryStream(Properties.Resources.LaptopStand)); }
public void TestMethod4() { DXFDocument doc = new DXFDocument(); doc.Load(new MemoryStream(Properties.Resources.Hase)); }
public override void ParseGroupCode(DXFDocument doc, int groupcode, string value) { base.ParseGroupCode(doc, groupcode, value); if (groupcode == 2) _record.StyleName = value; }