Monday, 26 March 2012

Image Generator


public static void ChangeImageColor(Hammond obj)
{
    using (Image image = Image.FromFile(HttpContext.Current.Server.MapPath(obj.StandardVerse)))
    {
        using (MemoryStream stream = new MemoryStream(ConvertImageToByteArray(image)))
        {
            using (Image image2 = Image.FromFile(HttpContext.Current.Server.MapPath(obj.StandardVerse)))
            {
                using ((Bitmap) image2)
                {
                    using (Image image3 = Image.FromStream(stream))
                    {
                        using (Bitmap bitmap2 = new Bitmap(new Bitmap(image3)))
                        {
                            List<Color> list = new List<Color>();
                            height = bitmap2.Height;
                            List<int> list2 = new List<int>();
                            List<int> list3 = new List<int>();
                            int num6 = bitmap2.Width - 1;
                            for (int i = 0; i <= num6; i++)
                            {
                                int num7 = bitmap2.Height - 1;
                                for (int k = 0; k <= num7; k++)
                                {
                                    if ((((((bitmap2.GetPixel(i, k).R != 0xff) && (bitmap2.GetPixel(i, k).G != 0xff)) && ((bitmap2.GetPixel(i, k).G != 0xfe) && (bitmap2.GetPixel(i, k).G != 0xfd))) && (((bitmap2.GetPixel(i, k).G != 0xfc) && (bitmap2.GetPixel(i, k).G != 0xfb)) && ((bitmap2.GetPixel(i, k).G != 250) && (bitmap2.GetPixel(i, k).G != 0xf9)))) && ((((bitmap2.GetPixel(i, k).G != 0xf8) && (bitmap2.GetPixel(i, k).G != 0xf7)) && ((bitmap2.GetPixel(i, k).G != 0xf6) && (bitmap2.GetPixel(i, k).G != 0xf5))) && (((bitmap2.GetPixel(i, k).G != 0xf4) && (bitmap2.GetPixel(i, k).G != 0xf3)) && ((bitmap2.GetPixel(i, k).G != 0xf2) && (bitmap2.GetPixel(i, k).G != 0xf1))))) && (((((bitmap2.GetPixel(i, k).G != 240) && (bitmap2.GetPixel(i, k).G != 0xef)) && ((bitmap2.GetPixel(i, k).G != 0xee) && (bitmap2.GetPixel(i, k).G != 0xed))) && (((bitmap2.GetPixel(i, k).G != 0xec) && (bitmap2.GetPixel(i, k).G != 0xeb)) && ((bitmap2.GetPixel(i, k).G != 0xea) && (bitmap2.GetPixel(i, k).G != 0xe9)))) && ((((bitmap2.GetPixel(i, k).G != 0xe8) && (bitmap2.GetPixel(i, k).G != 0xe7)) && ((bitmap2.GetPixel(i, k).G != 230) && (bitmap2.GetPixel(i, k).G != 0xe5))) && (((bitmap2.GetPixel(i, k).G != 0xe4) && (bitmap2.GetPixel(i, k).G != 0xe3)) && (((bitmap2.GetPixel(i, k).G != 0xe2) && (bitmap2.GetPixel(i, k).G != 0xe1)) && (bitmap2.GetPixel(i, k).B != 0xff))))))
                                    {
                                        list2.Add(i);
                                        list3.Add(k);
                                    }
                                }
                            }
                            int num8 = bitmap2.Width - 1;
                            for (int j = 0; j <= num8; j++)
                            {
                                int num9 = bitmap2.Height - 1;
                                for (int m = 0; m <= num9; m++)
                                {
                                    bitmap2.SetPixel(j, m, Color.White);
                                }
                            }
                            if (obj.StandardVerse.Substring(obj.StandardVerse.LastIndexOf("/") + 1) != "00000blank.jpg")
                            {
                                int num10 = list2.Count - 1;
                                for (int n = 0; n <= num10; n++)
                                {
                                    bitmap2.SetPixel(list2[n], list3[n], Color.FromName(obj.ImprintInk));
                                }
                            }
                            string filename = HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_verse.tif");
                            bitmap2.Save(filename, ImageFormat.Tiff);
                        }
                    }
                }
            }
        }
    }
}

 /***************/


public static byte[] ConvertImageToByteArray(Image imageIn)
{
    using (MemoryStream stream = new MemoryStream())
    {
        imageIn.Save(stream, ImageFormat.Png);
        return stream.ToArray();
    }
}




End 

