Beispiel #1
0
        //  This method does the actual translation into text.
        private void DoTranslation()
        {
            if (!this._fileLoaded)
            {
                MessageBox.Show("No file loaded... Please open a file and try again.");
            }
            else
            {
                try
                {
                    this.textBox1.Clear();
                    _outputFile = DefaultOutputFile;

                    // choose output file location, either a temp directory, or a user selected spot.
                    if (_saveToFile)
                    {
                        _outputFile = GetSaveFileName();
                    }
                    if (_outputFile == null)
                    {
                        return;
                    }

                    // delete the output file if one already exists
                    if (File.Exists(_outputFile))
                    {
                        File.Delete(_outputFile);
                    }

                    // OK, we're committed, put up the wait cursor
                    this.UseWaitCursor = true;
                    Cursor.Current     = Cursors.WaitCursor;

                    // this is how the image should be passed to the translator
                    FileSystemImageSource myIS = new FileSystemImageSource(_tempDir, true);

                    this.progressBar1.Value = 0;

                    // do the actual translation here.  The text is saved as a file in _outputFile.

                    _engine.Translate(myIS, _selectedMimeType, _outputFile);

                    if (!_saveToFile)
                    {
                        // Load the text back into the text box for display.
                        StreamReader input   = new StreamReader(_outputFile);
                        string       oneLine = input.ReadLine();
                        while (oneLine != null)
                        {
                            this.textBox1.AppendText(oneLine);
                            oneLine = input.ReadLine();
                        }
                        input.Close();
                    }
                    else
                    {
                        try
                        {
                            System.Diagnostics.Process.Start(_outputFile);
                        }
                        catch (Exception ex)
                        {
                            if (File.Exists(_outputFile))
                            {
                                InfoBox("File \"" + _outputFile + "\" is created.");
                            }
                            else
                            {
                                InfoBox(ex.ToString());
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    // if it's a license exception, it's probably because of pdfTranslator
                    if ((ex is AtalasoftLicenseException) && (_selectedMimeType == "application/pdf"))
                    {
                        LicenseCheckFailure("To generate PDF output, an Atalasoft PDF Translator license is required.", ex.Message);
                    }
                    else
                    {
                        InfoBox(ex.ToString());
                    }
                }
                finally
                {
                    this.UseWaitCursor = false;
                    progressBar1.Hide();
                }
            }
        }
Beispiel #2
0
        private void BatchSaveForUnitTests()
        {
            var path = @"d:\Programs\Benchmarks\Fraps\Screenshots";

            var pb = new ProgressBar();
            pb.Maximum = 18;
            pb.Dock = DockStyle.Bottom;
            Controls.Add(pb);
            pb.Show();

            foreach (var file in Directory.GetFiles(path, "*.png"))
            {
                var bmp = Bitmap.FromFile(file) as Bitmap;
                var result = Screenshot.GetTooltip(bmp, false);
                if (result == null)
                {
                    Debugger.Break();
                    return;
                }

                var tt = new D3Bit.Tooltip(result);
                var r = new Results(tt);

                pbItem.Image = tt.Processed;

                SaveForUnitTests(r, result, bmp.Size);
                pb.Increment(1);
                Trace.TraceInformation("Saved " + r.Name);
                bmp.Dispose();
            }
            pb.Hide();
            MessageBox.Show("Done!");
        }
Beispiel #3
0
        private void addFileTransferRcv(string fileName, string userName)
        {
            iFileTransCntRcv++;

            string sRCV = "RCV";
            Label label = new Label();
            label.Name = "lblFileTransfer" + sRCV + iFileTransCntRcv;
            label.Text = fileName + "\n" + "전송대기";

            ProgressBar progressBar = new ProgressBar();
            progressBar.Name = "pgbFileTransfer" + sRCV + iFileTransCntRcv;
            pnlFileListRcv.Controls.Add(label);
            pnlFileListRcv.Controls.Add(progressBar);

            label.Top = iLabelGap + iPnlHeightRcv;
            label.Left = 3 + iPnlLeftRcv;
            label.Height = 25;
            label.BackColor = System.Drawing.Color.Aqua;
            label.Font = new Font("굴림", 9, FontStyle.Regular);

            progressBar.Top = iLabelGap + iPnlHeightRcv;
            progressBar.Left = 3 + label.Left;
            progressBar.Hide();

            Button btnOk = new Button();
            btnOk.Text = "수신";
            btnOk.Click += new EventHandler(btnOkClick);
            btnOk.Top = iLabelGap + iPnlHeightRcv;
            btnOk.Left = 3 + label.Width;
            btnOk.Height = 18;
            btnOk.Width = 45;
            btnOk.Font = new Font("굴림", 8, FontStyle.Regular);

            Button btnCancel = new Button();
            btnCancel.Text = "거부";
            btnCancel.Click += new EventHandler(btnCancelClick);
            btnCancel.Top = iLabelGap + iPnlHeightRcv;
            btnCancel.Left = 3 + label.Width + btnOk.Width + 3;
            btnCancel.Height = 18;
            btnCancel.Width = 45;
            btnCancel.Font = new Font("굴림", 8, FontStyle.Regular);

            pnlFileListRcv.Controls.Add(btnOk);
            pnlFileListRcv.Controls.Add(btnCancel);
            btnOk.BringToFront();
            btnCancel.BringToFront();

            setShortFileName(label, fileName);

            chatBox2.AppendText("Height=" + label.Height + " : Top=" + label.Top + "\n");

            iPnlHeightRcv += label.Height;

            if (!pnlFileStatus.Visible)
            {
                pnlFileStatus.Visible = true;
            }
        }