Beispiel #1
0
        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);
        }