public static string CreateCardHighProof(Hammond obj)
{
    string str = Guid.NewGuid().ToString();
    string str3 = Guid.NewGuid().ToString();
    try
    {
        ColorMatrix newColorMatrix = new ColorMatrix(new float[][] { new float[] { 0.299f, 0.299f, 0.299f, 0f, 0f }, new float[] { 0.587f, 0.587f, 0.587f, 0f, 0f }, new float[] { 0.114f, 0.114f, 0.114f, 0f, 0f }, new float[] { 0f, 0f, 0f, 1f, 0f }, new float[] { 0f, 0f, 0f, 0f, 1f } }) {
            Matrix33 = 1f
        };
        using (ImageAttributes attributes = new ImageAttributes())
        {
            float num3;
            float num4;
            float num5;
            float num6;
            attributes.SetColorMatrix(newColorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Default);
            string str4 = obj.CardSize.Replace("X", "x").Replace("\"", "");
            if (str4.Substring(0, str4.IndexOf("x") - 1).Contains("/"))
            {
                string[] strArray = str4.Substring(0, str4.IndexOf("x") - 1).Split(new char[] { ' ' });
                num3 = Conversions.ToSingle(strArray[0]);
                string[] strArray2 = strArray[1].Split(new char[] { '/' });
                num4 = Conversions.ToSingle(strArray2[0]) / Conversions.ToSingle(strArray2[1]);
            }
            else
            {
                num3 = Conversions.ToSingle(str4.Substring(0, str4.IndexOf("x") - 1).Trim());
                num4 = 0f;
            }
            if (str4.Substring(str4.IndexOf("x") + 2).Contains("/"))
            {
                string[] strArray3 = str4.Substring(str4.IndexOf("x") + 2).Split(new char[] { ' ' });
                num5 = Conversions.ToSingle(strArray3[0]);
                string[] strArray4 = strArray3[1].Split(new char[] { '/' });
                num6 = Conversions.ToSingle(strArray4[0]) / Conversions.ToSingle(strArray4[1]);
            }
            else
            {
                num5 = Conversions.ToSingle(str4.Substring(str4.IndexOf("x") + 2).Trim());
                num6 = 0f;
            }
            int width = (int) Math.Round((double) TwipsToPixelsX(Convert.ToSingle((float) ((num3 + num4) * 1440f)), obj.ResolutionType));
            int height = (int) Math.Round((double) TwipsToPixelsY(Convert.ToSingle((float) ((num5 + num6) * 1440f)), obj.ResolutionType));
            using (Bitmap bitmap = new Bitmap(width, height))
            {
                if (Conversions.ToDouble(obj.CompanyID) == 3.0)
                {
                    bitmap.SetResolution(600f, 600f);
                }
                else if (Conversions.ToDouble(obj.CompanyID) == 2.0)
                {
                    bitmap.SetResolution(600f, 600f);
                }
                using (Graphics graphics = Graphics.FromImage(bitmap))
                {
                    string str10;
                    string str16;
                    Rectangle rectangle;
                    graphics.Clear(Color.White);
                    graphics.CompositingQuality = CompositingQuality.HighSpeed;
                    graphics.SmoothingMode = SmoothingMode.HighQuality;
                    graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                    Color color = Color.FromName("Black");
                    float num10 = TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.VerseWidth, 1440M)), obj.ResolutionType);
                    float num9 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.VerseHeight, 1440M)), obj.ResolutionType);
                    float num8 = TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextWidth, 1440M)), obj.ResolutionType);
                    float num7 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextHeight, 1440M)), obj.ResolutionType);
                    if (obj.VerseType == "Standard")
                    {
                        using (Image image = Image.FromFile(HttpContext.Current.Server.MapPath(obj.StandardVerse)))
                        {
                            float num11;
                            float num12;
                            RectangleF ef;
                            if (Conversions.ToDouble(obj.CompanyID) == 3.0)
                            {
                                num11 = width - TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.VerseLeft, 1440M)), obj.ResolutionType);
                                if (obj.CardLayout == "H")
                                {
                                    num12 = height - TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.VerseTop, 1440M)), obj.ResolutionType);
                                }
                                else
                                {
                                    num12 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.VerseTop, 1440M)), obj.ResolutionType);
                                }
                                ef = new RectangleF(num11, num12, num10, num9);
                            }
                            else if (Conversions.ToDouble(obj.CompanyID) == 2.0)
                            {
                                rectangle = new Rectangle((int) Math.Round((double) TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.VerseLeft, 1440M)), obj.ResolutionType)), (int) Math.Round((double) TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.VerseTop, 1440M)), obj.ResolutionType)), (int) Math.Round((double) num10), (int) Math.Round((double) num9));
                                ef = rectangle;
                                num11 = TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.VerseLeft, 1440M)), obj.ResolutionType);
                                num12 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.VerseTop, 1440M)), obj.ResolutionType);
                            }
                            if ((Conversions.ToString(obj.VerseAlignmentX) == "T") & (Conversions.ToString(obj.VerseAlignmentY) == "C"))
                            {
                                graphics.DrawImage(image, num11 + ((num10 - image.Width) / 2f), num12, (float) image.Width, (float) image.Height);
                            }
                            else
                            {
                                rectangle = new Rectangle((int) Math.Round((double) (num11 + ((num10 - image.Width) / 2f))), (int) Math.Round((double) (num12 + ((num9 - image.Height) / 2f))), (int) Math.Round((double) image.Width), (int) Math.Round((double) image.Height));
                                graphics.DrawImage(image, rectangle, 0f, 0f, (float) image.Width, (float) image.Height, GraphicsUnit.Pixel, attributes);
                            }
                        }
                    }
                    else if (obj.VerseType == "Custom")
                    {
                        RectangleF ef2;
                        if (Conversions.ToDouble(obj.CompanyID) == 3.0)
                        {
                            object obj2;
                            float x = width - TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.VerseLeft, 1440M)), obj.ResolutionType);
                            if (obj.CardLayout == "H")
                            {
                                obj2 = height - TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.VerseTop, 1440M)), obj.ResolutionType);
                            }
                            else
                            {
                                obj2 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.VerseTop, 1440M)), obj.ResolutionType);
                            }
                            ef2 = new RectangleF(x, Conversions.ToSingle(obj2), num10, num9);
                        }
                        else if (Conversions.ToDouble(obj.CompanyID) == 2.0)
                        {
                            rectangle = new Rectangle((int) Math.Round((double) TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.VerseLeft, 1440M)), obj.ResolutionType)), (int) Math.Round((double) TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.VerseTop, 1440M)), obj.ResolutionType)), (int) Math.Round((double) num10), (int) Math.Round((double) num9));
                            ef2 = rectangle;
                        }
                        string typeStyle = obj.TypeStyle;
                        using (PrivateFontCollection fonts = new PrivateFontCollection())
                        {
                            DirectoryInfo info = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/"));
                            if (info.Exists)
                            {
                                FileInfo[] files = info.GetFiles();
                                for (int i = 0; i < files.Length; i++)
                                {
                                    object obj3 = files[i];
                                    fonts.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + obj3.ToString());
                                    if (fonts.Families[fonts.Families.Count<FontFamily>() - 1].Name == typeStyle)
                                    {
                                        fonts.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + obj3.ToString());
                                        break;
                                    }
                                }
                                info = null;
                            }
                            using (Font font = new Font(fonts.Families[fonts.Families.Count<FontFamily>() - 1], Convert.ToSingle(obj.VerseFontSize)))
                            {
                                using (SolidBrush brush = new SolidBrush(color))
                                {
                                    using (StringFormat format = new StringFormat())
                                    {
                                        if ((Conversions.ToString(obj.VerseAlignmentX) == "T") & (Conversions.ToString(obj.VerseAlignmentY) == "C"))
                                        {
                                            format.Alignment = StringAlignment.Center;
                                            format.LineAlignment = StringAlignment.Near;
                                            format.Trimming = StringTrimming.Character;
                                            graphics.DrawString(obj.CustomVerseText, font, brush, ef2, format);
                                        }
                                        else
                                        {
                                            format.Alignment = StringAlignment.Center;
                                            format.LineAlignment = StringAlignment.Center;
                                            format.Trimming = StringTrimming.Character;
                                            graphics.DrawString(obj.CustomVerseText, font, brush, ef2, format);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (!obj.LogoShow)
                    {
                        goto Label_478F;
                    }
                    if (obj.CardLogoLocation != "Below")
                    {
                        goto Label_29C0;
                    }
                    if (!((!(TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.IconLeft, 1440M)), obj.ResolutionType) == TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType)) & !(TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.IconTop, 1440M)), obj.ResolutionType) == TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType))) & (Conversions.ToDouble(obj.CompanyID) == 3.0)))
                    {
                        goto Label_18A7;
                    }
                    string filename = HttpContext.Current.Server.MapPath("~/Order/OrderLogos/Card/" + obj.LogoName);
                    using (Image image2 = Image.FromFile(filename))
                    {
                        object obj4;
                        double num17;
                        double num18;
                        float num15 = TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.IconWidth, 1440M)), obj.ResolutionType);
                        float num14 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.IconHeight, 1440M)), obj.ResolutionType);
                        float num16 = width - TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.IconLeft, 1440M)), obj.ResolutionType);
                        if (obj.CardLayout == "H")
                        {
                            obj4 = height - TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.IconTop, 1440M)), obj.ResolutionType);
                        }
                        else
                        {
                            obj4 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.IconTop, 1440M)), obj.ResolutionType);
                        }
                        RectangleF ef3 = new RectangleF(num16, Conversions.ToSingle(obj4), num15, num14);
                        if (!(image2.HorizontalResolution == 600f) | !(image2.VerticalResolution == 600f))
                        {
                            using (MemoryStream stream = new MemoryStream(ConvertImageToByteArray(image2)))
                            {
                                using (Image image3 = Image.FromStream(stream))
                                {
                                    using (Image image4 = SetResolution(image3, 600))
                                    {
                                        if ((image4.Width > num15) & (image4.Height > num14))
                                        {
                                            num17 = num15 / ((float) image4.Width);
                                            num18 = num14 / ((float) image4.Height);
                                        }
                                        else if ((image4.Width > num15) & (image4.Height < num14))
                                        {
                                            num17 = num15 / ((float) image4.Width);
                                            num18 = 1.0;
                                        }
                                        else if ((image4.Width < num15) & (image4.Height > num14))
                                        {
                                            num17 = 1.0;
                                            num18 = num14 / ((float) image4.Height);
                                        }
                                        else
                                        {
                                            num17 = 1.0;
                                            num18 = 1.0;
                                        }
                                        if (!(num17 == 1.0) | !(num18 == 1.0))
                                        {
                                            ResizeImage(image4, num17, num18, HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif"));
                                        }
                                        if ((num17 == 1.0) & (num18 == 1.0))
                                        {
                                            using (Image image5 = image4)
                                            {
                                                rectangle = new Rectangle((int) Math.Round((double) (num16 + ((num15 - image5.Width) / 2f))), Conversions.ToInteger(Operators.AddObject(obj4, (num14 - image5.Height) / 2f)), image5.Width, image5.Height);
                                                graphics.DrawImage(image5, rectangle, 0f, 0f, (float) image5.Width, (float) image5.Height, GraphicsUnit.Pixel, attributes);
                                            }
                                        }
                                        else
                                        {
                                            using (Image image6 = Image.FromFile(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif")))
                                            {
                                                rectangle = new Rectangle((int) Math.Round((double) (num16 + ((num15 - image6.Width) / 2f))), Conversions.ToInteger(Operators.AddObject(obj4, (num14 - image6.Height) / 2f)), image6.Width, image6.Height);
                                                graphics.DrawImage(image6, rectangle, 0f, 0f, (float) image6.Width, (float) image6.Height, GraphicsUnit.Pixel, attributes);
                                            }
                                        }
                                    }
                                    goto Label_1531;
                                }
                            }
                        }
                        if ((image2.Width > num15) & (image2.Height > num14))
                        {
                            num17 = num15 / ((float) image2.Width);
                            num18 = num14 / ((float) image2.Height);
                        }
                        else if ((image2.Width > num15) & (image2.Height < num14))
                        {
                            num17 = num15 / ((float) image2.Width);
                            num18 = 1.0;
                        }
                        else if ((image2.Width < num15) & (image2.Height > num14))
                        {
                            num17 = 1.0;
                            num18 = num14 / ((float) image2.Height);
                        }
                        else
                        {
                            num17 = 1.0;
                            num18 = 1.0;
                        }
                        if (!(num17 == 1.0) | !(num18 == 1.0))
                        {
                            ResizeImage(image2, num17, num18, HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif"));
                        }
                        if ((num17 == 1.0) & (num18 == 1.0))
                        {
                            using (Image image7 = image2)
                            {
                                rectangle = new Rectangle((int) Math.Round((double) (num16 + ((num15 - image7.Width) / 2f))), Conversions.ToInteger(Operators.AddObject(obj4, (num14 - image7.Height) / 2f)), image7.Width, image7.Height);
                                graphics.DrawImage(image7, rectangle, 0f, 0f, (float) image7.Width, (float) image7.Height, GraphicsUnit.Pixel, attributes);
                            }
                        }
                        else
                        {
                            using (Image image8 = Image.FromFile(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif")))
                            {
                                rectangle = new Rectangle((int) Math.Round((double) (num16 + ((num15 - image8.Width) / 2f))), Conversions.ToInteger(Operators.AddObject(obj4, (num14 - image8.Height) / 2f)), image8.Width, image8.Height);
                                graphics.DrawImage(image8, rectangle, 0f, 0f, (float) image8.Width, (float) image8.Height, GraphicsUnit.Pixel, attributes);
                            }
                        }
                    }
                Label_1531:
                    if (obj.MessageShow)
                    {
                        RectangleF ef4;
                        string s = obj.Personalize1 + Environment.NewLine + obj.Personalize2 + Environment.NewLine + obj.Personalize3 + Environment.NewLine + obj.Personalize4;
                        if (Conversions.ToDouble(obj.CompanyID) == 3.0)
                        {
                            object obj5;
                            float num19 = width - TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType);
                            if (obj.CardLayout == "H")
                            {
                                obj5 = height - TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                            }
                            else
                            {
                                obj5 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                            }
                            ef4 = new RectangleF(num19, Conversions.ToSingle(obj5), num8, num7);
                        }
                        using (SolidBrush brush2 = new SolidBrush(color))
                        {
                            using (StringFormat format2 = new StringFormat())
                            {
                                if ((Conversions.ToString(obj.TextAlignmentX) == "T") & (Conversions.ToString(obj.TextAlignmentY) == "C"))
                                {
                                    format2.Alignment = StringAlignment.Center;
                                    format2.LineAlignment = StringAlignment.Near;
                                    format2.Trimming = StringTrimming.Character;
                                }
                                else
                                {
                                    format2.Alignment = StringAlignment.Center;
                                    format2.LineAlignment = StringAlignment.Center;
                                    format2.Trimming = StringTrimming.Character;
                                }
                                using (PrivateFontCollection fonts2 = new PrivateFontCollection())
                                {
                                    DirectoryInfo info2 = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/"));
                                    string messageTypeStyle = obj.MessageTypeStyle;
                                    if (info2.Exists)
                                    {
                                        FileInfo[] infoArray8 = info2.GetFiles();
                                        for (int j = 0; j < infoArray8.Length; j++)
                                        {
                                            object obj6 = infoArray8[j];
                                            fonts2.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + obj6.ToString());
                                            if (fonts2.Families[fonts2.Families.Count<FontFamily>() - 1].Name == messageTypeStyle)
                                            {
                                                fonts2.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + obj6.ToString());
                                                break;
                                            }
                                        }
                                        info2 = null;
                                    }
                                    using (Font font2 = new Font(fonts2.Families[fonts2.Families.Count<FontFamily>() - 1], Convert.ToSingle(obj.MessageFontSize)))
                                    {
                                        graphics.DrawString(s, font2, brush2, ef4, format2);
                                    }
                                }
                            }
                        }
                    }
                    goto Label_29C0;
                Label_18A7:
                    str10 = HttpContext.Current.Server.MapPath("~/Order/OrderLogos/Card/" + obj.LogoName);
                    using (Image image9 = Image.FromFile(str10))
                    {
                        object obj7;
                        object obj8;
                        double num20;
                        double num21;
                        if (Conversions.ToDouble(obj.CompanyID) == 2.0)
                        {
                            obj7 = TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType);
                            obj8 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                        }
                        else if (Conversions.ToDouble(obj.CompanyID) == 3.0)
                        {
                            obj7 = width - TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType);
                            if (obj.CardLayout == "H")
                            {
                                obj8 = height - TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                            }
                            else
                            {
                                obj8 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                            }
                        }
                        RectangleF ef5 = new RectangleF(Conversions.ToSingle(obj7), Conversions.ToSingle(obj8), num8, num7);
                        if (!(image9.HorizontalResolution == 600f) | !(image9.VerticalResolution == 600f))
                        {
                            using (MemoryStream stream2 = new MemoryStream(ConvertImageToByteArray(image9)))
                            {
                                using (Image image10 = Image.FromStream(stream2))
                                {
                                    using (Image image11 = SetResolution(image10, 600))
                                    {
                                        if (obj.MessageShow)
                                        {
                                            if ((image11.Width > num8) & (image11.Height > (num7 / 2f)))
                                            {
                                                num20 = num8 / ((float) image11.Width);
                                                num21 = (num7 / 2f) / ((float) image11.Height);
                                            }
                                            else if ((image11.Width > num8) & (image11.Height < (num7 / 2f)))
                                            {
                                                num20 = num8 / ((float) image11.Width);
                                                num21 = 1.0;
                                            }
                                            else if ((image11.Width < num8) & (image11.Height > (num7 / 2f)))
                                            {
                                                num20 = 1.0;
                                                num21 = (num7 / 2f) / ((float) image11.Height);
                                            }
                                            else
                                            {
                                                num20 = 1.0;
                                                num21 = 1.0;
                                            }
                                        }
                                        else if ((image11.Width > num8) & (image11.Height > num7))
                                        {
                                            num20 = num8 / ((float) image11.Width);
                                            num21 = num7 / ((float) image11.Height);
                                        }
                                        else if ((image11.Width > num8) & (image11.Height < num7))
                                        {
                                            num20 = num8 / ((float) image11.Width);
                                            num21 = 1.0;
                                        }
                                        else if ((image11.Width < num8) & (image11.Height > num7))
                                        {
                                            num20 = 1.0;
                                            num21 = num7 / ((float) image11.Height);
                                        }
                                        else
                                        {
                                            num20 = 1.0;
                                            num21 = 1.0;
                                        }
                                        if (!(num20 == 1.0) | !(num21 == 1.0))
                                        {
                                            ResizeImage(image11, num20, num21, HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif"));
                                        }
                                        if ((num20 == 1.0) & (num21 == 1.0))
                                        {
                                            using (Image image12 = image11)
                                            {
                                                if (!obj.MessageShow)
                                                {
                                                    rectangle = new Rectangle(Conversions.ToInteger(Operators.AddObject(obj7, (num8 - image12.Width) / 2f)), Conversions.ToInteger(Operators.AddObject(obj8, (num7 - image12.Height) / 2f)), (int) Math.Round((double) image12.Width), (int) Math.Round((double) image12.Height));
                                                    graphics.DrawImage(image12, rectangle, 0f, 0f, (float) image12.Width, (float) image12.Height, GraphicsUnit.Pixel, attributes);
                                                }
                                                else
                                                {
                                                    rectangle = new Rectangle(Conversions.ToInteger(Operators.AddObject(obj7, (num8 - image12.Width) / 2f)), Conversions.ToInteger(Operators.AddObject(obj8, num7 / 2f)), image12.Width, image12.Height);
                                                    graphics.DrawImage(image12, rectangle, 0f, 0f, (float) image12.Width, (float) image12.Height, GraphicsUnit.Pixel, attributes);
                                                }
                                            }
                                            goto Label_261D;
                                        }
                                        using (Image image13 = Image.FromFile(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif")))
                                        {
                                            if (!obj.MessageShow)
                                            {
                                                rectangle = new Rectangle(Conversions.ToInteger(Operators.AddObject(obj7, (num8 - image13.Width) / 2f)), Conversions.ToInteger(Operators.AddObject(obj8, (num7 - image13.Height) / 2f)), (int) Math.Round((double) image13.Width), (int) Math.Round((double) image13.Height));
                                                graphics.DrawImage(image13, rectangle, 0f, 0f, (float) image13.Width, (float) image13.Height, GraphicsUnit.Pixel, attributes);
                                            }
                                            else
                                            {
                                                rectangle = new Rectangle(Conversions.ToInteger(Operators.AddObject(obj7, (num8 - image13.Width) / 2f)), Conversions.ToInteger(Operators.AddObject(obj8, num7 / 2f)), image13.Width, image13.Height);
                                                graphics.DrawImage(image13, rectangle, 0f, 0f, (float) image13.Width, (float) image13.Height, GraphicsUnit.Pixel, attributes);
                                            }
                                            goto Label_261D;
                                        }
                                    }
                                }
                            }
                        }
                        if (obj.MessageShow)
                        {
                            if ((image9.Width > num8) & (image9.Height > (num7 / 2f)))
                            {
                                num20 = num8 / ((float) image9.Width);
                                num21 = (num7 / 2f) / ((float) image9.Height);
                            }
                            else if ((image9.Width > num8) & (image9.Height < (num7 / 2f)))
                            {
                                num20 = num8 / ((float) image9.Width);
                                num21 = 1.0;
                            }
                            else if ((image9.Width < num8) & (image9.Height > (num7 / 2f)))
                            {
                                num20 = 1.0;
                                num21 = (num7 / 2f) / ((float) image9.Height);
                            }
                            else
                            {
                                num20 = 1.0;
                                num21 = 1.0;
                            }
                        }
                        else if ((image9.Width > num8) & (image9.Height > num7))
                        {
                            num20 = num8 / ((float) image9.Width);
                            num21 = num7 / ((float) image9.Height);
                        }
                        else if ((image9.Width > num8) & (image9.Height < num7))
                        {
                            num20 = num8 / ((float) image9.Width);
                            num21 = 1.0;
                        }
                        else if ((image9.Width < num8) & (image9.Height > num7))
                        {
                            num20 = 1.0;
                            num21 = num7 / ((float) image9.Height);
                        }
                        else
                        {
                            num20 = 1.0;
                            num21 = 1.0;
                        }
                        if (!(num20 == 1.0) | !(num21 == 1.0))
                        {
                            ResizeImage(image9, num20, num21, HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif"));
                        }
                        if ((num20 == 1.0) & (num21 == 1.0))
                        {
                            using (Image image14 = image9)
                            {
                                if (!obj.MessageShow)
                                {
                                    rectangle = new Rectangle(Conversions.ToInteger(Operators.AddObject(obj7, (num8 - image14.Width) / 2f)), Conversions.ToInteger(Operators.AddObject(obj8, (num7 - image14.Height) / 2f)), (int) Math.Round((double) image14.Width), (int) Math.Round((double) image14.Height));
                                    graphics.DrawImage(image14, rectangle, 0f, 0f, (float) image14.Width, (float) image14.Height, GraphicsUnit.Pixel, attributes);
                                }
                                else
                                {
                                    rectangle = new Rectangle(Conversions.ToInteger(Operators.AddObject(obj7, (num8 - image14.Width) / 2f)), Conversions.ToInteger(Operators.AddObject(obj8, num7 / 2f)), image14.Width, image14.Height);
                                    graphics.DrawImage(image14, rectangle, 0f, 0f, (float) image14.Width, (float) image14.Height, GraphicsUnit.Pixel, attributes);
                                }
                            }
                        }
                        else
                        {
                            using (Image image15 = Image.FromFile(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif")))
                            {
                                if (!obj.MessageShow)
                                {
                                    rectangle = new Rectangle(Conversions.ToInteger(Operators.AddObject(obj7, (num8 - image15.Width) / 2f)), Conversions.ToInteger(Operators.AddObject(obj8, (num7 - image15.Height) / 2f)), (int) Math.Round((double) image15.Width), (int) Math.Round((double) image15.Height));
                                    graphics.DrawImage(image15, rectangle, 0f, 0f, (float) image15.Width, (float) image15.Height, GraphicsUnit.Pixel, attributes);
                                }
                                else
                                {
                                    rectangle = new Rectangle(Conversions.ToInteger(Operators.AddObject(obj7, (num8 - image15.Width) / 2f)), Conversions.ToInteger(Operators.AddObject(obj8, num7 / 2f)), image15.Width, image15.Height);
                                    graphics.DrawImage(image15, rectangle, 0f, 0f, (float) image15.Width, (float) image15.Height, GraphicsUnit.Pixel, attributes);
                                }
                            }
                        }
                    }
                Label_261D:
                    if (obj.MessageShow)
                    {
                        RectangleF ef6;
                        string str11 = obj.Personalize1;
                        if (Conversions.ToDouble(obj.CompanyID) == 3.0)
                        {
                            object obj9;
                            float num22 = width - TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType);
                            if (obj.CardLayout == "H")
                            {
                                obj9 = height - TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                            }
                            else
                            {
                                obj9 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                            }
                            ef6 = new RectangleF(num22, Conversions.ToSingle(obj9), num8, num7 / 2f);
                        }
                        else if (Conversions.ToDouble(obj.CompanyID) == 2.0)
                        {
                            ef6 = new RectangleF(TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType), TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType), num8, num7 / 2f);
                        }
                        using (PrivateFontCollection fonts3 = new PrivateFontCollection())
                        {
                            DirectoryInfo info3 = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/"));
                            string str12 = obj.MessageTypeStyle;
                            if (info3.Exists)
                            {
                                FileInfo[] infoArray9 = info3.GetFiles();
                                for (int k = 0; k < infoArray9.Length; k++)
                                {
                                    object obj10 = infoArray9[k];
                                    fonts3.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + obj10.ToString());
                                    if (fonts3.Families[fonts3.Families.Count<FontFamily>() - 1].Name == str12)
                                    {
                                        fonts3.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + obj10.ToString());
                                        break;
                                    }
                                }
                                info3 = null;
                            }
                            using (Font font3 = new Font(fonts3.Families[fonts3.Families.Count<FontFamily>() - 1], Convert.ToSingle(obj.MessageFontSize)))
                            {
                                using (SolidBrush brush3 = new SolidBrush(color))
                                {
                                    using (StringFormat format3 = new StringFormat())
                                    {
                                        if ((Conversions.ToString(obj.TextAlignmentX) == "T") & (Conversions.ToString(obj.TextAlignmentY) == "C"))
                                        {
                                            format3.Alignment = StringAlignment.Center;
                                            format3.LineAlignment = StringAlignment.Near;
                                            format3.Trimming = StringTrimming.Character;
                                        }
                                        else
                                        {
                                            format3.Alignment = StringAlignment.Center;
                                            format3.LineAlignment = StringAlignment.Center;
                                            format3.Trimming = StringTrimming.Character;
                                        }
                                        graphics.DrawString(str11, font3, brush3, ef6, format3);
                                    }
                                }
                            }
                        }
                    }
                Label_29C0:
                    if (obj.CardLogoLocation != "Above")
                    {
                        goto Label_478F;
                    }
                    if (!((!(TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.IconLeft, 1440M)), obj.ResolutionType) == TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType)) & !(TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.IconTop, 1440M)), obj.ResolutionType) == TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType))) & (Conversions.ToDouble(obj.CompanyID) == 3.0)))
                    {
                        goto Label_369F;
                    }
                    string str13 = HttpContext.Current.Server.MapPath("~/Order/OrderLogos/Card/" + obj.LogoName);
                    using (Image image16 = Image.FromFile(str13))
                    {
                        object obj11;
                        double num26;
                        double num27;
                        float num24 = TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.IconWidth, 1440M)), obj.ResolutionType);
                        float num23 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.IconHeight, 1440M)), obj.ResolutionType);
                        float num25 = width - TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.IconLeft, 1440M)), obj.ResolutionType);
                        if (obj.CardLayout == "H")
                        {
                            obj11 = height - TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.IconTop, 1440M)), obj.ResolutionType);
                        }
                        else
                        {
                            obj11 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.IconTop, 1440M)), obj.ResolutionType);
                        }
                        RectangleF ef7 = new RectangleF(num25, Conversions.ToSingle(obj11), num24, num23);
                        if (!(image16.HorizontalResolution == 600f) | !(image16.VerticalResolution == 600f))
                        {
                            using (MemoryStream stream3 = new MemoryStream(ConvertImageToByteArray(image16)))
                            {
                                using (Image image17 = Image.FromStream(stream3))
                                {
                                    using (Image image18 = SetResolution(image17, 600))
                                    {
                                        if ((image18.Width > num24) & (image18.Height > num23))
                                        {
                                            num26 = num24 / ((float) image18.Width);
                                            num27 = num23 / ((float) image18.Height);
                                        }
                                        else if ((image18.Width > num24) & (image18.Height < num23))
                                        {
                                            num26 = num24 / ((float) image18.Width);
                                            num27 = 1.0;
                                        }
                                        else if ((image18.Width < num24) & (image18.Height > num23))
                                        {
                                            num26 = 1.0;
                                            num27 = num23 / ((float) image18.Height);
                                        }
                                        else
                                        {
                                            num26 = 1.0;
                                            num27 = 1.0;
                                        }
                                        if (!(num26 == 1.0) | !(num27 == 1.0))
                                        {
                                            ResizeImage(image18, num26, num27, HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif"));
                                        }
                                        if ((num26 == 1.0) & (num27 == 1.0))
                                        {
                                            using (Image image19 = image18)
                                            {
                                                rectangle = new Rectangle((int) Math.Round((double) (num25 + ((num24 - image19.Width) / 2f))), Conversions.ToInteger(Operators.AddObject(obj11, (num23 - image19.Height) / 2f)), image19.Width, image19.Height);
                                                graphics.DrawImage(image19, rectangle, 0f, 0f, (float) image19.Width, (float) image19.Height, GraphicsUnit.Pixel, attributes);
                                            }
                                        }
                                        else
                                        {
                                            using (Image image20 = Image.FromFile(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif")))
                                            {
                                                rectangle = new Rectangle((int) Math.Round((double) (num25 + ((num24 - image20.Width) / 2f))), Conversions.ToInteger(Operators.AddObject(obj11, (num23 - image20.Height) / 2f)), image20.Width, image20.Height);
                                                graphics.DrawImage(image20, rectangle, 0f, 0f, (float) image20.Width, (float) image20.Height, GraphicsUnit.Pixel, attributes);
                                            }
                                        }
                                    }
                                    goto Label_3329;
                                }
                            }
                        }
                        if ((image16.Width > num24) & (image16.Height > num23))
                        {
                            num26 = num24 / ((float) image16.Width);
                            num27 = num23 / ((float) image16.Height);
                        }
                        else if ((image16.Width > num24) & (image16.Height < num23))
                        {
                            num26 = num24 / ((float) image16.Width);
                            num27 = 1.0;
                        }
                        else if ((image16.Width < num24) & (image16.Height > num23))
                        {
                            num26 = 1.0;
                            num27 = num23 / ((float) image16.Height);
                        }
                        else
                        {
                            num26 = 1.0;
                            num27 = 1.0;
                        }
                        if (!(num26 == 1.0) | !(num27 == 1.0))
                        {
                            ResizeImage(image16, num26, num27, HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif"));
                        }
                        if ((num26 == 1.0) & (num27 == 1.0))
                        {
                            using (Image image21 = image16)
                            {
                                rectangle = new Rectangle((int) Math.Round((double) (num25 + ((num24 - image21.Width) / 2f))), Conversions.ToInteger(Operators.AddObject(obj11, (num23 - image21.Height) / 2f)), image21.Width, image21.Height);
                                graphics.DrawImage(image21, rectangle, 0f, 0f, (float) image21.Width, (float) image21.Height, GraphicsUnit.Pixel, attributes);
                            }
                        }
                        else
                        {
                            using (Image image22 = Image.FromFile(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif")))
                            {
                                rectangle = new Rectangle((int) Math.Round((double) (num25 + ((num24 - image22.Width) / 2f))), Conversions.ToInteger(Operators.AddObject(obj11, (num23 - image22.Height) / 2f)), image22.Width, image22.Height);
                                graphics.DrawImage(image22, rectangle, 0f, 0f, (float) image22.Width, (float) image22.Height, GraphicsUnit.Pixel, attributes);
                            }
                        }
                    }
                Label_3329:
                    if (obj.MessageShow)
                    {
                        RectangleF ef8;
                        string str14 = obj.Personalize1 + Environment.NewLine + obj.Personalize2 + Environment.NewLine + obj.Personalize3 + Environment.NewLine + obj.Personalize4;
                        if (Conversions.ToDouble(obj.CompanyID) == 3.0)
                        {
                            object obj12;
                            float num28 = width - TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType);
                            if (obj.CardLayout == "H")
                            {
                                obj12 = height - TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                            }
                            else
                            {
                                obj12 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                            }
                            ef8 = new RectangleF(num28, Conversions.ToSingle(obj12), num8, num7);
                        }
                        using (PrivateFontCollection fonts4 = new PrivateFontCollection())
                        {
                            DirectoryInfo info4 = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/"));
                            string str15 = obj.MessageTypeStyle;
                            if (info4.Exists)
                            {
                                FileInfo[] infoArray10 = info4.GetFiles();
                                for (int m = 0; m < infoArray10.Length; m++)
                                {
                                    object obj13 = infoArray10[m];
                                    fonts4.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + obj13.ToString());
                                    if (fonts4.Families[fonts4.Families.Count<FontFamily>() - 1].Name == str15)
                                    {
                                        fonts4.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + obj13.ToString());
                                        break;
                                    }
                                }
                                info4 = null;
                            }
                            using (Font font4 = new Font(fonts4.Families[fonts4.Families.Count<FontFamily>() - 1], Convert.ToSingle(obj.MessageFontSize)))
                            {
                                using (StringFormat format4 = new StringFormat())
                                {
                                    using (SolidBrush brush4 = new SolidBrush(color))
                                    {
                                        if ((Conversions.ToString(obj.TextAlignmentX) == "T") & (Conversions.ToString(obj.TextAlignmentY) == "C"))
                                        {
                                            format4.Alignment = StringAlignment.Center;
                                            format4.LineAlignment = StringAlignment.Near;
                                            format4.Trimming = StringTrimming.Character;
                                        }
                                        else
                                        {
                                            format4.Alignment = StringAlignment.Center;
                                            format4.LineAlignment = StringAlignment.Center;
                                            format4.Trimming = StringTrimming.Character;
                                        }
                                        graphics.DrawString(str14, font4, brush4, ef8, format4);
                                    }
                                }
                            }
                        }
                    }
                    goto Label_478F;
                Label_369F:
                    str16 = HttpContext.Current.Server.MapPath("~/Order/OrderLogos/Card/" + obj.LogoName);
                    using (Image image23 = Image.FromFile(str16))
                    {
                        object obj14;
                        object obj15;
                        double num29;
                        double num30;
                        if (Conversions.ToDouble(obj.CompanyID) == 2.0)
                        {
                            obj14 = TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType);
                            obj15 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                        }
                        else if (Conversions.ToDouble(obj.CompanyID) == 3.0)
                        {
                            obj14 = width - TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType);
                            if (obj.CardLayout == "H")
                            {
                                obj15 = height - TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                            }
                            else
                            {
                                obj15 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                            }
                        }
                        RectangleF ef9 = new RectangleF(Conversions.ToSingle(obj14), Conversions.ToSingle(obj15), num8, num7);
                        if (!(image23.HorizontalResolution == 600f) | !(image23.VerticalResolution == 600f))
                        {
                            using (MemoryStream stream4 = new MemoryStream(ConvertImageToByteArray(image23)))
                            {
                                using (Image image24 = Image.FromStream(stream4))
                                {
                                    using (Image image25 = SetResolution(image24, 600))
                                    {
                                        if (obj.MessageShow)
                                        {
                                            if ((image25.Width > num8) & (image25.Height > (num7 / 2f)))
                                            {
                                                num29 = num8 / ((float) image25.Width);
                                                num30 = (num7 / 2f) / ((float) image25.Height);
                                            }
                                            else if ((image25.Width > num8) & (image25.Height < (num7 / 2f)))
                                            {
                                                num29 = num8 / ((float) image25.Width);
                                                num30 = 1.0;
                                            }
                                            else if ((image25.Width < num8) & (image25.Height > (num7 / 2f)))
                                            {
                                                num29 = 1.0;
                                                num30 = (num7 / 2f) / ((float) image25.Height);
                                            }
                                            else
                                            {
                                                num29 = 1.0;
                                                num30 = 1.0;
                                            }
                                        }
                                        else if ((image25.Width > num8) & (image25.Height > num7))
                                        {
                                            num29 = num8 / ((float) image25.Width);
                                            num30 = num7 / ((float) image25.Height);
                                        }
                                        else if ((image25.Width > num8) & (image25.Height < num7))
                                        {
                                            num29 = num8 / ((float) image25.Width);
                                            num30 = 1.0;
                                        }
                                        else if ((image25.Width < num8) & (image25.Height > num7))
                                        {
                                            num29 = 1.0;
                                            num30 = num7 / ((float) image25.Height);
                                        }
                                        else
                                        {
                                            num29 = 1.0;
                                            num30 = 1.0;
                                        }
                                        if (!(num29 == 1.0) | !(num30 == 1.0))
                                        {
                                            ResizeImage(image25, num29, num30, HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif"));
                                        }
                                        if ((num29 == 1.0) & (num30 == 1.0))
                                        {
                                            using (Image image26 = image25)
                                            {
                                                if (!obj.MessageShow)
                                                {
                                                    rectangle = new Rectangle(Conversions.ToInteger(Operators.AddObject(obj14, (num8 - image26.Width) / 2f)), Conversions.ToInteger(Operators.AddObject(obj15, (num7 - image26.Height) / 2f)), (int) Math.Round((double) image26.Width), (int) Math.Round((double) image26.Height));
                                                    graphics.DrawImage(image26, rectangle, 0f, 0f, (float) image26.Width, (float) image26.Height, GraphicsUnit.Pixel, attributes);
                                                }
                                                else
                                                {
                                                    rectangle = new Rectangle(Conversions.ToInteger(Operators.AddObject(obj14, (num8 - image26.Width) / 2f)), Conversions.ToInteger(obj15), image26.Width, image26.Height);
                                                    graphics.DrawImage(image26, rectangle, 0f, 0f, (float) image26.Width, (float) image26.Height, GraphicsUnit.Pixel, attributes);
                                                }
                                            }
                                            goto Label_43CD;
                                        }
                                        using (Image image27 = Image.FromFile(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif")))
                                        {
                                            if (!obj.MessageShow)
                                            {
                                                rectangle = new Rectangle(Conversions.ToInteger(Operators.AddObject(obj14, (num8 - image27.Width) / 2f)), Conversions.ToInteger(Operators.AddObject(obj15, (num7 - image27.Height) / 2f)), (int) Math.Round((double) image27.Width), (int) Math.Round((double) image27.Height));
                                                graphics.DrawImage(image27, rectangle, 0f, 0f, (float) image27.Width, (float) image27.Height, GraphicsUnit.Pixel, attributes);
                                            }
                                            else
                                            {
                                                rectangle = new Rectangle(Conversions.ToInteger(Operators.AddObject(obj14, (num8 - image27.Width) / 2f)), Conversions.ToInteger(obj15), image27.Width, image27.Height);
                                                graphics.DrawImage(image27, rectangle, 0f, 0f, (float) image27.Width, (float) image27.Height, GraphicsUnit.Pixel, attributes);
                                            }
                                            goto Label_43CD;
                                        }
                                    }
                                }
                            }
                        }
                        if (obj.MessageShow)
                        {
                            if ((image23.Width > num8) & (image23.Height > (num7 / 2f)))
                            {
                                num29 = num8 / ((float) image23.Width);
                                num30 = (num7 / 2f) / ((float) image23.Height);
                            }
                            else if ((image23.Width > num8) & (image23.Height < (num7 / 2f)))
                            {
                                num29 = num8 / ((float) image23.Width);
                                num30 = 1.0;
                            }
                            else if ((image23.Width < num8) & (image23.Height > (num7 / 2f)))
                            {
                                num29 = 1.0;
                                num30 = (num7 / 2f) / ((float) image23.Height);
                            }
                            else
                            {
                                num29 = 1.0;
                                num30 = 1.0;
                            }
                        }
                        else if ((image23.Width > num8) & (image23.Height > num7))
                        {
                            num29 = num8 / ((float) image23.Width);
                            num30 = num7 / ((float) image23.Height);
                        }
                        else if ((image23.Width > num8) & (image23.Height < num7))
                        {
                            num29 = num8 / ((float) image23.Width);
                            num30 = 1.0;
                        }
                        else if ((image23.Width < num8) & (image23.Height > num7))
                        {
                            num29 = 1.0;
                            num30 = num7 / ((float) image23.Height);
                        }
                        else
                        {
                            num29 = 1.0;
                            num30 = 1.0;
                        }
                        if (!(num29 == 1.0) | !(num30 == 1.0))
                        {
                            ResizeImage(image23, num29, num30, HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif"));
                        }
                        if ((num29 == 1.0) & (num30 == 1.0))
                        {
                            using (Image image28 = image23)
                            {
                                if (!obj.MessageShow)
                                {
                                    rectangle = new Rectangle(Conversions.ToInteger(Operators.AddObject(obj14, (num8 - image28.Width) / 2f)), Conversions.ToInteger(Operators.AddObject(obj15, (num7 - image28.Height) / 2f)), (int) Math.Round((double) image28.Width), (int) Math.Round((double) image28.Height));
                                    graphics.DrawImage(image28, rectangle, 0f, 0f, (float) image28.Width, (float) image28.Height, GraphicsUnit.Pixel, attributes);
                                }
                                else
                                {
                                    rectangle = new Rectangle(Conversions.ToInteger(Operators.AddObject(obj14, (num8 - image28.Width) / 2f)), Conversions.ToInteger(obj15), image28.Width, image28.Height);
                                    graphics.DrawImage(image28, rectangle, 0f, 0f, (float) image28.Width, (float) image28.Height, GraphicsUnit.Pixel, attributes);
                                }
                            }
                        }
                        else
                        {
                            using (Image image29 = Image.FromFile(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif")))
                            {
                                if (!obj.MessageShow)
                                {
                                    rectangle = new Rectangle(Conversions.ToInteger(Operators.AddObject(obj14, (num8 - image29.Width) / 2f)), Conversions.ToInteger(Operators.AddObject(obj15, (num7 - image29.Height) / 2f)), (int) Math.Round((double) image29.Width), (int) Math.Round((double) image29.Height));
                                    graphics.DrawImage(image29, rectangle, 0f, 0f, (float) image29.Width, (float) image29.Height, GraphicsUnit.Pixel, attributes);
                                }
                                else
                                {
                                    rectangle = new Rectangle(Conversions.ToInteger(Operators.AddObject(obj14, (num8 - image29.Width) / 2f)), Conversions.ToInteger(obj15), image29.Width, image29.Height);
                                    graphics.DrawImage(image29, rectangle, 0f, 0f, (float) image29.Width, (float) image29.Height, GraphicsUnit.Pixel, attributes);
                                }
                            }
                        }
                    }
                Label_43CD:
                    if (obj.MessageShow)
                    {
                        RectangleF ef10;
                        string str17 = obj.Personalize1;
                        if (Conversions.ToDouble(obj.CompanyID) == 3.0)
                        {
                            object obj16;
                            float num31 = width - TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType);
                            if (obj.CardLayout == "H")
                            {
                                obj16 = height - TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                            }
                            else
                            {
                                obj16 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                            }
                            ef10 = new RectangleF(num31, Conversions.ToSingle(Operators.AddObject(obj16, num7 / 2f)), num8, num7 / 2f);
                        }
                        else if (Conversions.ToDouble(obj.CompanyID) == 2.0)
                        {
                            ef10 = new RectangleF(TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType), TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType) + (num7 / 2f), num8, num7 / 2f);
                        }
                        using (StringFormat format5 = new StringFormat())
                        {
                            if ((Conversions.ToString(obj.TextAlignmentX) == "T") & (Conversions.ToString(obj.TextAlignmentY) == "C"))
                            {
                                format5.Alignment = StringAlignment.Center;
                                format5.LineAlignment = StringAlignment.Near;
                                format5.Trimming = StringTrimming.Character;
                            }
                            else
                            {
                                format5.Alignment = StringAlignment.Center;
                                format5.LineAlignment = StringAlignment.Center;
                                format5.Trimming = StringTrimming.Character;
                            }
                            using (PrivateFontCollection fonts5 = new PrivateFontCollection())
                            {
                                DirectoryInfo info5 = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/"));
                                string str18 = obj.MessageTypeStyle;
                                if (info5.Exists)
                                {
                                    FileInfo[] infoArray11 = info5.GetFiles();
                                    for (int n = 0; n < infoArray11.Length; n++)
                                    {
                                        object obj17 = infoArray11[n];
                                        fonts5.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + obj17.ToString());
                                        if (fonts5.Families[fonts5.Families.Count<FontFamily>() - 1].Name == str18)
                                        {
                                            fonts5.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + obj17.ToString());
                                            break;
                                        }
                                    }
                                    info5 = null;
                                }
                                using (Font font5 = new Font(fonts5.Families[fonts5.Families.Count<FontFamily>() - 1], Convert.ToSingle(obj.MessageFontSize)))
                                {
                                    using (SolidBrush brush5 = new SolidBrush(color))
                                    {
                                        graphics.DrawString(str17, font5, brush5, ef10, format5);
                                    }
                                }
                            }
                        }
                    }
                Label_478F:
                    if (obj.MessageShow & !obj.LogoShow)
                    {
                        string str19 = obj.Personalize1 + Environment.NewLine + obj.Personalize2 + Environment.NewLine + obj.Personalize3 + Environment.NewLine + obj.Personalize4;
                        using (StringFormat format6 = new StringFormat())
                        {
                            RectangleF ef11;
                            if (Conversions.ToDouble(obj.CompanyID) == 3.0)
                            {
                                object obj18;
                                float num32 = width - TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType);
                                if (obj.CardLayout == "H")
                                {
                                    obj18 = height - TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                                }
                                else
                                {
                                    obj18 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                                }
                                ef11 = new RectangleF(num32, Conversions.ToSingle(obj18), num8, num7);
                                if ((Conversions.ToString(obj.TextAlignmentX) == "T") & (Conversions.ToString(obj.TextAlignmentY) == "C"))
                                {
                                    format6.Alignment = StringAlignment.Center;
                                    format6.LineAlignment = StringAlignment.Near;
                                    format6.Trimming = StringTrimming.Character;
                                }
                                else
                                {
                                    format6.Alignment = StringAlignment.Center;
                                    format6.LineAlignment = StringAlignment.Center;
                                    format6.Trimming = StringTrimming.Character;
                                }
                            }
                            else if (Conversions.ToDouble(obj.CompanyID) == 2.0)
                            {
                                ef11 = new RectangleF(TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType), TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType), num8, num7);
                                format6.Alignment = StringAlignment.Center;
                                format6.LineAlignment = StringAlignment.Near;
                                format6.Trimming = StringTrimming.Character;
                            }
                            using (PrivateFontCollection fonts6 = new PrivateFontCollection())
                            {
                                DirectoryInfo info6 = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/"));
                                string str20 = obj.MessageTypeStyle;
                                if (info6.Exists)
                                {
                                    FileInfo[] infoArray12 = info6.GetFiles();
                                    for (int num38 = 0; num38 < infoArray12.Length; num38++)
                                    {
                                        object obj19 = infoArray12[num38];
                                        fonts6.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + obj19.ToString());
                                        if (fonts6.Families[fonts6.Families.Count<FontFamily>() - 1].Name == str20)
                                        {
                                            fonts6.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + obj19.ToString());
                                            break;
                                        }
                                    }
                                    info6 = null;
                                }
                                using (Font font6 = new Font(fonts6.Families[fonts6.Families.Count<FontFamily>() - 1], Convert.ToSingle(obj.MessageFontSize)))
                                {
                                    using (SolidBrush brush6 = new SolidBrush(color))
                                    {
                                        graphics.DrawString(str19, font6, brush6, ef11, format6);
                                    }
                                }
                            }
                        }
                    }
                    string str5 = HttpContext.Current.Server.MapPath("~/ProofingTool/Production Files/" + str + ".tif");
                    using (EncoderParameters parameters = new EncoderParameters(2))
                    {
                        parameters.Param[0] = new EncoderParameter(Encoder.ColorDepth, 8L);
                        parameters.Param[1] = new EncoderParameter(Encoder.Compression, 2L);
                        bitmap.Save(str5, GetEncoderInfo("image/tiff"), parameters);
                    }
                    Process process = new Process();
                    Process process2 = process;
                    try
                    {
                        process2.StartInfo.FileName = HttpContext.Current.Server.MapPath("~/Bin/GetGrayScaleProof.exe");
                        process2.StartInfo.Arguments = " \"" + str5 + "\" \"" + HttpContext.Current.Server.MapPath("~/ProofingTool/Production Files/" + str3 + ".tif") + "\"";
                        process2.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                        process2.StartInfo.CreateNoWindow = true;
                        process2.Start();
                        process2.WaitForExit(0xbb8);
                        process2.Kill();
                        process2.Dispose();
                    }
                    catch (Exception exception1)
                    {
                        ProjectData.SetProjectError(exception1);
                        Exception exception = exception1;
                        process2.Kill();
                        process2.Dispose();
                        ProjectData.ClearProjectError();
                    }
                    process2 = null;
                }
            }
        }
    }
    catch (Exception exception3)
    {
        ProjectData.SetProjectError(exception3);
        Exception exception2 = exception3;
        if ((!string.IsNullOrEmpty(obj.LogoName) & !string.IsNullOrEmpty(obj.SessionID)) && File.Exists(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif")))
        {
            File.Delete(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif"));
        }
        GC.Collect();
        ProjectData.ClearProjectError();
    }
    finally
    {
        if ((!string.IsNullOrEmpty(obj.LogoName) & !string.IsNullOrEmpty(obj.SessionID)) && File.Exists(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif")))
        {
            File.Delete(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif"));
        }
    }
    return string.Format("{0}|{1}", str3, str);
}

 

 
End

public static void CreateCardLowProof(Hammond obj)
{
    try
    {
        float num7;
        float num8;
        float num9;
        float num10;
        string str = obj.CardSize.Replace("X", "x").Replace("\"", "");
        if (str.Substring(0, str.IndexOf("x") - 1).Contains("/"))
        {
            string[] strArray = str.Substring(0, str.IndexOf("x") - 1).Split(new char[] { ' ' });
            num7 = Conversions.ToSingle(strArray[0]);
            string[] strArray2 = strArray[1].Split(new char[] { '/' });
            num8 = Conversions.ToSingle(strArray2[0]) / Conversions.ToSingle(strArray2[1]);
        }
        else
        {
            num7 = Conversions.ToSingle(str.Substring(0, str.IndexOf("x") - 1).Trim());
            num8 = 0f;
        }
        if (str.Substring(str.IndexOf("x") + 2).Contains("/"))
        {
            string[] strArray3 = str.Substring(str.IndexOf("x") + 2).Split(new char[] { ' ' });
            num9 = Conversions.ToSingle(strArray3[0]);
            string[] strArray4 = strArray3[1].Split(new char[] { '/' });
            num10 = Conversions.ToSingle(strArray4[0]) / Conversions.ToSingle(strArray4[1]);
        }
        else
        {
            num9 = Conversions.ToSingle(str.Substring(str.IndexOf("x") + 2).Trim());
            num10 = 0f;
        }
        int width = (int) Math.Round((double) TwipsToPixelsX(Convert.ToSingle((float) ((num7 + num8) * 1440f)), obj.ResolutionType));
        int height = (int) Math.Round((double) TwipsToPixelsY(Convert.ToSingle((float) ((num9 + num10) * 1440f)), obj.ResolutionType));
        float num6 = TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.VerseWidth, 1440M)), obj.ResolutionType);
        float num5 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.VerseHeight, 1440M)), obj.ResolutionType);
        float num4 = TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextWidth, 1440M)), obj.ResolutionType);
        float num3 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextHeight, 1440M)), obj.ResolutionType);
        using (Bitmap bitmap = new Bitmap(width, height))
        {
            using (Graphics graphics = Graphics.FromImage(bitmap))
            {
                Rectangle rectangle;
                Color color = Color.FromName(obj.ImprintInk);
                graphics.Clear(Color.White);
                graphics.SmoothingMode = SmoothingMode.HighQuality;
                graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
                graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                if (obj.VerseType == "Standard")
                {
                    ChangeImageColor(obj);
                    using (Image image = Image.FromFile(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_verse.tif")))
                    {
                        float num11;
                        float num12;
                        RectangleF ef;
                        if (Conversions.ToDouble(obj.CompanyID) == 3.0)
                        {
                            num11 = width - TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.VerseLeft, 1440M)), obj.ResolutionType);
                            if (obj.CardLayout == "H")
                            {
                                num12 = height - TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.VerseTop, 1440M)), obj.ResolutionType);
                            }
                            else
                            {
                                num12 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.VerseTop, 1440M)), obj.ResolutionType);
                            }
                            ef = new RectangleF(num11, num12, num6, num5);
                        }
                        else if (Conversions.ToDouble(obj.CompanyID) == 2.0)
                        {
                            rectangle = new Rectangle((int) Math.Round((double) TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.VerseLeft, 1440M)), obj.ResolutionType)), (int) Math.Round((double) TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.VerseTop, 1440M)), obj.ResolutionType)), (int) Math.Round((double) num6), (int) Math.Round((double) num5));
                            ef = rectangle;
                            num11 = TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.VerseLeft, 1440M)), obj.ResolutionType);
                            num12 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.VerseTop, 1440M)), obj.ResolutionType);
                        }
                        if ((Conversions.ToString(obj.VerseAlignmentX) == "T") & (Conversions.ToString(obj.VerseAlignmentY) == "C"))
                        {
                            graphics.DrawImage(image, num11 + ((num6 - image.Width) / 2f), num12, (float) image.Width, (float) image.Height);
                        }
                        else
                        {
                            graphics.DrawImage(image, num11 + ((num6 - image.Width) / 2f), num12 + ((num5 - image.Height) / 2f), (float) image.Width, (float) image.Height);
                        }
                    }
                }
                else if (obj.VerseType == "Custom")
                {
                    RectangleF ef2;
                    if (Conversions.ToDouble(obj.CompanyID) == 3.0)
                    {
                        object obj2;
                        float x = width - TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.VerseLeft, 1440M)), obj.ResolutionType);
                        if (obj.CardLayout == "H")
                        {
                            obj2 = height - TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.VerseTop, 1440M)), obj.ResolutionType);
                        }
                        else
                        {
                            obj2 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.VerseTop, 1440M)), obj.ResolutionType);
                        }
                        ef2 = new RectangleF(x, Conversions.ToSingle(obj2), num6, num5);
                    }
                    else if (Conversions.ToDouble(obj.CompanyID) == 2.0)
                    {
                        rectangle = new Rectangle((int) Math.Round((double) TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.VerseLeft, 1440M)), obj.ResolutionType)), (int) Math.Round((double) TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.VerseTop, 1440M)), obj.ResolutionType)), (int) Math.Round((double) num6), (int) Math.Round((double) num5));
                        ef2 = rectangle;
                    }
                    string typeStyle = obj.TypeStyle;
                    using (PrivateFontCollection fonts = new PrivateFontCollection())
                    {
                        DirectoryInfo info = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/"));
                        if (info.Exists)
                        {
                            FileInfo[] files = info.GetFiles();
                            for (int i = 0; i < files.Length; i++)
                            {
                                object obj3 = files[i];
                                fonts.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + obj3.ToString());
                                if (fonts.Families[fonts.Families.Count<FontFamily>() - 1].Name == typeStyle)
                                {
                                    fonts.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + obj3.ToString());
                                    break;
                                }
                            }
                            info = null;
                        }
                        using (Font font = new Font(fonts.Families[fonts.Families.Count<FontFamily>() - 1], Convert.ToSingle(obj.VerseFontSize)))
                        {
                            using (SolidBrush brush = new SolidBrush(color))
                            {
                                using (StringFormat format = new StringFormat())
                                {
                                    if ((Conversions.ToString(obj.VerseAlignmentX) == "T") & (Conversions.ToString(obj.VerseAlignmentY) == "C"))
                                    {
                                        format.Alignment = StringAlignment.Center;
                                        format.LineAlignment = StringAlignment.Near;
                                        format.Trimming = StringTrimming.Character;
                                        graphics.DrawString(obj.CustomVerseText, font, brush, ef2, format);
                                    }
                                    else
                                    {
                                        format.Alignment = StringAlignment.Center;
                                        format.LineAlignment = StringAlignment.Center;
                                        format.Trimming = StringTrimming.Character;
                                        graphics.DrawString(obj.CustomVerseText, font, brush, ef2, format);
                                    }
                                }
                            }
                        }
                    }
                }
                if (obj.LogoShow)
                {
                    if (obj.CardLogoLocation == "Below")
                    {
                        if ((!(TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.IconLeft, 1440M)), obj.ResolutionType) == TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType)) & !(TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.IconTop, 1440M)), obj.ResolutionType) == TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType))) & (Conversions.ToDouble(obj.CompanyID) == 3.0))
                        {
                            string str4 = HttpContext.Current.Server.MapPath("~/Order/OrderLogos/Card/" + obj.LogoName);
                            using (Image image2 = Image.FromFile(str4))
                            {
                                object obj4;
                                double num17;
                                double num18;
                                float num15 = TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.IconWidth, 1440M)), obj.ResolutionType);
                                float num14 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.IconHeight, 1440M)), obj.ResolutionType);
                                float num16 = width - TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.IconLeft, 1440M)), obj.ResolutionType);
                                if (obj.CardLayout == "H")
                                {
                                    obj4 = height - TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.IconTop, 1440M)), obj.ResolutionType);
                                }
                                else
                                {
                                    obj4 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.IconTop, 1440M)), obj.ResolutionType);
                                }
                                RectangleF ef3 = new RectangleF(num16, Conversions.ToSingle(obj4), num15, num14);
                                if ((image2.Width > num15) & (image2.Height > num14))
                                {
                                    num17 = num15 / ((float) image2.Width);
                                    num18 = num14 / ((float) image2.Height);
                                }
                                else if ((image2.Width > num15) & (image2.Height < num14))
                                {
                                    num17 = num15 / ((float) image2.Width);
                                    num18 = 1.0;
                                }
                                else if ((image2.Width < num15) & (image2.Height > num14))
                                {
                                    num17 = 1.0;
                                    num18 = num14 / ((float) image2.Height);
                                }
                                else
                                {
                                    num17 = 1.0;
                                    num18 = 1.0;
                                }
                                if (!(num17 == 1.0) | !(num18 == 1.0))
                                {
                                    ResizeImage(image2, num17, num18, HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif"));
                                }
                                if ((num17 == 1.0) & (num18 == 1.0))
                                {
                                    using (Image image3 = image2)
                                    {
                                        graphics.DrawImage(image3, num16 + ((num15 - image3.Width) / 2f), Conversions.ToSingle(Operators.AddObject(obj4, (num14 - image3.Height) / 2f)), (float) image3.Width, (float) image3.Height);
                                    }
                                }
                                else
                                {
                                    using (Image image4 = Image.FromFile(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif")))
                                    {
                                        graphics.DrawImage(image4, num16 + ((num15 - image4.Width) / 2f), Conversions.ToSingle(Operators.AddObject(obj4, (num14 - image4.Height) / 2f)), (float) image4.Width, (float) image4.Height);
                                    }
                                }
                            }
                            if (obj.MessageShow)
                            {
                                RectangleF ef4;
                                string s = obj.Personalize1 + Environment.NewLine + obj.Personalize2 + Environment.NewLine + obj.Personalize3 + Environment.NewLine + obj.Personalize4;
                                if (Conversions.ToDouble(obj.CompanyID) == 3.0)
                                {
                                    object obj5;
                                    float num19 = width - TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType);
                                    if (obj.CardLayout == "H")
                                    {
                                        obj5 = height - TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                                    }
                                    else
                                    {
                                        obj5 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                                    }
                                    ef4 = new RectangleF(num19, Conversions.ToSingle(obj5), num4, num3);
                                }
                                if (obj.MessageShow)
                                {
                                    using (SolidBrush brush2 = new SolidBrush(color))
                                    {
                                        using (StringFormat format2 = new StringFormat())
                                        {
                                            if ((Conversions.ToString(obj.TextAlignmentX) == "T") & (Conversions.ToString(obj.TextAlignmentY) == "C"))
                                            {
                                                format2.Alignment = StringAlignment.Center;
                                                format2.LineAlignment = StringAlignment.Near;
                                                format2.Trimming = StringTrimming.Character;
                                            }
                                            else
                                            {
                                                format2.Alignment = StringAlignment.Center;
                                                format2.LineAlignment = StringAlignment.Center;
                                                format2.Trimming = StringTrimming.Character;
                                            }
                                            using (PrivateFontCollection fonts2 = new PrivateFontCollection())
                                            {
                                                DirectoryInfo info2 = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/"));
                                                string messageTypeStyle = obj.MessageTypeStyle;
                                                if (info2.Exists)
                                                {
                                                    FileInfo[] infoArray8 = info2.GetFiles();
                                                    for (int j = 0; j < infoArray8.Length; j++)
                                                    {
                                                        object obj6 = infoArray8[j];
                                                        fonts2.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + obj6.ToString());
                                                        if (fonts2.Families[fonts2.Families.Count<FontFamily>() - 1].Name == messageTypeStyle)
                                                        {
                                                            fonts2.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + obj6.ToString());
                                                            break;
                                                        }
                                                    }
                                                    info2 = null;
                                                }
                                                using (Font font2 = new Font(fonts2.Families[fonts2.Families.Count<FontFamily>() - 1], Convert.ToSingle(obj.MessageFontSize)))
                                                {
                                                    graphics.DrawString(s, font2, brush2, ef4, format2);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            string str7 = HttpContext.Current.Server.MapPath("~/Order/OrderLogos/Card/" + obj.LogoName);
                            using (Image image5 = Image.FromFile(str7))
                            {
                                object obj7;
                                object obj8;
                                double num20;
                                double num21;
                                if (Conversions.ToDouble(obj.CompanyID) == 2.0)
                                {
                                    obj7 = TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType);
                                    obj8 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                                }
                                else if (Conversions.ToDouble(obj.CompanyID) == 3.0)
                                {
                                    obj7 = width - TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType);
                                    if (obj.CardLayout == "H")
                                    {
                                        obj8 = height - TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                                    }
                                    else
                                    {
                                        obj8 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                                    }
                                }
                                RectangleF ef5 = new RectangleF(Conversions.ToSingle(obj7), Conversions.ToSingle(obj8), num4, num3);
                                if (obj.MessageShow)
                                {
                                    if ((image5.Width > num4) & (image5.Height > (num3 / 2f)))
                                    {
                                        num20 = num4 / ((float) image5.Width);
                                        num21 = (num3 / 2f) / ((float) image5.Height);
                                    }
                                    else if ((image5.Width > num4) & (image5.Height < (num3 / 2f)))
                                    {
                                        num20 = num4 / ((float) image5.Width);
                                        num21 = 1.0;
                                    }
                                    else if ((image5.Width < num4) & (image5.Height > (num3 / 2f)))
                                    {
                                        num20 = 1.0;
                                        num21 = (num3 / 2f) / ((float) image5.Height);
                                    }
                                    else
                                    {
                                        num20 = 1.0;
                                        num21 = 1.0;
                                    }
                                }
                                else if ((image5.Width > num4) & (image5.Height > num3))
                                {
                                    num20 = num4 / ((float) image5.Width);
                                    num21 = num3 / ((float) image5.Height);
                                }
                                else if ((image5.Width > num4) & (image5.Height < num3))
                                {
                                    num20 = num4 / ((float) image5.Width);
                                    num21 = 1.0;
                                }
                                else if ((image5.Width < num4) & (image5.Height > num3))
                                {
                                    num20 = 1.0;
                                    num21 = num3 / ((float) image5.Height);
                                }
                                else
                                {
                                    num20 = 1.0;
                                    num21 = 1.0;
                                }
                                if (!(num20 == 1.0) | !(num21 == 1.0))
                                {
                                    ResizeImage(image5, num20, num21, HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif"));
                                }
                                if ((num20 == 1.0) & (num21 == 1.0))
                                {
                                    using (Image image6 = image5)
                                    {
                                        if (!obj.MessageShow)
                                        {
                                            rectangle = new Rectangle(Conversions.ToInteger(Operators.AddObject(obj7, (num4 - image6.Width) / 2f)), Conversions.ToInteger(Operators.AddObject(obj8, (num3 - image6.Height) / 2f)), (int) Math.Round((double) image6.Width), (int) Math.Round((double) image6.Height));
                                            graphics.DrawImage(image6, rectangle);
                                        }
                                        else
                                        {
                                            rectangle = new Rectangle(Conversions.ToInteger(Operators.AddObject(obj7, (num4 - image6.Width) / 2f)), Conversions.ToInteger(Operators.AddObject(obj8, num3 / 2f)), image6.Width, image6.Height);
                                            graphics.DrawImage(image6, rectangle);
                                        }
                                    }
                                }
                                else
                                {
                                    using (Image image7 = Image.FromFile(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif")))
                                    {
                                        if (!obj.MessageShow)
                                        {
                                            rectangle = new Rectangle(Conversions.ToInteger(Operators.AddObject(obj7, (num4 - image7.Width) / 2f)), Conversions.ToInteger(Operators.AddObject(obj8, (num3 - image7.Height) / 2f)), (int) Math.Round((double) image7.Width), (int) Math.Round((double) image7.Height));
                                            graphics.DrawImage(image7, rectangle);
                                        }
                                        else
                                        {
                                            rectangle = new Rectangle(Conversions.ToInteger(Operators.AddObject(obj7, (num4 - image7.Width) / 2f)), Conversions.ToInteger(Operators.AddObject(obj8, num3 / 2f)), image7.Width, image7.Height);
                                            graphics.DrawImage(image7, rectangle);
                                        }
                                    }
                                }
                            }
                            if (obj.MessageShow)
                            {
                                RectangleF ef6;
                                string str9 = obj.Personalize1;
                                if (Conversions.ToDouble(obj.CompanyID) == 3.0)
                                {
                                    object obj9;
                                    float num22 = width - TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType);
                                    if (obj.CardLayout == "H")
                                    {
                                        obj9 = height - TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                                    }
                                    else
                                    {
                                        obj9 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                                    }
                                    ef6 = new RectangleF(num22, Conversions.ToSingle(obj9), num4, num3 / 2f);
                                }
                                else if (Conversions.ToDouble(obj.CompanyID) == 2.0)
                                {
                                    ef6 = new RectangleF(TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType), TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType), num4, num3 / 2f);
                                }
                                DirectoryInfo info3 = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/"));
                                string str8 = obj.MessageTypeStyle;
                                using (PrivateFontCollection fonts3 = new PrivateFontCollection())
                                {
                                    if (info3.Exists)
                                    {
                                        FileInfo[] infoArray9 = info3.GetFiles();
                                        for (int k = 0; k < infoArray9.Length; k++)
                                        {
                                            object obj10 = infoArray9[k];
                                            fonts3.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + obj10.ToString());
                                            if (fonts3.Families[fonts3.Families.Count<FontFamily>() - 1].Name == str8)
                                            {
                                                fonts3.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + obj10.ToString());
                                                break;
                                            }
                                        }
                                        info3 = null;
                                    }
                                    using (Font font3 = new Font(fonts3.Families[fonts3.Families.Count<FontFamily>() - 1], Convert.ToSingle(obj.MessageFontSize)))
                                    {
                                        using (SolidBrush brush3 = new SolidBrush(color))
                                        {
                                            using (StringFormat format3 = new StringFormat())
                                            {
                                                if ((Conversions.ToString(obj.TextAlignmentX) == "T") & (Conversions.ToString(obj.TextAlignmentY) == "C"))
                                                {
                                                    format3.Alignment = StringAlignment.Center;
                                                    format3.LineAlignment = StringAlignment.Near;
                                                    format3.Trimming = StringTrimming.Character;
                                                }
                                                else
                                                {
                                                    format3.Alignment = StringAlignment.Center;
                                                    format3.LineAlignment = StringAlignment.Center;
                                                    format3.Trimming = StringTrimming.Character;
                                                }
                                                graphics.DrawString(str9, font3, brush3, ef6, format3);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (obj.CardLogoLocation == "Above")
                    {
                        if ((!(TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.IconLeft, 1440M)), obj.ResolutionType) == TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType)) & !(TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.IconTop, 1440M)), obj.ResolutionType) == TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType))) & (Conversions.ToDouble(obj.CompanyID) == 3.0))
                        {
                            string str10 = HttpContext.Current.Server.MapPath("~/Order/OrderLogos/Card/" + obj.LogoName);
                            using (Image image8 = Image.FromFile(str10))
                            {
                                object obj11;
                                double num26;
                                double num27;
                                float num24 = TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.IconWidth, 1440M)), obj.ResolutionType);
                                float num23 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.IconHeight, 1440M)), obj.ResolutionType);
                                float num25 = width - TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.IconLeft, 1440M)), obj.ResolutionType);
                                if (obj.CardLayout == "H")
                                {
                                    obj11 = height - TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.IconTop, 1440M)), obj.ResolutionType);
                                }
                                else
                                {
                                    obj11 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.IconTop, 1440M)), obj.ResolutionType);
                                }
                                RectangleF ef7 = new RectangleF(num25, Conversions.ToSingle(obj11), num24, num23);
                                if ((image8.Width > num24) & (image8.Height > num23))
                                {
                                    num26 = num24 / ((float) image8.Width);
                                    num27 = num23 / ((float) image8.Height);
                                }
                                else if ((image8.Width > num24) & (image8.Height < num23))
                                {
                                    num26 = num24 / ((float) image8.Width);
                                    num27 = 1.0;
                                }
                                else if ((image8.Width < num24) & (image8.Height > num23))
                                {
                                    num26 = 1.0;
                                    num27 = num23 / ((float) image8.Height);
                                }
                                else
                                {
                                    num26 = 1.0;
                                    num27 = 1.0;
                                }
                                if (!(num26 == 1.0) | !(num27 == 1.0))
                                {
                                    ResizeImage(image8, num26, num27, HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif"));
                                }
                                if ((num26 == 1.0) & (num27 == 1.0))
                                {
                                    using (Image image9 = image8)
                                    {
                                        graphics.DrawImage(image9, num25 + ((num24 - image9.Width) / 2f), Conversions.ToSingle(Operators.AddObject(obj11, (num23 - image9.Height) / 2f)), (float) image9.Width, (float) image9.Height);
                                    }
                                }
                                else
                                {
                                    using (Image image10 = Image.FromFile(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif")))
                                    {
                                        graphics.DrawImage(image10, num25 + ((num24 - image10.Width) / 2f), Conversions.ToSingle(Operators.AddObject(obj11, (num23 - image10.Height) / 2f)), (float) image10.Width, (float) image10.Height);
                                    }
                                }
                            }
                            if (obj.MessageShow)
                            {
                                RectangleF ef8;
                                string str12 = obj.Personalize1 + Environment.NewLine + obj.Personalize2 + Environment.NewLine + obj.Personalize3 + Environment.NewLine + obj.Personalize4;
                                if (Conversions.ToDouble(obj.CompanyID) == 3.0)
                                {
                                    object obj12;
                                    float num28 = width - TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType);
                                    if (obj.CardLayout == "H")
                                    {
                                        obj12 = height - TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                                    }
                                    else
                                    {
                                        obj12 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                                    }
                                    ef8 = new RectangleF(num28, Conversions.ToSingle(obj12), num4, num3);
                                }
                                DirectoryInfo info4 = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/"));
                                string str11 = obj.MessageTypeStyle;
                                using (PrivateFontCollection fonts4 = new PrivateFontCollection())
                                {
                                    if (info4.Exists)
                                    {
                                        FileInfo[] infoArray10 = info4.GetFiles();
                                        for (int m = 0; m < infoArray10.Length; m++)
                                        {
                                            object obj13 = infoArray10[m];
                                            fonts4.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + obj13.ToString());
                                            if (fonts4.Families[fonts4.Families.Count<FontFamily>() - 1].Name == str11)
                                            {
                                                fonts4.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + obj13.ToString());
                                                break;
                                            }
                                        }
                                        info4 = null;
                                    }
                                    using (Font font4 = new Font(fonts4.Families[fonts4.Families.Count<FontFamily>() - 1], Convert.ToSingle(obj.MessageFontSize)))
                                    {
                                        using (StringFormat format4 = new StringFormat())
                                        {
                                            using (SolidBrush brush4 = new SolidBrush(color))
                                            {
                                                if ((Conversions.ToString(obj.TextAlignmentX) == "T") & (Conversions.ToString(obj.TextAlignmentY) == "C"))
                                                {
                                                    format4.Alignment = StringAlignment.Center;
                                                    format4.LineAlignment = StringAlignment.Near;
                                                    format4.Trimming = StringTrimming.Character;
                                                }
                                                else
                                                {
                                                    format4.Alignment = StringAlignment.Center;
                                                    format4.LineAlignment = StringAlignment.Center;
                                                    format4.Trimming = StringTrimming.Character;
                                                }
                                                graphics.DrawString(str12, font4, brush4, ef8, format4);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            string str13 = HttpContext.Current.Server.MapPath("~/Order/OrderLogos/Card/" + obj.LogoName);
                            using (Image image11 = Image.FromFile(str13))
                            {
                                object obj14;
                                object obj15;
                                double num29;
                                double num30;
                                if (Conversions.ToDouble(obj.CompanyID) == 2.0)
                                {
                                    obj14 = TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType);
                                    obj15 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                                }
                                else if (Conversions.ToDouble(obj.CompanyID) == 3.0)
                                {
                                    obj14 = width - TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType);
                                    if (obj.CardLayout == "H")
                                    {
                                        obj15 = height - TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                                    }
                                    else
                                    {
                                        obj15 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                                    }
                                }
                                RectangleF ef9 = new RectangleF(Conversions.ToSingle(obj14), Conversions.ToSingle(obj15), num4, num3);
                                if (obj.MessageShow)
                                {
                                    if ((image11.Width > num4) & (image11.Height > (num3 / 2f)))
                                    {
                                        num29 = num4 / ((float) image11.Width);
                                        num30 = (num3 / 2f) / ((float) image11.Height);
                                    }
                                    else if ((image11.Width > num4) & (image11.Height < (num3 / 2f)))
                                    {
                                        num29 = num4 / ((float) image11.Width);
                                        num30 = 1.0;
                                    }
                                    else if ((image11.Width < num4) & (image11.Height > (num3 / 2f)))
                                    {
                                        num29 = 1.0;
                                        num30 = (num3 / 2f) / ((float) image11.Height);
                                    }
                                    else
                                    {
                                        num29 = 1.0;
                                        num30 = 1.0;
                                    }
                                }
                                else if ((image11.Width > num4) & (image11.Height > num3))
                                {
                                    num29 = num4 / ((float) image11.Width);
                                    num30 = num3 / ((float) image11.Height);
                                }
                                else if ((image11.Width > num4) & (image11.Height < num3))
                                {
                                    num29 = num4 / ((float) image11.Width);
                                    num30 = 1.0;
                                }
                                else if ((image11.Width < num4) & (image11.Height > num3))
                                {
                                    num29 = 1.0;
                                    num30 = num3 / ((float) image11.Height);
                                }
                                else
                                {
                                    num29 = 1.0;
                                    num30 = 1.0;
                                }
                                if (!(num29 == 1.0) | !(num30 == 1.0))
                                {
                                    ResizeImage(image11, num29, num30, HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif"));
                                }
                                if ((num29 == 1.0) & (num30 == 1.0))
                                {
                                    using (Image image12 = image11)
                                    {
                                        if (!obj.MessageShow)
                                        {
                                            rectangle = new Rectangle(Conversions.ToInteger(Operators.AddObject(obj14, (num4 - image12.Width) / 2f)), Conversions.ToInteger(Operators.AddObject(obj15, (num3 - image12.Height) / 2f)), (int) Math.Round((double) image12.Width), (int) Math.Round((double) image12.Height));
                                            graphics.DrawImage(image12, rectangle);
                                        }
                                        else
                                        {
                                            rectangle = new Rectangle(Conversions.ToInteger(Operators.AddObject(obj14, (num4 - image12.Width) / 2f)), Conversions.ToInteger(obj15), image12.Width, image12.Height);
                                            graphics.DrawImage(image12, rectangle);
                                        }
                                    }
                                }
                                else
                                {
                                    using (Image image13 = Image.FromFile(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif")))
                                    {
                                        if (!obj.MessageShow)
                                        {
                                            rectangle = new Rectangle(Conversions.ToInteger(Operators.AddObject(obj14, (num4 - image13.Width) / 2f)), Conversions.ToInteger(Operators.AddObject(obj15, (num3 - image13.Height) / 2f)), (int) Math.Round((double) image13.Width), (int) Math.Round((double) image13.Height));
                                            graphics.DrawImage(image13, rectangle);
                                        }
                                        else
                                        {
                                            rectangle = new Rectangle(Conversions.ToInteger(Operators.AddObject(obj14, (num4 - image13.Width) / 2f)), Conversions.ToInteger(obj15), image13.Width, image13.Height);
                                            graphics.DrawImage(image13, rectangle);
                                        }
                                    }
                                }
                            }
                            if (obj.MessageShow)
                            {
                                RectangleF ef10;
                                string str14 = obj.Personalize1;
                                if (Conversions.ToDouble(obj.CompanyID) == 3.0)
                                {
                                    object obj16;
                                    float num31 = width - TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType);
                                    if (obj.CardLayout == "H")
                                    {
                                        obj16 = height - TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                                    }
                                    else
                                    {
                                        obj16 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                                    }
                                    ef10 = new RectangleF(num31, Conversions.ToSingle(Operators.AddObject(obj16, num3 / 2f)), num4, num3 / 2f);
                                }
                                else if (Conversions.ToDouble(obj.CompanyID) == 2.0)
                                {
                                    ef10 = new RectangleF(TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType), TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType) + (num3 / 2f), num4, num3 / 2f);
                                }
                                using (StringFormat format5 = new StringFormat())
                                {
                                    if ((Conversions.ToString(obj.TextAlignmentX) == "T") & (Conversions.ToString(obj.TextAlignmentY) == "C"))
                                    {
                                        format5.Alignment = StringAlignment.Center;
                                        format5.LineAlignment = StringAlignment.Near;
                                        format5.Trimming = StringTrimming.Character;
                                    }
                                    else
                                    {
                                        format5.Alignment = StringAlignment.Center;
                                        format5.LineAlignment = StringAlignment.Center;
                                        format5.Trimming = StringTrimming.Character;
                                    }
                                    DirectoryInfo info5 = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/"));
                                    string str15 = obj.MessageTypeStyle;
                                    using (PrivateFontCollection fonts5 = new PrivateFontCollection())
                                    {
                                        if (info5.Exists)
                                        {
                                            FileInfo[] infoArray11 = info5.GetFiles();
                                            for (int n = 0; n < infoArray11.Length; n++)
                                            {
                                                object obj17 = infoArray11[n];
                                                fonts5.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + obj17.ToString());
                                                if (fonts5.Families[fonts5.Families.Count<FontFamily>() - 1].Name == str15)
                                                {
                                                    fonts5.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + obj17.ToString());
                                                    break;
                                                }
                                            }
                                            info5 = null;
                                        }
                                        using (Font font5 = new Font(fonts5.Families[fonts5.Families.Count<FontFamily>() - 1], Convert.ToSingle(obj.MessageFontSize)))
                                        {
                                            using (SolidBrush brush5 = new SolidBrush(color))
                                            {
                                                graphics.DrawString(str14, font5, brush5, ef10, format5);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (obj.MessageShow & !obj.LogoShow)
                {
                    using (StringFormat format6 = new StringFormat())
                    {
                        RectangleF ef11;
                        string str16 = obj.Personalize1 + Environment.NewLine + obj.Personalize2 + Environment.NewLine + obj.Personalize3 + Environment.NewLine + obj.Personalize4;
                        if (Conversions.ToDouble(obj.CompanyID) == 3.0)
                        {
                            object obj18;
                            float num32 = width - TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType);
                            if (obj.CardLayout == "H")
                            {
                                obj18 = height - TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                            }
                            else
                            {
                                obj18 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType);
                            }
                            ef11 = new RectangleF(num32, Conversions.ToSingle(obj18), num4, num3);
                            if ((Conversions.ToString(obj.TextAlignmentX) == "T") & (Conversions.ToString(obj.TextAlignmentY) == "C"))
                            {
                                format6.Alignment = StringAlignment.Center;
                                format6.LineAlignment = StringAlignment.Near;
                                format6.Trimming = StringTrimming.Character;
                            }
                            else
                            {
                                format6.Alignment = StringAlignment.Center;
                                format6.LineAlignment = StringAlignment.Center;
                                format6.Trimming = StringTrimming.Character;
                            }
                        }
                        else if (Conversions.ToDouble(obj.CompanyID) == 2.0)
                        {
                            ef11 = new RectangleF(TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.TextLeft, 1440M)), obj.ResolutionType), TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.TextTop, 1440M)), obj.ResolutionType), num4, num3);
                            format6.Alignment = StringAlignment.Center;
                            format6.LineAlignment = StringAlignment.Near;
                        }
                        using (PrivateFontCollection fonts6 = new PrivateFontCollection())
                        {
                            DirectoryInfo info6 = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/"));
                            string str17 = obj.MessageTypeStyle;
                            if (info6.Exists)
                            {
                                FileInfo[] infoArray12 = info6.GetFiles();
                                for (int num38 = 0; num38 < infoArray12.Length; num38++)
                                {
                                    object obj19 = infoArray12[num38];
                                    fonts6.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + obj19.ToString());
                                    if (fonts6.Families[fonts6.Families.Count<FontFamily>() - 1].Name == str17)
                                    {
                                        fonts6.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + obj19.ToString());
                                        break;
                                    }
                                }
                                info6 = null;
                            }
                            using (Font font6 = new Font(fonts6.Families[fonts6.Families.Count<FontFamily>() - 1], Convert.ToSingle(obj.MessageFontSize)))
                            {
                                using (SolidBrush brush6 = new SolidBrush(color))
                                {
                                    graphics.DrawString(str16, font6, brush6, ef11, format6);
                                }
                            }
                        }
                    }
                }
                string filename = HttpContext.Current.Server.MapPath("~/ProofingTool/Low Resolution Images/" + obj.SessionID + "_Card.gif");
                bitmap.Save(filename, ImageFormat.Gif);
            }
        }
    }
    catch (Exception exception1)
    {
        ProjectData.SetProjectError(exception1);
        Exception exception = exception1;
        if (!string.IsNullOrEmpty(obj.SessionID) && File.Exists(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_verse.tif")))
        {
            File.Delete(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_verse.tif"));
        }
        if ((!string.IsNullOrEmpty(obj.LogoName) & !string.IsNullOrEmpty(obj.SessionID)) && File.Exists(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif")))
        {
            File.Delete(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif"));
        }
        ProjectData.ClearProjectError();
    }
    finally
    {
        if (!string.IsNullOrEmpty(obj.SessionID) && File.Exists(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_verse.tif")))
        {
            File.Delete(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_verse.tif"));
        }
        if ((!string.IsNullOrEmpty(obj.LogoName) & !string.IsNullOrEmpty(obj.SessionID)) && File.Exists(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif")))
        {
            File.Delete(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.LogoName.Substring(0, obj.LogoName.LastIndexOf(".")) + "Scaled.tif"));
        }
    }
}

 

 
End 


public static string CreateEnvelopeHighProof(Hammond obj)
{
    string str2 = Guid.NewGuid().ToString();
    string str3 = Guid.NewGuid().ToString();
    try
    {
        int width = (int) Math.Round((double) TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.EnvelopeWidth, 1440M)), obj.ResolutionType));
        int height = (int) Math.Round((double) TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.EnvelopeHeight, 1440M)), obj.ResolutionType));
        using (Bitmap bitmap = new Bitmap(width, height))
        {
            if (Conversions.ToDouble(obj.CompanyID) == 3.0)
            {
                bitmap.SetResolution(600f, 600f);
            }
            else if (true)
            {
                bitmap.SetResolution(600f, 600f);
            }
            using (Graphics graphics = Graphics.FromImage(bitmap))
            {
                string str4;
                graphics.Clear(Color.White);
                graphics.CompositingQuality = CompositingQuality.HighSpeed;
                graphics.SmoothingMode = SmoothingMode.HighQuality;
                graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                Color color = Color.FromName("Black");
                if (obj.EnvelopeImprintShow)
                {
                    using (SolidBrush brush = new SolidBrush(color))
                    {
                        using (PrivateFontCollection fonts = new PrivateFontCollection())
                        {
                            DirectoryInfo info = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/"));
                            string envelopeTypeStyle = obj.EnvelopeTypeStyle;
                            if (info.Exists)
                            {
                                FileInfo[] files = info.GetFiles();
                                for (int i = 0; i < files.Length; i++)
                                {
                                    fonts.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + files[i].ToString());
                                    if (fonts.Families[fonts.Families.Count<FontFamily>() - 1].Name == envelopeTypeStyle)
                                    {
                                        break;
                                    }
                                }
                                info = null;
                            }
                            using (Font font = new Font(fonts.Families[fonts.Families.Count<FontFamily>() - 1], Convert.ToSingle(obj.EnvelopeFontSize)))
                            {
                                string s = obj.EnvelopePersonalize1 + Environment.NewLine + obj.EnvelopePersonalize2 + Environment.NewLine + obj.EnvelopePersonalize3 + Environment.NewLine + obj.EnvelopePersonalize4;
                                float x = TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.EnvelopeImprintLeft, 1440M)), obj.ResolutionType);
                                float y = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.EnvelopeImprintTop, 1440M)), obj.ResolutionType);
                                float num4 = TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.EnvelopeImprintWidth, 1440M)), obj.ResolutionType);
                                float num3 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.EnvelopeImprintHeight, 1440M)), obj.ResolutionType);
                                using (StringFormat format = new StringFormat())
                                {
                                    if ((Conversions.ToString(obj.EnvelopeImprintAlignmentX) == "T") & (Conversions.ToString(obj.EnvelopeImprintAlignmentY) == "C"))
                                    {
                                        format.Alignment = StringAlignment.Center;
                                        format.LineAlignment = StringAlignment.Near;
                                        format.Trimming = StringTrimming.Character;
                                    }
                                    else
                                    {
                                        format.Alignment = StringAlignment.Center;
                                        format.LineAlignment = StringAlignment.Center;
                                        format.Trimming = StringTrimming.Character;
                                    }
                                    if (obj.EnvelopeLogoShow)
                                    {
                                        RectangleF layoutRectangle = new RectangleF(x, y + num3, num4, num3);
                                        graphics.DrawString(s, font, brush, layoutRectangle, format);
                                    }
                                    else
                                    {
                                        RectangleF ef2 = new RectangleF(x, y, num4, num3);
                                        graphics.DrawString(s, font, brush, ef2, format);
                                    }
                                }
                            }
                        }
                    }
                }
                if (obj.EnvelopeLogoShow)
                {
                    ColorMatrix newColorMatrix = new ColorMatrix(new float[][] { new float[] { 0.299f, 0.299f, 0.299f, 0f, 0f }, new float[] { 0.587f, 0.587f, 0.587f, 0f, 0f }, new float[] { 0.114f, 0.114f, 0.114f, 0f, 0f }, new float[] { 0f, 0f, 0f, 1f, 0f }, new float[] { 0f, 0f, 0f, 0f, 1f } }) {
                        Matrix33 = 1f
                    };
                    using (ImageAttributes attributes = new ImageAttributes())
                    {
                        attributes.SetColorMatrix(newColorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Default);
                        string filename = HttpContext.Current.Server.MapPath("~/Order/OrderLogos/Envelope/" + obj.EnvelopeLogoName);
                        using (Image image = Image.FromFile(filename))
                        {
                            double num11;
                            double num12;
                            Rectangle rectangle;
                            float num9 = TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.EnvelopeImprintLeft, 1440M)), obj.ResolutionType);
                            float num10 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.EnvelopeImprintTop, 1440M)), obj.ResolutionType);
                            float num8 = TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.EnvelopeImprintWidth, 1440M)), obj.ResolutionType);
                            float num7 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.EnvelopeImprintHeight, 1440M)), obj.ResolutionType);
                            if (!(image.HorizontalResolution == 600f) | !(image.VerticalResolution == 600f))
                            {
                                using (MemoryStream stream = new MemoryStream(ConvertImageToByteArray(image)))
                                {
                                    using (Image image2 = Image.FromStream(stream))
                                    {
                                        using (Image image3 = SetResolution(image2, 600))
                                        {
                                            if ((image3.Width > num8) & (image3.Height > num7))
                                            {
                                                num11 = num8 / ((float) image3.Width);
                                                num12 = num7 / ((float) image3.Height);
                                            }
                                            else if ((image3.Width > num8) & (image3.Height < num7))
                                            {
                                                num11 = num8 / ((float) image3.Width);
                                                num12 = 1.0;
                                            }
                                            else if ((image3.Width < num8) & (image3.Height > num7))
                                            {
                                                num11 = 1.0;
                                                num12 = num7 / ((float) image3.Height);
                                            }
                                            else
                                            {
                                                num11 = 1.0;
                                                num12 = 1.0;
                                            }
                                            if (!(num11 == 1.0) | !(num12 == 1.0))
                                            {
                                                ResizeImage(image3, num11, num12, HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.EnvelopeLogoName.Substring(0, obj.EnvelopeLogoName.LastIndexOf(".")) + "ScaledE.tif"));
                                            }
                                            if ((num11 == 1.0) & (num12 == 1.0))
                                            {
                                                using (Image image4 = image3)
                                                {
                                                    rectangle = new Rectangle((int) Math.Round((double) (num9 + ((num8 - image4.Width) / 2f))), (int) Math.Round((double) (num10 + ((num7 - image4.Height) / 2f))), (int) Math.Round((double) image4.Width), (int) Math.Round((double) image4.Height));
                                                    graphics.DrawImage(image4, rectangle, 0f, 0f, (float) image4.Width, (float) image4.Height, GraphicsUnit.Pixel, attributes);
                                                }
                                            }
                                            else
                                            {
                                                using (Image image5 = Image.FromFile(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.EnvelopeLogoName.Substring(0, obj.EnvelopeLogoName.LastIndexOf(".")) + "ScaledE.tif")))
                                                {
                                                    rectangle = new Rectangle((int) Math.Round((double) (num9 + ((num8 - image5.Width) / 2f))), (int) Math.Round((double) (num10 + ((num7 - image5.Height) / 2f))), (int) Math.Round((double) image5.Width), (int) Math.Round((double) image5.Height));
                                                    graphics.DrawImage(image5, rectangle, 0f, 0f, (float) image5.Width, (float) image5.Height, GraphicsUnit.Pixel, attributes);
                                                }
                                            }
                                        }
                                        goto Label_0E3C;
                                    }
                                }
                            }
                            if ((image.Width > num8) & (image.Height > num7))
                            {
                                num11 = num8 / ((float) image.Width);
                                num12 = num7 / ((float) image.Height);
                            }
                            else if ((image.Width > num8) & (image.Height < num7))
                            {
                                num11 = num8 / ((float) image.Width);
                                num12 = 1.0;
                            }
                            else if ((image.Width < num8) & (image.Height > num7))
                            {
                                num11 = 1.0;
                                num12 = num7 / ((float) image.Height);
                            }
                            else
                            {
                                num11 = 1.0;
                                num12 = 1.0;
                            }
                            if (!(num11 == 1.0) | !(num12 == 1.0))
                            {
                                ResizeImage(image, num11, num12, HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.EnvelopeLogoName.Substring(0, obj.EnvelopeLogoName.LastIndexOf(".")) + "ScaledE.tif"));
                            }
                            if ((num11 == 1.0) & (num12 == 1.0))
                            {
                                using (Image image6 = image)
                                {
                                    rectangle = new Rectangle((int) Math.Round((double) (num9 + ((num8 - image6.Width) / 2f))), (int) Math.Round((double) (num10 + ((num7 - image6.Height) / 2f))), (int) Math.Round((double) image6.Width), (int) Math.Round((double) image6.Height));
                                    graphics.DrawImage(image6, rectangle, 0f, 0f, (float) image6.Width, (float) image6.Height, GraphicsUnit.Pixel, attributes);
                                }
                            }
                            else
                            {
                                using (Image image7 = Image.FromFile(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.EnvelopeLogoName.Substring(0, obj.EnvelopeLogoName.LastIndexOf(".")) + "ScaledE.tif")))
                                {
                                    rectangle = new Rectangle((int) Math.Round((double) (num9 + ((num8 - image7.Width) / 2f))), (int) Math.Round((double) (num10 + ((num7 - image7.Height) / 2f))), (int) Math.Round((double) image7.Width), (int) Math.Round((double) image7.Height));
                                    graphics.DrawImage(image7, rectangle, 0f, 0f, (float) image7.Width, (float) image7.Height, GraphicsUnit.Pixel, attributes);
                                }
                            }
                        }
                    }
                }
            Label_0E3C:
                str4 = HttpContext.Current.Server.MapPath("~/ProofingTool/Production Files/" + str2 + ".tif");
                using (EncoderParameters parameters = new EncoderParameters(2))
                {
                    parameters.Param[0] = new EncoderParameter(Encoder.ColorDepth, 8L);
                    parameters.Param[1] = new EncoderParameter(Encoder.Compression, 2L);
                    bitmap.Save(str4, GetEncoderInfo("image/tiff"), parameters);
                }
                Process process = new Process();
                Process process2 = process;
                try
                {
                    process2.StartInfo.FileName = HttpContext.Current.Server.MapPath("~/Bin/GetGrayScaleProof.exe");
                    process2.StartInfo.Arguments = " \"" + str4 + "\" \"" + HttpContext.Current.Server.MapPath("~/ProofingTool/Production Files/" + str3 + ".tif") + "\"";
                    process2.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                    process2.StartInfo.CreateNoWindow = true;
                    process2.Start();
                    process2.WaitForExit(0xbb8);
                    process2.Kill();
                    process2.Dispose();
                }
                catch (Exception exception1)
                {
                    ProjectData.SetProjectError(exception1);
                    Exception exception = exception1;
                    process2.Kill();
                    process2.Dispose();
                    ProjectData.ClearProjectError();
                }
                process2 = null;
            }
        }
    }
    catch (Exception exception2)
    {
        ProjectData.SetProjectError(exception2);
        if ((!string.IsNullOrEmpty(obj.SessionID) & !string.IsNullOrEmpty(obj.EnvelopeLogoName)) && File.Exists(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.EnvelopeLogoName.Substring(0, obj.EnvelopeLogoName.LastIndexOf(".")) + "ScaledE.tif")))
        {
            File.Delete(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.EnvelopeLogoName.Substring(0, obj.EnvelopeLogoName.LastIndexOf(".")) + "ScaledE.tif"));
        }
        GC.Collect();
        ProjectData.ClearProjectError();
    }
    finally
    {
        if ((!string.IsNullOrEmpty(obj.SessionID) & !string.IsNullOrEmpty(obj.EnvelopeLogoName)) && File.Exists(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.EnvelopeLogoName.Substring(0, obj.EnvelopeLogoName.LastIndexOf(".")) + "ScaledE.tif")))
        {
            File.Delete(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.EnvelopeLogoName.Substring(0, obj.EnvelopeLogoName.LastIndexOf(".")) + "ScaledE.tif"));
        }
    }
    return string.Format("{0}|{1}", str3, str2);
}


