Example #1
0
        public void GetStartFromBuffer(LockBitmap[] buffer)
        {
            int   c;
            float ok, total;

            for (c = buffer.Length - 2; c >= 0; c--)
            {
                ok = 0; total = 0;
                foreach (Line line in lines)
                {
                    foreach (Letter l in line.letters)
                    {
                        foreach (Coord p in l.pixels)
                        {
                            total++;
                            if (ConversionThread.ColorDiff(buffer[c].GetPixel(p.x, p.y), Settings.subColor) < Settings.sameCharacterThreshold)
                            {
                                ok++;
                            }
                        }
                    }
                }
                if (ok / total < Settings.sameSubRange)
                {
                    break;
                }
            }
            if (c < 0)
            {
                c = 0;
            }
            startFrame = ConversionThread.frameIndex - buffer.Length + c;
            //Console.WriteLine("Inizio frame: " + startFrame);
            //Console.WriteLine("Inizio secondi: " + startFrame / Settings.frameRate);
        }
Example #2
0
        protected override void Convert()
        {
            var result = SautinSoftOffice.InitWord();

            if (result == 0) //succesfully opend program
            {
                do
                {
                    var document = ConversionQueue.Dequeue();

                    string newPath = "";

                    if (document.Name.EndsWith(SupportedExtension))
                    {
                        var newName = document.Name.Replace(SupportedExtension, Constants.PDFExtension);
                        newPath = document.FullPath.Replace(document.Name, newName);
                    }

                    result = SautinSoftOffice.ConvertFile(document.FullPath, newPath, UseOffice.eDirection.DOCX_to_PDF);
                } while (ConversionQueue.Count > 0);

                SautinSoftOffice.CloseWord();
            }

            ConversionThread.Abort();
        }
Example #3
0
        public bool GetEndFromBuffer(LockBitmap[] buffer)
        {
            int   c;
            float ok, total;

            ok = 0; total = 0;
            foreach (Line line in lines)
            {
                foreach (Letter l in line.letters)
                {
                    foreach (Coord p in l.pixels)
                    {
                        total++;
                        if (ConversionThread.ColorDiff(ConversionThread.frame.GetPixel(p.x, p.y), Settings.subColor) < Settings.sameCharacterThreshold)
                        {
                            ok++;
                        }
                    }
                }
            }
            if (ok / total > Settings.sameSubRange)
            {
                return(false);
            }

            for (c = buffer.Length - 2; c >= 0; c--)
            {
                ok = 0; total = 0;
                foreach (Line line in lines)
                {
                    foreach (Letter l in line.letters)
                    {
                        foreach (Coord p in l.pixels)
                        {
                            total++;
                            if (ConversionThread.ColorDiff(buffer[c].GetPixel(p.x, p.y), Settings.subColor) < Settings.sameCharacterThreshold)
                            {
                                ok++;
                            }
                        }
                    }
                }
                if (ok / total > Settings.sameSubRange)
                {
                    break;
                }
            }

            if (c < 0)
            {
                c = 0;
            }
            endFrame = ConversionThread.frameIndex - buffer.Length + c;
            //Console.WriteLine("Fine frame: " + endFrame);
            //Console.WriteLine("Fine secondi: " + endFrame / Settings.frameRate);
            CalculateSpaces();
            return(true);
        }
        void ExportFilesCmdExecuted(object target, ExecutedRoutedEventArgs e)
        {
            string folder = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
            var dlg1 = new Ionic.Utils.FolderBrowserDialogEx
            {
                Description = "Select a location to export to:",
                ShowNewFolderButton = true,
                ShowEditBox = true,
                NewStyle = true,
                RootFolder = System.Environment.SpecialFolder.MyComputer,
                SelectedPath = folder,
                ShowFullPathInEditBox = false,
            };

            var result = dlg1.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                folder = dlg1.SelectedPath;
            }
            else
            {
                return;
            }

            ProgressBarDialog progressBar = new ProgressBarDialog()
            {
                TotalThreads = fileList.Count
            };

            string folderName = Path.GetFileName(folder);
            if (string.IsNullOrWhiteSpace(folderName))
            {
                folderName = Path.GetRandomFileName();
            }

            using (FileStream file = File.Create(Path.Combine(folder, Path.ChangeExtension(folderName, ".manga"))))
            {
                file.WriteByte(0);
            }

            using (FileStream file = File.Create(Path.Combine(folder, Path.ChangeExtension(folderName, ".manga_save"))))
            {
                string output = string.Format("LAST=/mnt/us/pictures/{0}/{1}", folderName, fileList.First().OutputName);
                byte[] info = new UTF8Encoding(true).GetBytes(output);
                file.Write(info, 0, info.Length);
            }

            progressBar.CancellationTokenSource = new CancellationTokenSource();

            foreach (FileConversionInfo fileInfo in fileList)
            {
                fileInfo.OutputPath = Path.Combine(folder, fileInfo.OutputName);
                fileInfo.KindleProfile = this.SelectedProfile;
                ConversionThread thread = new ConversionThread(progressBar);
                ThreadPool.QueueUserWorkItem(thread.ThreadCallback, fileInfo);
            }

            progressBar.ShowDialog();
        }