private static void DrawLine(byte[] arr, byte cn) { 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 y1 = MetaForm.Format_Size2(arr[cn + 6], arr[cn + 7]); if (MetaForm.transform) { x = x + MetaForm.transPoint.X; y = y + MetaForm.transPoint.Y; single = single + MetaForm.transPoint.X; y1 = y1 + MetaForm.transPoint.Y; } 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.point1.X = x; MetaForm.Data.point1.Y = -y + (float)MetaForm.imgHeight; MetaForm.Data.point.X = single; MetaForm.Data.point.Y = -y1 + (float)MetaForm.imgHeight; MetaForm.vDXF.AddLine(MetaForm.Data); }
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 DrawArc(byte[] arr) { float single = MetaForm.FormatSize((int)arr[2], (int)arr[3]); float single1 = MetaForm.FormatSize((int)arr[6], (int)arr[7]); float x = MetaForm.Format_Size2(arr[8], arr[9]); float y = MetaForm.Format_Size2(arr[10], arr[11]); float single2 = MetaForm.Format_Size2(arr[12], arr[13]); float single3 = MetaForm.Format_Size2(arr[14], arr[15]); if (MetaForm.transform) { x = x + MetaForm.transPoint.X; y = y + MetaForm.transPoint.Y; } MetaForm.Data.Clear(); MetaForm.SetLineStyle((int)MetaForm.line_style); MetaForm.Data.thickness = MetaForm.obj_width; MetaForm.Data.color = DXFExport.ColorToDXF(Color.FromArgb(MetaForm.r, MetaForm.g, MetaForm.b)); MetaForm.Data.point.X = x; MetaForm.Data.point.Y = -y + (float)MetaForm.imgHeight; MetaForm.Data.point1.X = single2 + x; MetaForm.Data.point1.Y = -single3 - 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.Data.startAngle = -single1 - single; MetaForm.Data.endAngle = -single; MetaForm.Data.selfType = 0; MetaForm.vDXF.AddArc(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); }
private static void DrawEllArc(byte[] arr) { float single = MetaForm.FormatSize((int)arr[2], (int)arr[3]); float single1 = MetaForm.FormatSize((int)arr[6], (int)arr[7]); float x = MetaForm.Format_Size2(arr[8], arr[9]); float y = MetaForm.Format_Size2(arr[10], arr[11]); float single2 = MetaForm.Format_Size2(arr[12], arr[13]); float single3 = MetaForm.Format_Size2(arr[14], arr[15]); 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 = single2 + x; MetaForm.Data.point1.Y = -single3 - 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 (single2 <= single3) { DXFPoint y1 = MetaForm.Data.point; y1.Y = y1.Y - (single3 - single2) / 2f; DXFPoint dXFPoint1 = MetaForm.Data.point1; dXFPoint1.Y = dXFPoint1.Y - (single3 - single2) / 2f; } else { DXFPoint data2 = MetaForm.Data.point; data2.Y = data2.Y + (single2 - single3) / 2f; DXFPoint y2 = MetaForm.Data.point1; y2.Y = y2.Y + (single2 - single3) / 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; } MetaForm.Data.selfType = 1; MetaForm.Data.startAngle = single * MetaForm.rad; MetaForm.Data.endAngle = (single1 + single) * MetaForm.rad; MetaForm.vDXF.AddArc(MetaForm.Data); }