End


public static void CreateEnvelopeLowProof(Hammond obj)
{
    try
    {
        int width = (int) Math.Round((double) TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.EnvelopeWidth, 1440M)), obj.ResolutionType));
        int height = (int) Math.Round((double) TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.EnvelopeHeight, 1440M)), obj.ResolutionType));
        using (Bitmap bitmap = new Bitmap(width, height))
        {
            using (Graphics graphics = Graphics.FromImage(bitmap))
            {
                graphics.Clear(Color.White);
                graphics.CompositingQuality = CompositingQuality.HighSpeed;
                graphics.SmoothingMode = SmoothingMode.HighQuality;
                graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                if (obj.EnvelopeImprintShow)
                {
                    Color color = Color.FromName(obj.EnvelopeImprintInk);
                    using (SolidBrush brush = new SolidBrush(color))
                    {
                        DirectoryInfo info = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/"));
                        string envelopeTypeStyle = obj.EnvelopeTypeStyle;
                        using (PrivateFontCollection fonts = new PrivateFontCollection())
                        {
                            if (info.Exists)
                            {
                                FileInfo[] files = info.GetFiles();
                                for (int i = 0; i < files.Length; i++)
                                {
                                    fonts.AddFontFile(HttpContext.Current.Server.MapPath("~/ProofingTool/CustomFonts/") + files[i].ToString());
                                    if (fonts.Families[fonts.Families.Count<FontFamily>() - 1].Name == envelopeTypeStyle)
                                    {
                                        break;
                                    }
                                }
                                info = null;
                            }
                            using (Font font = new Font(fonts.Families[fonts.Families.Count<FontFamily>() - 1], Convert.ToSingle(obj.EnvelopeFontSize)))
                            {
                                string s = obj.EnvelopePersonalize1 + Environment.NewLine + obj.EnvelopePersonalize2 + Environment.NewLine + obj.EnvelopePersonalize3 + Environment.NewLine + obj.EnvelopePersonalize4;
                                float x = TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.EnvelopeImprintLeft, 1440M)), obj.ResolutionType);
                                float y = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.EnvelopeImprintTop, 1440M)), obj.ResolutionType);
                                float num4 = TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.EnvelopeImprintWidth, 1440M)), obj.ResolutionType);
                                float num3 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.EnvelopeImprintHeight, 1440M)), obj.ResolutionType);
                                using (StringFormat format = new StringFormat())
                                {
                                    if ((Conversions.ToString(obj.EnvelopeImprintAlignmentX) == "T") & (Conversions.ToString(obj.EnvelopeImprintAlignmentY) == "C"))
                                    {
                                        format.Alignment = StringAlignment.Center;
                                        format.LineAlignment = StringAlignment.Near;
                                        format.Trimming = StringTrimming.Character;
                                    }
                                    else
                                    {
                                        format.Alignment = StringAlignment.Center;
                                        format.LineAlignment = StringAlignment.Center;
                                        format.Trimming = StringTrimming.Character;
                                    }
                                    if (obj.EnvelopeLogoShow)
                                    {
                                        RectangleF layoutRectangle = new RectangleF(x, y + num3, num4, num3);
                                        graphics.DrawString(s, font, brush, layoutRectangle, format);
                                    }
                                    else
                                    {
                                        RectangleF ef2 = new RectangleF(x, y, num4, num3);
                                        graphics.DrawString(s, font, brush, ef2, format);
                                    }
                                }
                            }
                        }
                    }
                }
                if (obj.EnvelopeLogoShow)
                {
                    string str4 = HttpContext.Current.Server.MapPath("~/Order/OrderLogos/Envelope/" + obj.EnvelopeLogoName);
                    using (Image image = Image.FromFile(str4))
                    {
                        double num11;
                        double num12;
                        Rectangle rectangle;
                        float num9 = TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.EnvelopeImprintLeft, 1440M)), obj.ResolutionType);
                        float num10 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.EnvelopeImprintTop, 1440M)), obj.ResolutionType);
                        float num8 = TwipsToPixelsX(Convert.ToSingle(decimal.Multiply(obj.EnvelopeImprintWidth, 1440M)), obj.ResolutionType);
                        float num7 = TwipsToPixelsY(Convert.ToSingle(decimal.Multiply(obj.EnvelopeImprintHeight, 1440M)), obj.ResolutionType);
                        if ((image.Width > num8) & (image.Height > num7))
                        {
                            num11 = num8 / ((float) image.Width);
                            num12 = num7 / ((float) image.Height);
                        }
                        else if ((image.Width > num8) & (image.Height < num7))
                        {
                            num11 = num8 / ((float) image.Width);
                            num12 = 1.0;
                        }
                        else if ((image.Width < num8) & (image.Height > num7))
                        {
                            num11 = 1.0;
                            num12 = num7 / ((float) image.Height);
                        }
                        else
                        {
                            num11 = 1.0;
                            num12 = 1.0;
                        }
                        if (!(num11 == 1.0) | !(num12 == 1.0))
                        {
                            ResizeImage(image, num11, num12, HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.EnvelopeLogoName.Substring(0, obj.EnvelopeLogoName.LastIndexOf(".")) + "ScaledE.tif"));
                        }
                        if ((num11 == 1.0) & (num12 == 1.0))
                        {
                            using (Image image2 = image)
                            {
                                rectangle = new Rectangle((int) Math.Round((double) (num9 + ((num8 - image2.Width) / 2f))), (int) Math.Round((double) (num10 + ((num7 - image2.Height) / 2f))), (int) Math.Round((double) image2.Width), (int) Math.Round((double) image2.Height));
                                graphics.DrawImage(image2, rectangle);
                            }
                        }
                        else
                        {
                            using (Image image3 = Image.FromFile(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.EnvelopeLogoName.Substring(0, obj.EnvelopeLogoName.LastIndexOf(".")) + "ScaledE.tif")))
                            {
                                rectangle = new Rectangle((int) Math.Round((double) (num9 + ((num8 - image3.Width) / 2f))), (int) Math.Round((double) (num10 + ((num7 - image3.Height) / 2f))), (int) Math.Round((double) image3.Width), (int) Math.Round((double) image3.Height));
                                graphics.DrawImage(image3, rectangle);
                            }
                        }
                    }
                }
                string filename = HttpContext.Current.Server.MapPath("~/ProofingTool/Low Resolution Images/" + obj.SessionID + "_Envelope.gif");
                bitmap.Save(filename, ImageFormat.Gif);
            }
        }
    }
    catch (Exception exception1)
    {
        ProjectData.SetProjectError(exception1);
        if ((!string.IsNullOrEmpty(obj.SessionID) & !string.IsNullOrEmpty(obj.EnvelopeLogoName)) && File.Exists(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.EnvelopeLogoName.Substring(0, obj.EnvelopeLogoName.LastIndexOf(".")) + "ScaledE.tif")))
        {
            File.Delete(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.EnvelopeLogoName.Substring(0, obj.EnvelopeLogoName.LastIndexOf(".")) + "ScaledE.tif"));
        }
        ProjectData.ClearProjectError();
    }
    finally
    {
        if ((!string.IsNullOrEmpty(obj.SessionID) & !string.IsNullOrEmpty(obj.EnvelopeLogoName)) && File.Exists(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.EnvelopeLogoName.Substring(0, obj.EnvelopeLogoName.LastIndexOf(".")) + "ScaledE.tif")))
        {
            File.Delete(HttpContext.Current.Server.MapPath("~/ProofingTool/Temp/" + obj.SessionID + "_" + obj.EnvelopeLogoName.Substring(0, obj.EnvelopeLogoName.LastIndexOf(".")) + "ScaledE.tif"));
        }
    }
}

 

 
End 


