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 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); }
private static bool DelFunc(EmfPlusRecordType recordType, int flags, int dataSize, IntPtr recordData, PlayRecordCallback callbackData) { byte[] numArray = new byte[dataSize]; if (recordData != IntPtr.Zero) { Marshal.Copy(recordData, numArray, 0, dataSize); } EmfPlusRecordType emfPlusRecordType = recordType; if (emfPlusRecordType <= EmfPlusRecordType.DrawArc) { if (emfPlusRecordType == EmfPlusRecordType.EmfHeader) { MetaForm.imgWidth = MetaForm.EmfWidthToWidth((int)numArray[24], (int)numArray[25]); MetaForm.imgHeight = MetaForm.EmfWidthToWidth((int)numArray[28], (int)numArray[29]); MetaForm.cn_obj = (int)MetaForm.Format_Size2(numArray[41], numArray[42]); } else { switch (emfPlusRecordType) { case EmfPlusRecordType.Object: { if ((int)numArray.Length >= 32 || numArray[4] > 1) { if (numArray[4] != 0) { MetaForm.SplitRecObject(numArray); return(true); } if ((int)numArray.Length == 32) { MetaForm.r = numArray[30]; MetaForm.g = numArray[29]; MetaForm.b = numArray[28]; } if ((int)numArray.Length > 32) { MetaForm.r = numArray[34]; MetaForm.g = numArray[33]; MetaForm.b = numArray[32]; } if (numArray[8] == 0) { MetaForm.line_style = 0; } else { MetaForm.line_style = numArray[20]; } MetaForm.text_size = MetaForm.FormatSize((int)numArray[6], (int)numArray[7]); MetaForm.obj_width = MetaForm.FormatSize((int)numArray[18], (int)numArray[19]); MetaForm.text_style = numArray[12]; break; } else { MetaForm.r = numArray[14]; MetaForm.g = numArray[13]; MetaForm.b = numArray[12]; MetaForm.hatch_style = numArray[8]; break; } } case EmfPlusRecordType.Clear: case EmfPlusRecordType.FillPie: case EmfPlusRecordType.DrawPie: { return(true); } case EmfPlusRecordType.FillRects: { if (numArray[3] == 255) { MetaForm.r = numArray[2]; MetaForm.g = numArray[1]; MetaForm.b = numArray[0]; } MetaForm.DrawRectangle(numArray, 8, true); MetaForm.hatch_style = -1; break; } case EmfPlusRecordType.DrawRects: { MetaForm.DrawRectangle(numArray, 4, false); break; } case EmfPlusRecordType.FillPolygon: { MetaForm.DrawPolyLine(numArray, 4, true, false); MetaForm.hatch_style = -1; break; } case EmfPlusRecordType.DrawLines: { if (numArray[0] != 2) { MetaForm.DrawPolyLine(numArray, 0, false, false); break; } else { MetaForm.DrawLine(numArray, 4); break; } } case EmfPlusRecordType.FillEllipse: { if (numArray[3] != 0) { MetaForm.r = numArray[2]; MetaForm.g = numArray[1]; MetaForm.b = numArray[0]; } if (numArray[8] != numArray[10]) { MetaForm.DrawEllipse(numArray, 4, true); } else { MetaForm.DrawCircle(numArray, 4, true); } MetaForm.hatch_style = -1; break; } case EmfPlusRecordType.DrawEllipse: { if (numArray[4] != numArray[6]) { MetaForm.DrawEllipse(numArray, 0, false); break; } else { MetaForm.DrawCircle(numArray, 0, false); break; } } case EmfPlusRecordType.DrawArc: { if (numArray[12] != numArray[14]) { MetaForm.DrawEllArc(numArray); break; } else { MetaForm.DrawArc(numArray); break; } } default: { return(true); } } } } else if (emfPlusRecordType == EmfPlusRecordType.DrawBeziers) { MetaForm.DrawPolyLine(numArray, 0, false, true); } else if (emfPlusRecordType == EmfPlusRecordType.DrawString) { MetaForm.r = numArray[2]; MetaForm.g = numArray[1]; MetaForm.b = numArray[0]; MetaForm.DrawString(numArray); } else { switch (emfPlusRecordType) { case EmfPlusRecordType.ResetWorldTransform: { MetaForm.transform = false; break; } case EmfPlusRecordType.MultiplyWorldTransform: { return(true); } case EmfPlusRecordType.TranslateWorldTransform: { MetaForm.transform = true; MetaForm.transPoint.X = MetaForm.FormatSize((int)numArray[2], (int)numArray[3]); MetaForm.transPoint.Y = MetaForm.FormatSize((int)numArray[6], (int)numArray[7]); break; } default: { return(true); } } } return(true); }
private static void SplitRecObject(byte[] curArr) { int num = 12; int num1 = 4; if (curArr[9] != 64) { num1 = 8; } int num2 = num + (int)MetaForm.Format_Size2(curArr[4], curArr[5]) * num1; int length = (int)curArr.Length; ArrayList arrayLists = new ArrayList(); int num3 = -1; while (num2 < length) { if (curArr[num2] == 0) { if (num2 + 1 >= length || curArr[num2 + 1] == 0) { break; } arrayLists.Add(new MetaForm.ObjectEnt()); num3++; if (curArr[num2 + 1] == 1) { (arrayLists[num3] as MetaForm.ObjectEnt).type = MetaForm.ObjTypeRecord.objLine; } if (curArr[num2 + 1] == 3) { (arrayLists[num3] as MetaForm.ObjectEnt).type = MetaForm.ObjTypeRecord.objBezier; } } if ((arrayLists[num3] as MetaForm.ObjectEnt).type == MetaForm.ObjTypeRecord.objBezier && curArr[num2] == 1 || (arrayLists[num3] as MetaForm.ObjectEnt).type == MetaForm.ObjTypeRecord.objLine && curArr[num2] == 3) { arrayLists.Add(new MetaForm.ObjectEnt()); num3++; if (curArr[num2] == 1) { (arrayLists[num3] as MetaForm.ObjectEnt).type = MetaForm.ObjTypeRecord.objLine; } if (curArr[num2] == 3) { (arrayLists[num3] as MetaForm.ObjectEnt).type = MetaForm.ObjTypeRecord.objBezier; } int count = (arrayLists[num3 - 1] as MetaForm.ObjectEnt).points.Count - 1; (arrayLists[num3] as MetaForm.ObjectEnt).points.Add( (arrayLists[num3 - 1] as MetaForm.ObjectEnt).points[count]); (arrayLists[num3] as MetaForm.ObjectEnt).compobj = num3 - 1; } if (num1 != 4) { (arrayLists[num3] as MetaForm.ObjectEnt).points.Add( new PointF(MetaForm.FormatSize((int)curArr[num + 2], (int)curArr[num + 3]), MetaForm.FormatSize((int)curArr[num + 6], (int)curArr[num + 7]))); } else { (arrayLists[num3] as MetaForm.ObjectEnt).points.Add( new PointF(MetaForm.Format_Size2(curArr[num], curArr[num + 1]), MetaForm.Format_Size2(curArr[num + 2], curArr[num + 3]))); } if (curArr[num2] == 129 || curArr[num2] == 161) { (arrayLists[num3] as MetaForm.ObjectEnt).type = MetaForm.ObjTypeRecord.objCloseLine; } if (curArr[num2] == 131 || curArr[num2] == 163) { (arrayLists[num3] as MetaForm.ObjectEnt).type = MetaForm.ObjTypeRecord.objCloseBezier; } num = num + num1; num2++; } MetaForm.AddObjectsPath(arrayLists); }