-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add new OCR Corrections form ("Edit" button on Corrections tab)
- Loading branch information
1 parent
f6a7b6d
commit 60791da
Showing
9 changed files
with
477 additions
and
28 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Data; | ||
using System.Drawing; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
using Microsoft.SqlServer.Server; | ||
|
||
namespace RegulatedNoise | ||
{ | ||
public partial class EditOcrResults : Form | ||
{ | ||
private string _startOfRow, _endOfRow; | ||
public string ReturnValue; | ||
|
||
public EditOcrResults(string dataToEdit) | ||
{ | ||
InitializeComponent(); | ||
lbEditOcrResults.Items.Clear(); | ||
|
||
var rows = dataToEdit.Split(new string[] {"\r\n"}, StringSplitOptions.None); | ||
|
||
foreach (var row in rows) | ||
{ | ||
if(row.Contains(';')) | ||
lbEditOcrResults.Items.Add(row); | ||
} | ||
} | ||
|
||
private bool suspendTextChanged = false; | ||
|
||
private void lbEditOcrResults_SelectedIndexChanged(object sender, EventArgs e) | ||
{ | ||
suspendTextChanged = true; | ||
var row = lbEditOcrResults.Text; | ||
var rowId = row.Substring(row.LastIndexOf(";", System.StringComparison.Ordinal)+1); | ||
|
||
if (pbEditOcrResultsOriginalImage.Image != null) | ||
pbEditOcrResultsOriginalImage.Image.Dispose(); | ||
|
||
if (File.Exists(".//OCR Correction Images//" + rowId + ".png")) | ||
pbEditOcrResultsOriginalImage.Image = Bitmap.FromFile(".//OCR Correction Images//" + rowId + ".png"); | ||
|
||
var results = row.Split(';'); | ||
if (results.GetLength(0) > 7) | ||
{ | ||
tbEditOcrResultsCommodityName.Text = results[2]; | ||
tbEditOcrResultsSellPrice.Text = results[3]; | ||
tbEditOcrResultsBuyPrice.Text = results[4]; | ||
tbEditOcrResultsDemand.Text = results[5]; | ||
tbEditOcrResultsDemandLevel.Text = results[6]; | ||
tbEditOcrResultsSupply.Text = results[7]; | ||
tbEditOcrResultsSupplyLevel.Text = results[8]; | ||
_startOfRow = results[0] + ";" + results[1] + ";"; | ||
_endOfRow = results[9]+";"+results[10]+";"+results[11]; | ||
} | ||
suspendTextChanged = false; | ||
|
||
} | ||
|
||
private void tbEditOcrResultTextChanged(object sender, EventArgs e) | ||
{ | ||
if (suspendTextChanged) return; | ||
|
||
lbEditOcrResults.SelectedIndexChanged -= lbEditOcrResults_SelectedIndexChanged; | ||
lbEditOcrResults.Items[lbEditOcrResults.SelectedIndex] = _startOfRow + | ||
tbEditOcrResultsCommodityName.Text + ";" + | ||
tbEditOcrResultsSellPrice.Text + ";" + | ||
tbEditOcrResultsBuyPrice.Text + ";" + | ||
tbEditOcrResultsDemand.Text + ";" + | ||
tbEditOcrResultsDemandLevel.Text + ";" + | ||
tbEditOcrResultsSupply.Text + ";" + | ||
tbEditOcrResultsSupplyLevel.Text + ";" + | ||
_endOfRow | ||
; | ||
|
||
lbEditOcrResults.SelectedIndexChanged += lbEditOcrResults_SelectedIndexChanged; | ||
} | ||
|
||
private void bEditOcrResultsOK_Click(object sender, EventArgs e) | ||
{ | ||
foreach (var x in lbEditOcrResults.Items) | ||
{ | ||
ReturnValue += x + "\r\n"; | ||
} | ||
DialogResult= DialogResult.OK; | ||
Close(); | ||
} | ||
} | ||
} |
Oops, something went wrong.