public static void ResizeImage(Image srcImage, double scaleFactorX, double scaleFactorY, string toStream)
{
    try
    {
        using (srcImage)
        {
            using (MemoryStream stream = new MemoryStream(ConvertImageToByteArray(srcImage)))
            {
                using (Image image = Image.FromStream(stream))
                {
                    int height = (int) Math.Round((double) (image.Height * scaleFactorY));
                    double num = ((double) image.Width) / ((double) image.Height);
                    int width = (int) Math.Round((double) (height * num));
                    using (Bitmap bitmap = new Bitmap(width, height))
                    {
                        using (Graphics graphics = Graphics.FromImage(bitmap))
                        {
                            graphics.CompositingQuality = CompositingQuality.HighQuality;
                            graphics.SmoothingMode = SmoothingMode.HighQuality;
                            graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                            Rectangle rect = new Rectangle(0, 0, width, height);
                            graphics.DrawImage(image, rect);
                            bitmap.Save(toStream, ImageFormat.Tiff);
                        }
                    }
                }
            }
        }
        srcImage.Dispose();
    }
    catch (Exception exception1)
    {
        ProjectData.SetProjectError(exception1);
        Exception exception = exception1;
        srcImage.Dispose();
        ProjectData.ClearProjectError();
    }
}

 

 
End


