Exemplo n.º 1
0
        public void processEpubFunction()
        {
            Properties.Settings setting = new Properties.Settings();

            Process process = new Process(this, setting.convDirectory);

            Process.setProgressBar1_Delegate spba  = new Process.setProgressBar1_Delegate(Process.setProgressBar1);
            Process.setProgressBar2_Delegate spba2 = new Process.setProgressBar2_Delegate(Process.setProgressBar2);
            Process.setProgressBar3_Delegate spba3 = new Process.setProgressBar3_Delegate(Process.setProgressBar3);
            Process.setProgressBar4_Delegate spba4 = new Process.setProgressBar4_Delegate(Process.setProgressBar4);
            Process.setProgressBar5_Delegate spba5 = new Process.setProgressBar5_Delegate(Process.setProgressBar5);
            this.Invoke(spba, 0, 0);
            this.Invoke(spba2, 0, 0);
            this.Invoke(spba3, 0, 0);
            this.Invoke(spba4, 0, 0);
            this.Invoke(spba5, 0, 0);

            UIDisable_Delegate uidd = new UIDisable_Delegate(UIDisable);
            UIEnable_Delegate  uied = new UIEnable_Delegate(UIEnable);

            this.Invoke(uidd);
            int count = filelistview.RowCount;

            canAccess = true;
            for (int i = 0; i < count; i++)
            {
                if (!canAccess)
                {
                    this.Invoke(spba, 0, 0);
                    this.Invoke(spba2, 0, 0);
                    this.Invoke(spba3, 0, 0);
                    this.Invoke(spba4, 0, 0);
                    this.Invoke(spba5, 0, 0);
                    break;
                }
                this.Invoke(spba, i, count);
                String cbzAddress = (String)filelistview.Rows[i].Cells[4].Value;
                process.DoProcessEpub(cbzAddress, (String)filelistview.Rows[i].Cells[2].Value, (String)filelistview.Rows[i].Cells[3].Value);
            }
            this.Invoke(uied);
        }
Exemplo n.º 2
0
 private void forApple_CheckedChanged(object sender, EventArgs e)
 {
     Properties.Settings setting = new Properties.Settings();
     forceResizing.Enabled = setting.forApple = true;
     setting.Save();
 }
Exemplo n.º 3
0
 private void resizeHeight_ValueChanged(object sender, EventArgs e)
 {
     Properties.Settings setting = new Properties.Settings();
     setting.userHeight = (int)resizeHeight.Value;
     setting.Save();
 }
Exemplo n.º 4
0
 private void resizeWidth_ValueChanged(object sender, EventArgs e)
 {
     Properties.Settings setting = new Properties.Settings();
     setting.userWidth = (int)resizeWidth.Value;
     setting.Save();
 }
Exemplo n.º 5
0
 private void doSplitCover_CheckedChanged(object sender, EventArgs e)
 {
     Properties.Settings setting = new Properties.Settings();
     setting.dosplitCover = doSplitCover.Checked;
     setting.Save();
 }
Exemplo n.º 6
0
        public Setting()
        {
            InitializeComponent();

            if (Properties.Settings.Default.convDirectory.Length == 0)
            {
                Properties.Settings temp = new Properties.Settings();
                temp.convDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                temp.Save();
            }

            Properties.Settings settings = new Properties.Settings();
            outputAddressBox.Text = settings.convDirectory;
            if (settings.direction.Equals("ltr"))
            {
                isLTR.Checked = true;
            }
            else
            {
                isRTL.Checked = true;
            }

            if (settings.forApple)
            {
                forceResizing.Enabled = true;
                forApple.Checked      = true;
            }
            else
            {
                forceResizing.Enabled = false;
                forGoogle.Checked     = true;
            }

            forceResizing.Checked = settings.forceResizing;

            if (settings.imagetype.Equals("jpeg"))
            {
                toJPG.Checked = true;
            }
            else if (settings.imagetype.Equals("png"))
            {
                toPNG.Checked = true;
            }
            else
            {
                toGIF.Checked = true;
            }

            quality.Value            = settings.quality;
            doSplitLandscape.Checked = settings.dosplitLandscape;
            doSplitCover.Checked     = settings.dosplitCover;
            resizeWidth.Value        = settings.userWidth;
            resizeHeight.Value       = settings.userHeight;

            string[] resizeTypeData = { "가운데 맞춤(기본)", "가로 고정", "세로 고정", "종횡비 무시", "리사이징 하지 않음" };
            resizeType.Items.AddRange(resizeTypeData);
            resizeType.SelectedIndex = settings.resizeType;
            switch (resizeType.SelectedIndex)
            {
            case 0:
            case 3:
                resizeWidth.Enabled  = true;
                resizeHeight.Enabled = true;
                break;

            case 1:
                resizeWidth.Enabled  = true;
                resizeHeight.Enabled = false;
                break;

            case 2:
                resizeWidth.Enabled  = false;
                resizeHeight.Enabled = true;
                break;

            case 4:
                resizeWidth.Enabled  = false;
                resizeHeight.Enabled = false;
                break;
            }
        }
