Ejemplo n.º 1
0
 private void cb_DPI_SelectedIndexChanged(object sender, EventArgs e)
 {
     selectedDPI = a4sizes[cb_DPI.SelectedIndex];
     Properties.Settings.Default.s_DPI = cb_DPI.SelectedIndex;
     Properties.Settings.Default.Save();
 }
Ejemplo n.º 2
0
        public int[] getPicData(int pic_num, pagestructs sch, a4size a, out int cw, out int ch)
        {
            int[] possize = new int[4];
            int   picnum  = pic_num;
            int   col     = 0;
            int   row     = 0;

            cw = 0;
            ch = 0;

            int top  = a.margin;
            int left = a.margin;

            int wid = 0;
            int hei = 0;

            foreach (int i in sch.picsPerCol)
            {
                if (picnum - i >= 0)
                {
                    picnum -= i;
                    int h = i == 1 ? a.halfheight : (sch.picsPerCol.Contains(1) ? a.fourthheight : a.thirdheight);
                    top += h;
                    top += a.padding;
                }
                else
                {
                    col = picnum;

                    int l = 0;

                    wid = i == 1 ? a.fullwidth : (i == 2 ? a.halfwidth : (i == 3 ? a.thirdwidth : a.fourthwidth));
                    hei = i == 1 ? a.halfheight : (sch.picsPerCol.Contains(1) ? a.fourthheight : a.thirdheight);

                    cw = wid;
                    ch = hei;

                    switch (i)
                    {
                    case 1:
                        l = 0;
                        break;

                    case 2:
                        l = a.halfwidth;
                        break;

                    case 3:
                        l = a.thirdwidth;
                        break;

                    case 4:
                        l = a.fourthwidth;
                        break;
                    }

                    for (int ii = 0; ii < col; ii++)
                    {
                        left += l + a.padding;
                    }

                    picnum = i;
                    break;
                }

                row++;
            }

            possize[0] = left;              //LEFT
            possize[1] = top;               //TOP
            possize[2] = wid;               //WIDTH
            possize[3] = hei;               //HEIGHT

            return(possize);
        }
Ejemplo n.º 3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            foreach (dpi d in Enum.GetValues(typeof(dpi)))
            {
                a4size a = new a4size();

                switch (d)
                {
                case dpi.d_72:
                    a._dpi    = dpi.d_72;
                    a.width   = 595;
                    a.height  = 842;
                    a.margin  = 15;
                    a.padding = 8;
                    break;

                case dpi.d_100:
                    a._dpi    = dpi.d_100;
                    a.width   = 827;
                    a.height  = 1169;
                    a.margin  = 20;
                    a.padding = 10;
                    break;

                case dpi.d_140:
                    a._dpi    = dpi.d_140;
                    a.width   = 1157;
                    a.height  = 1637;
                    a.margin  = 27;
                    a.padding = 14;
                    break;

                case dpi.d_200:
                    a._dpi    = dpi.d_200;
                    a.width   = 1654;
                    a.height  = 2339;
                    a.margin  = 41;
                    a.padding = 22;
                    break;

                case dpi.d_300:
                    a._dpi    = dpi.d_300;
                    a.width   = 2480;
                    a.height  = 3508;
                    a.margin  = 61;
                    a.padding = 32;
                    break;

                case dpi.d_400:
                    a._dpi    = dpi.d_400;
                    a.width   = 3307;
                    a.height  = 4677;
                    a.margin  = 81;
                    a.padding = 42;
                    break;

                case dpi.d_600:
                    a._dpi    = dpi.d_600;
                    a.width   = 4961;
                    a.height  = 7016;
                    a.margin  = 121;
                    a.padding = 63;
                    break;

                case dpi.d_1200:
                    a._dpi    = dpi.d_1200;
                    a.width   = 9921;
                    a.height  = 14031;
                    a.margin  = 241;
                    a.padding = 125;
                    break;

                case dpi.dd_30:
                    a._dpi    = dpi.dd_30;
                    a.width   = 248;
                    a.height  = 351;
                    a.margin  = 5;
                    a.padding = 3;
                    break;
                }

                a.fullheight   = a.height - (2 * a.margin);
                a.halfheight   = (a.height - ((2 * a.margin) + a.padding)) / 2;
                a.thirdheight  = (a.height - ((2 * a.margin) + (2 * a.padding))) / 3;
                a.fourthheight = (a.height - ((2 * a.margin) + (3 * a.padding))) / 4;
                a.fullwidth    = a.width - (2 * a.margin);
                a.halfwidth    = (a.width - ((2 * a.margin) + a.padding)) / 2;
                a.thirdwidth   = (a.width - ((2 * a.margin) + (2 * a.padding))) / 3;
                a.fourthwidth  = (a.width - ((2 * a.margin) + (3 * a.padding))) / 4;

                a4sizes.Add(a);

                cb_BlackBG.Checked = Properties.Settings.Default.s_BlackBG;
                cb_Borders.Checked = Properties.Settings.Default.s_Borders;
            }

            foreach (Schemes v in Enum.GetValues(typeof(Schemes)))
            {
                pagestructs ps = new pagestructs();

                switch (v)
                {
                case Schemes.s133:
                    ps.sch        = Schemes.s133;
                    ps.positions  = new int[] { 1, 3, 3, 3, 3, 3, 3 };
                    ps.pics       = 7;
                    ps.picsPerCol = new int[] { 1, 3, 3 };
                    break;

                case Schemes.s134:
                    ps.sch        = Schemes.s134;
                    ps.positions  = new int[] { 1, 3, 3, 3, 4, 4, 4, 4 };
                    ps.pics       = 8;
                    ps.picsPerCol = new int[] { 1, 3, 4 };
                    break;

                case Schemes.s212:
                    ps.sch        = Schemes.s212;
                    ps.positions  = new int[] { 2, 2, 1, 2, 2 };
                    ps.pics       = 5;
                    ps.picsPerCol = new int[] { 2, 1, 2 };
                    break;

                case Schemes.s232:
                    ps.sch        = Schemes.s232;
                    ps.positions  = new int[] { 2, 2, 3, 3, 3, 2, 2 };
                    ps.pics       = 7;
                    ps.picsPerCol = new int[] { 2, 3, 2 };
                    break;

                case Schemes.s313:
                    ps.sch        = Schemes.s313;
                    ps.positions  = new int[] { 3, 3, 3, 1, 3, 3, 3 };
                    ps.pics       = 7;
                    ps.picsPerCol = new int[] { 3, 1, 3 };
                    break;

                case Schemes.s323:
                    ps.sch        = Schemes.s323;
                    ps.positions  = new int[] { 3, 3, 3, 2, 2, 3, 3, 3 };
                    ps.pics       = 8;
                    ps.picsPerCol = new int[] { 3, 2, 3 };
                    break;

                case Schemes.s333:
                    ps.sch        = Schemes.s333;
                    ps.positions  = new int[] { 3, 3, 3, 3, 3, 3, 3, 3, 3 };
                    ps.pics       = 9;
                    ps.picsPerCol = new int[] { 3, 3, 3 };
                    break;

                case Schemes.s434:
                    ps.sch        = Schemes.s434;
                    ps.positions  = new int[] { 4, 4, 4, 4, 3, 3, 3, 4, 4, 4, 4 };
                    ps.pics       = 11;
                    ps.picsPerCol = new int[] { 4, 3, 4 };
                    break;
                }

                psl.Add(ps);
            }

            cb_Scheme.SelectedIndex = Properties.Settings.Default.s_Layout;
            cb_DPI.SelectedIndex    = Properties.Settings.Default.s_DPI;
            switch (Properties.Settings.Default.s_Output)
            {
            case 0:
                rb_PDF.Checked = true;
                break;

            case 1:
                rb_IMG.Checked = true;
                break;

            case 2:
                rb_HTML.Checked = true;
                break;

            default: rb_PDF.Checked = true; break;
            }
        }
