private void btn_OK_Click(object sender, System.EventArgs e) { Model.Rect rect = new Model.Rect(); try { rect.Top = g_rect.Top; rect.Left = g_rect.Left; rect.Right = g_rect.Right; rect.Bottom = g_rect.Bottom; setPoint?.Invoke(tb_x, tb_y, rect); } catch { } g?.Dispose(); Close(); }
public void setPoint(TextBox tbx, TextBox tby, Model.Rect rect) { try { if (inRect(g_rect, rect)) { tbx.Text = ((rect.Left + rect.Right) / 2 - g_rect.Left).ToString(); tby.Text = ((rect.Top + rect.Bottom) / 2 - g_rect.Top).ToString(); if (tbx.Tag.Equals("goods")) { goodsRect = new Model.Rect(rect.Left - g_rect.Left, rect.Top - g_rect.Top, rect.Right - g_rect.Left, rect.Bottom - g_rect.Top); //getShot(goodsRect.Left + g_rect.Left, goodsRect.Top + g_rect.Top, goodsRect.Right - goodsRect.Left, goodsRect.Bottom - goodsRect.Top); } if (tbx.Tag.Equals("transaction")) { transactionRect = new Model.Rect(rect.Left - g_rect.Left, rect.Top - g_rect.Top, rect.Right - g_rect.Left, rect.Bottom - g_rect.Top); new Thread(tr => { Thread.Sleep(50); getShot(transactionRect.Left + g_rect.Left, transactionRect.Top + g_rect.Top, transactionRect.Right - transactionRect.Left, transactionRect.Bottom - transactionRect.Top, "transaction.jpg"); getTransactionData(Path.Combine(path, "transaction.jpg"), transaction_data, false); }).Start(); } if (tbx.Tag.Equals("price")) { priceRect = new Rect(rect.Left - g_rect.Left, rect.Top - g_rect.Top, rect.Right - g_rect.Left, rect.Bottom - g_rect.Top); new Thread(tr => { Thread.Sleep(50); getShot(priceRect.Left + g_rect.Left, priceRect.Top + g_rect.Top, priceRect.Right - priceRect.Left, priceRect.Bottom - priceRect.Top, "price.jpg"); getTransactionData(Path.Combine(path, "price.jpg"), price_data, false); }).Start(); } } } catch { } }
/// <summary> /// 是否包含 /// </summary> /// <param name="content"></param> /// <param name="rect"></param> /// <returns></returns> private bool inRect(Model.Rect content, Model.Rect rect) { return(rect.Left >= content.Left && rect.Top >= content.Top && rect.Right <= content.Right && rect.Bottom <= content.Bottom); }