private void mnuToolsOCRBitmapFile_Click(object sender, EventArgs e) { if (openFileDialog.ShowDialog() == DialogResult.OK) { CleanupDebugFiles(); PPOcr ppocr = new PPOcr(null); UnsafeBitmap bm = new UnsafeBitmap(openFileDialog.FileName); ppocr.ClearErrors(); Rectangle commodArea = ppocr.FindCommodityArea(bm); string island = ppocr.ExtractIslandName(bm); if (island == null || island.Length <= 0) { MessageBox.Show(this, "Can't find island name", Application.ProductName); } labelTitle.Text = "Island: " + island; List <Commodity> commodities = ppocr.ExtractCommodities(bm, commodArea); if (ppocr.Error.Length > 0) { MessageBox.Show(this, ppocr.Error, Application.ProductName); } if (commodities == null || commodities.Count <= 0) { dataGridView1.DataSource = null; } else { dataGridView1.DataSource = new List <Commodity>(commodities); } } }
private void CaptureMarketData() { try { CleanupDebugFiles(); ProcessWrapper procWrap = comboBoxPPWindows.SelectedItem as ProcessWrapper; if (procWrap == null || procWrap.Process == null || procWrap.Process.HasExited) { MessageBox.Show(this, "Can't find Puzzle Pirates window.", Application.ProductName); return; } PPOcr myOcr = new PPOcr(procWrap.Process); string island; DateTime dtStart = DateTime.Now; if (bidData != null) { bidData.Clear(); } allCommods = myOcr.ExtractAllCommodities(out island); this.BringToFront(); this.Activate(); if (myOcr.Error.Length > 0) { MessageBox.Show(this, myOcr.Error, Application.ProductName); } if (island == null || island.Length <= 0) { labelTitle.Text = "Island: Unknown"; } else { labelTitle.Text = "Island: " + island; } labelTitle.Text = labelTitle.Text + " on " + myOcr.Ocean; if (allCommods == null) { dataGridView1.DataSource = null; labelText.Text = "Rows: 0"; } else { DateTime dtStop = DateTime.Now; List <Commodity> list = new List <Commodity>(allCommods.Values); dataGridView1.DataSource = list; labelText.Text = "Rows: " + allCommods.Count.ToString() + " Rows/Sec: " + (Convert.ToDouble(allCommods.Count) / dtStop.Subtract(dtStart).TotalSeconds).ToString("N0"); } } catch (Exception ex) { MessageBox.Show(this, ex.Message.ToString() + "\n" + "\n" + ex.StackTrace.ToString(), Application.ProductName); } }