public static Image SetResolution(Image sourceImage, int resolution)
{
    double num = ((double) resolution) / ((double) ((int) Math.Round((double) sourceImage.HorizontalResolution)));
    using (Bitmap bitmap = new Bitmap(sourceImage.Width, sourceImage.Height))
    {
        bitmap.SetResolution((float) resolution, (float) resolution);
        Bitmap image = new Bitmap(sourceImage, (int) Math.Round((double) (sourceImage.Width * num)), (int) Math.Round((double) (sourceImage.Height * num)));
        using (Graphics graphics = Graphics.FromImage(bitmap))
        {
            graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            graphics.DrawImage(image, 0, 0);
        }
        return image;
    }
}

 

 
End


public static float TwipsToPixelsX(float twips, string resType)
{
    float num;
    if (resType.Split(new char[] { '|' })[0] == "low")
    {
        return (twips / 15f);
    }
    if (Conversions.ToDouble(resType.Split(new char[] { '|' })[1]) == 3.0)
    {
        return (twips / 2.4f);
    }
    if (Conversions.ToDouble(resType.Split(new char[] { '|' })[1]) == 2.0)
    {
        num = twips / 2.4f;
    }
    return num;
}

 
public class Hammond
{
    // Fields
    private bool _BlankStandardVerse;
    private string _CardHeight;
    private int _CardID;
    private string _CardLayout;
    private string _CardLogoLocation;
    private string _CardSize;
    private string _CardWidth;
    private string _CompanyCardID;
    private string _CompanyID;
    private string _CustomVerseText;
    private decimal _EnvelopeFontSize;
    private decimal _EnvelopeHeight;
    private char _EnvelopeImprintAlignmentX;
    private char _EnvelopeImprintAlignmentY;
    private decimal _EnvelopeImprintHeight;
    private string _EnvelopeImprintInk;
    private decimal _EnvelopeImprintLeft;
    private bool _EnvelopeImprintShow;
    private decimal _EnvelopeImprintTop;
    private decimal _EnvelopeImprintWidth;
    private char _EnvelopeLogoAlignmentX;
    private char _EnvelopeLogoAlignmentY;
    private decimal _EnvelopeLogoHeight;
    private decimal _EnvelopeLogoLeft;
    private string _EnvelopeLogoName;
    private bool _EnvelopeLogoShow;
    private decimal _EnvelopeLogoTop;
    private decimal _EnvelopeLogoWidth;
    private string _EnvelopePersonalize1;
    private string _EnvelopePersonalize2;
    private string _EnvelopePersonalize3;
    private string _EnvelopePersonalize4;
    private string _EnvelopeTypeStyle;
    private decimal _EnvelopeWidth;
    private char _IconAlignmentX;
    private char _IconAlignmentY;
    private decimal _IconHeight;
    private decimal _IconLeft;
    private decimal _IconTop;
    private decimal _IconWidth;
    private string _ImprintInk;
    private string _LogoName;
    private bool _LogoShow;
    private decimal _MessageFontSize;
    private bool _MessageShow;
    private string _MessageTypeStyle;
    private string _Personalize1;
    private string _Personalize2;
    private string _Personalize3;
    private string _Personalize4;
    private string _PTextSize;
    private string _restype;
    private string _SessionID;
    private string _StandardVerse;
    private char _TextAlignmentX;
    private char _TextAlignmentY;
    private decimal _TextHeight;
    private decimal _TextLeft;
    private decimal _TextTop;
    private decimal _TextWidth;
    private string _TypeStyle;
    private char _VerseAlignmentX;
    private char _VerseAlignmentY;
    private decimal _VerseFontSize;
    private decimal _VerseHeight;
    private string _VerseID;
    private decimal _VerseLeft;
    private string _VerseSize;
    private decimal _VerseTop;
    private string _VerseType;
    private decimal _VerseWidth;

