private static void DrawRectangle(byte[] arr, byte cn, bool hatch) { float x = MetaForm.Format_Size2(arr[cn], arr[cn + 1]); float y = MetaForm.Format_Size2(arr[cn + 2], arr[cn + 3]); float single = MetaForm.Format_Size2(arr[cn + 4], arr[cn + 5]); float single1 = MetaForm.Format_Size2(arr[cn + 6], arr[cn + 7]); if (MetaForm.transform) { x = x + MetaForm.transPoint.X; y = y + MetaForm.transPoint.Y; } MetaForm.Data.Clear(); MetaForm.Data.color = DXFExport.ColorToDXF(Color.FromArgb(MetaForm.r, MetaForm.g, MetaForm.b)); MetaForm.SetLineStyle((int)MetaForm.line_style); MetaForm.Data.thickness = MetaForm.obj_width; MetaForm.Data.point.X = x; MetaForm.Data.point.Y = -y + (float)MetaForm.imgHeight; MetaForm.Data.point1.X = single + x; MetaForm.Data.point1.Y = -single1 - y + (float)MetaForm.imgHeight; if (!hatch) { MetaForm.vDXF.AddRectangle(MetaForm.Data); return; } MetaForm.Data.count = 1; MetaForm.Data.points.Add(new ArrayList()); DXFPoint dXFPoint = new DXFPoint() { X = MetaForm.Data.point.X, Y = MetaForm.Data.point.Y, Z = 0f }; ((ArrayList)MetaForm.Data.points[0]).Add(dXFPoint); dXFPoint = new DXFPoint() { X = MetaForm.Data.point1.X, Y = MetaForm.Data.point.Y, Z = 0f }; ((ArrayList)MetaForm.Data.points[0]).Add(dXFPoint); dXFPoint = new DXFPoint() { X = MetaForm.Data.point1.X, Y = MetaForm.Data.point1.Y, Z = 0f }; ((ArrayList)MetaForm.Data.points[0]).Add(dXFPoint); dXFPoint = new DXFPoint() { X = MetaForm.Data.point.X, Y = MetaForm.Data.point1.Y, Z = 0f }; ((ArrayList)MetaForm.Data.points[0]).Add(dXFPoint); MetaForm.SetHatchStyle(MetaForm.hatch_style); MetaForm.Data.selfType = 0; MetaForm.vDXF.AddHatch(MetaForm.Data); }
private static void DrawCircle(byte[] arr, byte cn, bool hatch) { float x = MetaForm.Format_Size2(arr[cn], arr[cn + 1]); float y = MetaForm.Format_Size2(arr[cn + 2], arr[cn + 3]); float single = MetaForm.Format_Size2(arr[cn + 4], arr[cn + 5]); float single1 = MetaForm.Format_Size2(arr[cn + 6], arr[cn + 7]); if (MetaForm.transform) { x = x + MetaForm.transPoint.X; y = y + MetaForm.transPoint.Y; } MetaForm.Data.Clear(); MetaForm.Data.color = DXFExport.ColorToDXF(Color.FromArgb(MetaForm.r, MetaForm.g, MetaForm.b)); MetaForm.Data.thickness = MetaForm.obj_width; MetaForm.Data.point.X = x; MetaForm.Data.point.Y = -y + (float)MetaForm.imgHeight; MetaForm.Data.point1.X = single + x; MetaForm.Data.point1.Y = -single1 - y + (float)MetaForm.imgHeight; MetaForm.Data.radius = (MetaForm.Data.point1.X - MetaForm.Data.point.X) / 2f; DXFPoint data = MetaForm.Data.point; data.Y = data.Y - MetaForm.Data.radius; DXFPoint dXFPoint = MetaForm.Data.point1; dXFPoint.Y = dXFPoint.Y - MetaForm.Data.radius; DXFPoint data1 = MetaForm.Data.point; data1.X = data1.X + MetaForm.Data.radius; DXFPoint x1 = MetaForm.Data.point1; x1.X = x1.X + MetaForm.Data.radius; MetaForm.SetLineStyle((int)MetaForm.line_style); if (!hatch) { MetaForm.vDXF.AddCircle(MetaForm.Data); return; } MetaForm.Data.startAngle = 0f; MetaForm.Data.endAngle = 360f; MetaForm.SetHatchStyle(MetaForm.hatch_style); MetaForm.Data.selfType = 1; MetaForm.vDXF.AddHatch(MetaForm.Data); }
private static void DrawPolyLine(byte[] arr, byte cn, bool hatch, bool bezier) { MetaForm.Data.Clear(); Color color = Color.FromArgb(MetaForm.r, MetaForm.g, MetaForm.b); MetaForm.Data.color = DXFExport.ColorToDXF(color); MetaForm.SetLineStyle((int)MetaForm.line_style); MetaForm.Data.thickness = MetaForm.obj_width; MetaForm.Data.points.Add(new ArrayList()); MetaForm.Data.count = arr[cn]; for (int i = 4; i < arr[cn] * 4 + 4; i = i + 4) { float x = MetaForm.Format_Size2(arr[cn + i], arr[cn + i + 1]); float y = MetaForm.Format_Size2(arr[cn + i + 2], arr[cn + i + 3]); if (MetaForm.transform) { x = x + MetaForm.transPoint.X; y = y + MetaForm.transPoint.Y; } y = -y + (float)MetaForm.imgHeight; ((ArrayList)MetaForm.Data.points[0]).Add(new DXFPoint(x, y, 0f)); } if (hatch) { MetaForm.SetHatchStyle(MetaForm.hatch_style); MetaForm.Data.selfType = 0; MetaForm.vDXF.AddHatch(MetaForm.Data); return; } if (bezier) { MetaForm.vDXF.AddPolyBezier(MetaForm.Data, 0); return; } MetaForm.vDXF.AddPolyLine(MetaForm.Data, 0); }
private static void DrawEllipse(byte[] arr, byte cn, bool hatch) { float x = MetaForm.Format_Size2(arr[cn], arr[cn + 1]); float y = MetaForm.Format_Size2(arr[cn + 2], arr[cn + 3]); float single = MetaForm.Format_Size2(arr[cn + 4], arr[cn + 5]); float single1 = MetaForm.Format_Size2(arr[cn + 6], arr[cn + 7]); if (MetaForm.transform) { x = x + MetaForm.transPoint.X; y = y + MetaForm.transPoint.Y; } MetaForm.Data.Clear(); MetaForm.SetLineStyle((int)MetaForm.line_style); MetaForm.Data.color = DXFExport.ColorToDXF(Color.FromArgb(MetaForm.r, MetaForm.g, MetaForm.b)); MetaForm.Data.thickness = MetaForm.obj_width; MetaForm.Data.point.X = x; MetaForm.Data.point.Y = -y + (float)MetaForm.imgHeight; MetaForm.Data.point1.X = single + x; MetaForm.Data.point1.Y = -single1 - y + (float)MetaForm.imgHeight; MetaForm.Data.radius = (MetaForm.Data.point1.X - MetaForm.Data.point.X) / 2f; DXFPoint data = MetaForm.Data.point; data.Y = data.Y - MetaForm.Data.radius; DXFPoint dXFPoint = MetaForm.Data.point1; dXFPoint.Y = dXFPoint.Y - MetaForm.Data.radius; DXFPoint data1 = MetaForm.Data.point; data1.X = data1.X + MetaForm.Data.radius; DXFPoint x1 = MetaForm.Data.point1; x1.X = x1.X + MetaForm.Data.radius; if (single <= single1) { DXFPoint y1 = MetaForm.Data.point; y1.Y = y1.Y - (single1 - single) / 2f; DXFPoint dXFPoint1 = MetaForm.Data.point1; dXFPoint1.Y = dXFPoint1.Y - (single1 - single) / 2f; } else { DXFPoint data2 = MetaForm.Data.point; data2.Y = data2.Y + (single - single1) / 2f; DXFPoint y2 = MetaForm.Data.point1; y2.Y = y2.Y + (single - single1) / 2f; } MetaForm.Data.point1.X = (MetaForm.Data.point1.X - MetaForm.Data.point.X) / 2f; MetaForm.Data.point1.Y = (MetaForm.Data.point1.Y - MetaForm.Data.point.Y) / 2f; if (MetaForm.Data.radius < MetaForm.Data.point1.Y) { MetaForm.Data.radius = MetaForm.Data.point1.Y; } DXFPoint x2 = MetaForm.Data.point1; x2.X = x2.X / MetaForm.Data.radius; DXFPoint dXFPoint2 = MetaForm.Data.point1; dXFPoint2.Y = dXFPoint2.Y / MetaForm.Data.radius; if (MetaForm.Data.point1.X <= MetaForm.Data.point1.Y) { MetaForm.Data.point1.Y = MetaForm.Data.radius; MetaForm.Data.radius = MetaForm.Data.point1.X; MetaForm.Data.point1.X = 0f; } else { MetaForm.Data.point1.X = MetaForm.Data.radius; MetaForm.Data.radius = MetaForm.Data.point1.Y; MetaForm.Data.point1.Y = 0f; } if (!hatch) { MetaForm.vDXF.AddEllipse(MetaForm.Data); return; } MetaForm.Data.startAngle = 0f; MetaForm.Data.endAngle = 6.283185f; MetaForm.SetHatchStyle(MetaForm.hatch_style); MetaForm.Data.selfType = 2; MetaForm.vDXF.AddHatch(MetaForm.Data); }