Exemplo n.º 7
0
 private void isRTL_CheckedChanged(object sender, EventArgs e)
 {
     Properties.Settings setting = new Properties.Settings();
     setting.direction = "rtl";
     setting.Save();
 }
Exemplo n.º 8
0
        private void makeXHTML(String titleinXml, ref int currentWork, ref int totalWork)
        {
            Properties.Settings setting = new Properties.Settings();

            int metaWidth  = 0;
            int metaHeight = 0;

            var imagefiles = from file in Directory.GetFiles(Path.Combine(extractPath, "OEBPS")) orderby file ascending select file;

            totalWork = imagefiles.Count() + 5;
            foreach (string imagefile in imagefiles)
            {
                Image tempimage = Image.FromFile(imagefile);
                Size  size      = tempimage.Size;
                tempimage.Dispose();
                int Width = size.Width, Height = size.Height;

                if (metaWidth == 0)
                {
                    metaWidth = Width; metaHeight = Height;
                }

                StringBuilder sb = new StringBuilder();
                sb.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>");
                sb.AppendLine("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"");
                sb.AppendLine("\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">");
                sb.AppendLine("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">");
                sb.AppendLine("<head>");
                sb.AppendLine("<title>" + titleinXml + "</title>");
                if (!setting.forApple)
                {
                    sb.AppendLine("<style type=\"text/css\">body{width:" + Width + "px;height:" + Height + "px;margin:0;padding:0;}img {width:" + Width + "px;height:" + Height + "px;position:absolute;padding:0;margin:0;top:0;left:0;}</style>");
                    sb.AppendLine("<meta content=\"width=" + Width + ", height=" + Height + "\" name=\"viewport\" />");
                }
                else
                {
                    sb.AppendLine("<style type=\"text/css\">body{width:" + metaWidth + "px;height:" + metaHeight + "px;margin:0;padding:0;}");
                    if (setting.forceResizing)
                    {
                        sb.AppendLine("img {width:" + metaWidth + "px;height:" + metaHeight + "px;position:absolute;padding:0;margin:0;top:0;left:0;}</style>");
                    }
                    else
                    {
                        float nPercent = 0, nPercentW = 0, nPercentH = 0;
                        nPercentW = ((float)metaWidth / (float)Width);
                        nPercentH = ((float)metaHeight / (float)Height);

                        nPercent = (nPercentH < nPercentW) ? nPercentH : nPercentW;
                        int destWidth  = (int)(Width * nPercent);
                        int destHeight = (int)(Height * nPercent);

                        sb.AppendLine("img {width:" + destWidth + "px;height:" + destHeight + "px;position:absolute;padding:0;margin:0;top:" + ((metaHeight - destHeight) / 2) + ";left:" + ((metaWidth - destWidth) / 2) + ";}</style>");
                    }

                    sb.AppendLine("<meta content=\"width=" + metaWidth + ", height=" + metaHeight + "\" name=\"viewport\" />");
                }
                sb.AppendLine("</head>");
                sb.AppendLine("<body>");
                sb.AppendLine("<div><img alt=\"\" src=\"" + imagefile.Substring(imagefile.LastIndexOf("\\") + 1) + "\" /></div>");
                sb.AppendLine("</body>");
                sb.AppendLine("</html>");

                string XHTML = imagefile.Substring(imagefile.LastIndexOf("\\"));
                XHTML = XHTML.Substring(0, XHTML.LastIndexOf(".")) + ".xhtml";

                writeFile(extractPath, @"OEBPS\" + XHTML, sb.ToString(), Encoding.UTF8);

                form.Invoke(spb4, (currentWork++), totalWork);
            }
        }
Exemplo n.º 9
0
 private void SaveImage(ref Bitmap bm, int currentImageNum, ImageCodecInfo ic, EncoderParameters param)
 {
     Properties.Settings setting = new Properties.Settings();
     bm.Save(Path.Combine(extractPath, "OEBPS", String.Format("{0:D8}", currentImageNum) + "." + setting.imagetype), ic, param);
 }
Exemplo n.º 10
0
        private void processImages()
        {
            int Num_currentImage = 0, Num_totalImage = 0;

            //JPEG or PNG // and Quality
            ImageCodecInfo    imageCodec;
            EncoderParameters encoderParams = new EncoderParameters(1);

            Properties.Settings setting = new Properties.Settings();
            if (setting.imagetype.Equals("jpg"))
            {
                imageCodec             = getEncoderInfo("image/jpeg");
                encoderParams.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, (long)setting.quality);
            }
            else if (setting.imagetype.Equals("png"))
            {
                imageCodec             = getEncoderInfo("image/png");
                encoderParams.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Compression, 100L);
            }
            else
            {
                imageCodec             = getEncoderInfo("image/gif");
                encoderParams.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Compression, 100L);
            }

            // 2쪽 분할
            bool doSplitLandscape = setting.dosplitLandscape;

            // 표지 분할
            bool doSplitCover = setting.dosplitCover;

            // 리사이즈 유형
            int resizeType = 0;

            form.BeginInvoke((MethodInvoker) delegate
            {
                resizeType = setting.resizeType;
            });
            // 0. 가운데 맞춤(기본)
            // 1. 가로 맞춤
            // 2. 세로 맞춤
            // 3. 종횡비 무시
            // 4. 리사이징 하지 않음

            // 유저 지정 사이즈
            int userWidth  = (int)setting.userWidth;
            int userHeight = (int)setting.userHeight;

            int currentImageNum = 0;

            string[] filenames = Directory.GetFiles(Path.Combine(extractPath + @"\TEMP"));
            Num_totalImage = filenames.Count();

            foreach (string filename in filenames)
            {
                Bitmap   image = new Bitmap(filename);
                Bitmap   resized = null, cloneTempImage = null;
                Graphics g = null;
                int      sourceWidth = image.Width;
                int      sourceHeight = image.Height;
                int      destWidth = 0, destHeight = 0;

                bool  isLandScape = sourceWidth > sourceHeight;
                float nPercent = 0, nPercentW = 0, nPercentH = 0;

                switch (resizeType)
                {
                case 0:     // 0. 가운데 맞춤(기본)
                    if (isLandScape)
                    {
                        nPercentW = ((float)userWidth / (float)sourceWidth) * 2;
                    }
                    else
                    {
                        nPercentW = ((float)userWidth / (float)sourceWidth);
                    }

                    nPercentH = ((float)userHeight / (float)sourceHeight);

                    nPercent   = (nPercentH < nPercentW) ? nPercentH : nPercentW;
                    destWidth  = (int)(sourceWidth * nPercent);
                    destHeight = (int)(sourceHeight * nPercent);

                    resized = new Bitmap(userWidth, userHeight);

                    g = Graphics.FromImage(resized);
                    g.CompositingQuality = CompositingQuality.HighQuality;
                    g.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                    g.FillRectangle(new SolidBrush(Color.White), 0, 0, userWidth, userHeight);
                    break;


                case 1:    // 1. 가로 맞춤
                    if (isLandScape)
                    {
                        nPercentW = ((float)userWidth / (float)sourceWidth) * 2;
                    }
                    else
                    {
                        nPercentW = ((float)userWidth / (float)sourceWidth);
                    }

                    destWidth  = (int)(sourceWidth * nPercentW);
                    userHeight = destHeight = (int)(sourceHeight * nPercentW);


                    resized = new Bitmap(userWidth, destHeight);

                    g = Graphics.FromImage(resized);
                    g.CompositingQuality = CompositingQuality.HighQuality;
                    g.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                    g.FillRectangle(new SolidBrush(Color.White), 0, 0, destWidth, destHeight);
                    break;


                case 2:     // 2. 세로 맞춤
                    nPercentH = ((float)userHeight / (float)sourceHeight);

                    destWidth  = (int)(sourceWidth * nPercentH);
                    userWidth  = isLandScape ? destWidth / 2 : destWidth;
                    destHeight = (int)(sourceHeight * nPercentH);

                    resized = new Bitmap(isLandScape ? destWidth / 2 : destWidth, userHeight);

                    g = Graphics.FromImage(resized);
                    g.CompositingQuality = CompositingQuality.HighQuality;
                    g.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                    g.FillRectangle(new SolidBrush(Color.White), 0, 0, isLandScape ? destWidth / 2 : destWidth, destHeight);
                    break;

                case 3:    // 3. 종횡비 무시

                    destWidth  = isLandScape ? userWidth * 2 : userWidth;
                    destHeight = userHeight;

                    resized = new Bitmap(isLandScape ? destWidth / 2 : destWidth, userHeight);

                    g = Graphics.FromImage(resized);
                    g.CompositingQuality = CompositingQuality.HighQuality;
                    g.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                    g.FillRectangle(new SolidBrush(Color.White), 0, 0, isLandScape ? destWidth / 2 : destWidth, destHeight);
                    break;

                case 4:     // 4. 리사이징 하지 않음

                    destWidth  = sourceWidth;
                    userWidth  = isLandScape ? sourceWidth / 2 : sourceWidth;
                    destHeight = userHeight = sourceHeight;

                    resized = new Bitmap(isLandScape ? destWidth / 2 : destWidth, userHeight);

                    g = Graphics.FromImage(resized);
                    g.CompositingQuality = CompositingQuality.HighQuality;
                    g.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                    g.FillRectangle(new SolidBrush(Color.White), 0, 0, isLandScape ? destWidth / 2 : destWidth, destHeight);
                    break;
                }


                if (isLandScape)
                {
                    bool      isLTR = setting.direction.Equals("ltr");
                    Rectangle rect1, rect2;

                    if (filename.EndsWith("00000000.jpg", StringComparison.OrdinalIgnoreCase) ||
                        filename.EndsWith("00000000.png", StringComparison.OrdinalIgnoreCase) ||
                        filename.EndsWith("00000000.gif", StringComparison.OrdinalIgnoreCase))
                    {
                        if (doSplitCover)
                        {
                            rect1 = new Rectangle(isLTR ? sourceWidth / 2 : 0, 0, sourceWidth / 2, sourceHeight);
                            rect2 = new Rectangle(isLTR ? 0 : sourceWidth / 2, 0, sourceWidth / 2, sourceHeight);
                        }
                        else
                        {
                            rect1 = new Rectangle(isLTR ? 0 : sourceWidth / 2, 0, sourceWidth / 2, sourceHeight);
                            rect2 = new Rectangle(isLTR ? sourceWidth / 2 : 0, 0, sourceWidth / 2, sourceHeight);
                        }
                    }
                    else
                    {
                        rect1 = new Rectangle(isLTR ? 0 : sourceWidth / 2, 0, sourceWidth / 2, sourceHeight);
                        rect2 = new Rectangle(isLTR ? sourceWidth / 2 : 0, 0, sourceWidth / 2, sourceHeight);
                    }

                    g.DrawImage(cloneTempImage = image.Clone(rect1, image.PixelFormat), (userWidth - destWidth / 2) / 2, (userHeight - destHeight) / 2, destWidth / 2, destHeight);
                    SaveImage(ref resized, currentImageNum, imageCodec, encoderParams);
                    cloneTempImage.Dispose();
                    currentImageNum++;

                    g.FillRectangle(new SolidBrush(Color.White), 0, 0, userWidth, userHeight);

                    g.DrawImage(cloneTempImage = image.Clone(rect2, image.PixelFormat), (userWidth - destWidth / 2) / 2, (userHeight - destHeight) / 2, destWidth / 2, destHeight);
                    SaveImage(ref resized, currentImageNum, imageCodec, encoderParams);
                    cloneTempImage.Dispose();
                    currentImageNum++;
                }
                else
                {
                    g.DrawImage(image, (userWidth - destWidth) / 2, (userHeight - destHeight) / 2, destWidth, destHeight);
                    SaveImage(ref resized, currentImageNum, imageCodec, encoderParams);
                    currentImageNum++;
                }

                image.Dispose();
                resized.Dispose();
                g.Dispose();

                form.Invoke(spb3, (Num_currentImage++), Num_totalImage);
            }
        }
Exemplo n.º 11
0
 private void openFolder_Click(object sender, EventArgs e)
 {
     Properties.Settings setting = new Properties.Settings();
     System.Diagnostics.Process.Start("explorer.exe", setting.convDirectory);
 }