    // Methods
    public Hammond();

    // Properties
    public bool BlankStandardVerse { get; set; }
    public decimal CardHeight { get; set; }
    public int CardID { get; set; }
    public string CardLayout { get; set; }
    public string CardLogoLocation { get; set; }
    public string CardSize { get; set; }
    public decimal CardWidth { get; set; }
    public string CompanyCardID { get; set; }
    public string CompanyID { get; set; }
    public string CustomVerseText { get; set; }
    public decimal EnvelopeFontSize { get; set; }
    public decimal EnvelopeHeight { get; set; }
    public char EnvelopeImprintAlignmentX { get; set; }
    public char EnvelopeImprintAlignmentY { get; set; }
    public decimal EnvelopeImprintHeight { get; set; }
    public string EnvelopeImprintInk { get; set; }
    public decimal EnvelopeImprintLeft { get; set; }
    public bool EnvelopeImprintShow { get; set; }
    public decimal EnvelopeImprintTop { get; set; }
    public decimal EnvelopeImprintWidth { get; set; }
    public char EnvelopeLogoAlignmentX { get; set; }
    public char EnvelopeLogoAlignmentY { get; set; }
    public decimal EnvelopeLogoHeight { get; set; }
    public decimal EnvelopeLogoLeft { get; set; }
    public string EnvelopeLogoName { get; set; }
    public bool EnvelopeLogoShow { get; set; }
    public decimal EnvelopeLogoTop { get; set; }
    public decimal EnvelopeLogoWidth { get; set; }
    public string EnvelopePersonalize1 { get; set; }
    public string EnvelopePersonalize2 { get; set; }
    public string EnvelopePersonalize3 { get; set; }
    public string EnvelopePersonalize4 { get; set; }
    public string EnvelopeTypeStyle { get; set; }
    public decimal EnvelopeWidth { get; set; }
    public char IconAlignmentX { get; set; }
    public char IconAlignmentY { get; set; }
    public decimal IconHeight { get; set; }
    public decimal IconLeft { get; set; }
    public decimal IconTop { get; set; }
    public decimal IconWidth { get; set; }
    public string ImprintInk { get; set; }
    public string LogoName { get; set; }
    public bool LogoShow { get; set; }
    public decimal MessageFontSize { get; set; }
    public bool MessageShow { get; set; }
    public string MessageTypeStyle { get; set; }
    public string Personalize1 { get; set; }
    public string Personalize2 { get; set; }
    public string Personalize3 { get; set; }
    public string Personalize4 { get; set; }
    public string PTextSize { get; set; }
    public string ResolutionType { get; set; }
    public string SessionID { get; set; }
    public string StandardVerse { get; set; }
    public char TextAlignmentX { get; set; }
    public char TextAlignmentY { get; set; }
    public decimal TextHeight { get; set; }
    public decimal TextLeft { get; set; }
    public decimal TextTop { get; set; }
    public decimal TextWidth { get; set; }
    public string TypeStyle { get; set; }
    public char VerseAlignmentX { get; set; }
    public char VerseAlignmentY { get; set; }
    public decimal VerseFontSize { get; set; }
    public decimal VerseHeight { get; set; }
    public string VerseID { get; set; }
    public decimal VerseLeft { get; set; }
    public string VerseSize { get; set; }
    public decimal VerseTop { get; set; }
    public string VerseType { get; set; }
    public decimal VerseWidth { get; set; }
}

 
Expand Methods
 


End

public class HammondDal
{
    // Fields
    public static int height;

    // Methods
    [DebuggerNonUserCode]
    public HammondDal();
    public static void ChangeImageColor(Hammond obj);
    public static byte[] ConvertImageToByteArray(Image imageIn);
    public static string CreateCardHighProof(Hammond obj);
    public static void CreateCardLowProof(Hammond obj);
    public static string CreateEnvelopeHighProof(Hammond obj);
    public static void CreateEnvelopeLowProof(Hammond obj);
    public static ImageCodecInfo GetEncoderInfo(string sMime);
    public static void ResizeImage(Image srcImage, double scaleFactorX, double scaleFactorY, string toStream);
    public static Image SetResolution(Image sourceImage, int resolution);
    public static float TwipsToPixelsX(float twips, string resType);
    public static float TwipsToPixelsY(float twips, string resType);

    // Nested Types
    public enum HammondCardSuppliers
    {
        Birchcraft = 3,
        CarlsonCraft = 10,
        Tatex = 2
    }
}

 
Expand Methods