Ejemplo n.º 4
0
        public List <Bitmap> createPositions(pagestructs p, List <string> pics, a4size a)
        {
            List <Bitmap> bmps = new List <Bitmap>();

            int numofPics = pics.Count;

            int picspp = p.pics;

            int numOfPages = (numofPics / picspp) + (numofPics % picspp == 0 ? 0 : 1);

            int i = 0;

            Bitmap b = new Bitmap(a.width, a.height);

            using (Graphics g = Graphics.FromImage(b))
            {
                g.Clear(Properties.Settings.Default.s_BlackBG ? Color.Black : Color.White);
            }

            foreach (String s in pics)
            {
                using (Graphics g = Graphics.FromImage(b))
                {
                    int   cw = 0;
                    int   ch = 0;
                    int[] r  = getPicData(i, p, a, out cw, out ch);
                    int[] r2 = new int[4];
                    for (int ii = 0; ii < 4; ii++)
                    {
                        r2[ii] = r[ii];
                    }
                    Bitmap bmp  = new Bitmap(s);
                    Size   res  = getSize(bmp.Width, bmp.Height, r[3], r[2]);
                    Size   res2 = new Size();


                    if (res.Width > cw)
                    {
                        res2 = new Size(r[2], res.Height); r[1] = r[1] + (r[3] / 2) - (res2.Height / 2);
                    }
                    else
                    {
                        res2 = new Size(res.Width, r[3]); r[0] += (r[2] - res2.Width) / 2;
                    }

                    g.DrawImage(bmp, new Rectangle(r[0], r[1], res2.Width, res2.Height));
                    if (Properties.Settings.Default.s_Borders)
                    {
                        if (Properties.Settings.Default.s_BlackBG)
                        {
                            g.DrawRectangle(Pens.White, new Rectangle(r2[0], r2[1], r2[2], r2[3]));
                        }
                        else
                        {
                            g.DrawRectangle(Pens.Black, new Rectangle(r2[0], r2[1], r2[2], r2[3]));
                        }
                    }
                }

                if (i == picspp - 1)
                {
                    bmps.Add(b);

                    if (a._dpi == dpi.dd_30)
                    {
                        break;
                    }

                    i = -1;
                    b = new Bitmap(a.width, a.height);
                    using (Graphics g = Graphics.FromImage(b))
                    {
                        g.Clear(Properties.Settings.Default.s_BlackBG ? Color.Black : Color.White);
                    }
                }
                else if (s == pics.Last())
                {
                    bmps.Add(b);
                }

                i++;
            }

            return(bmps);
        }