private static QueueThread Instance() { if (singleton == null) { singleton = new QueueThread(); } return(singleton); }
public void ShowMessage(String msg) { QueueThread.InvokeControl(statusStrip1, () => { toolStripProgressBar1.Visible = true; toolStripStatusLabel1.Text = msg; }); }
public void HideMessage() { QueueThread.InvokeControl(statusStrip1, () => { toolStripProgressBar1.Visible = false; toolStripStatusLabel1.Text = "Ready..."; }); }
private void EnableControl(bool enable) { QueueThread.InvokeForm(this, () => { button1.Enabled = enable; button2.Enabled = enable; button3.Enabled = enable; comboBox1.Enabled = enable; comboBox2.Enabled = enable; }); }
private void button3_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(textBox1.Text.Trim())) { MessageBox.Show("Please select the image file..."); } QueueThread.Push(() => { try { EnableControl(false); ShowMessage("Extracting..."); int index = QueueThread.InvokeControl(comboBox1, () => { return(comboBox1.SelectedIndex); }); String img = QueueThread.InvokeControl(textBox1, () => { return(textBox1.Text.Trim()); }); String path = QueueThread.InvokeControl(textBox2, () => { return(textBox2.Text.Trim()); }); int ocrtype = QueueThread.InvokeControl(comboBox2, () => { return(comboBox2.SelectedIndex); }); String text = ""; /*if (ocrtype == 1) * { * text = MODIOCRConverter.Run(img); * } * else * { * text = TessecratOCRConverter.Run(tessdatapath, index == 0 ? TessecratOCRConverter.LanguageType.ENG : TessecratOCRConverter.LanguageType.JPN, img); * }*/ text = TessecratOCRConverter.Run(tessdatapath, index == 0 ? TessecratOCRConverter.LanguageType.ENG : TessecratOCRConverter.LanguageType.JPN, img); ShowMessage("Saving..."); SaveFile(path, outputfile, text); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { HideMessage(); EnableControl(true); } }); }
public Main() { InitializeComponent(); QueueThread.Start(); comboBox1.Items.Add("ENG"); comboBox1.Items.Add("JPN"); comboBox2.Items.Add("GOOGLE(Tessecrat)"); comboBox2.Items.Add("MS(MODI)"); comboBox1.SelectedIndex = 0; comboBox2.SelectedIndex = 0; this.MaximumSize = this.Size; tessdatapath = Path.GetDirectoryName(Application.ExecutablePath); outputfile = "output.txt"; }