private void OnMouseUp(object sender, MouseEventArgs e)
        {
            m_isMouseDown = false;


            // this.Close();
            this.Invalidate();
            if (m_rect.Width <= 0 || m_rect.Height <= 0)
            {
                return;
            }

            var bmp = m_canvas.Clone(m_rect, m_canvas.PixelFormat);

            //bmp.Save("D:\\555.png", ImageFormat.Png);
            Debug.WriteLine("Send image");
            String ocrStr = "";

            try
            {
                ocrStr = BaiduOcr.GetInstance().send(CaptureHelpers.Bitmap2Byte(bmp));

                if ("" == ocrStr)
                {
                    throw new Exception("返回结果为空");
                }
            } catch (Exception exp)
            {
                MessageBox.Show("OCR解析出错误: " + exp.Message);
            }

            var result = new BaiduTranslate().translate(ocrStr);

            Console.Write("解析结果: ");
            Console.WriteLine(result);

            var form = new TranslateResultForm(result.src, result.dst);

            form.ShowDialog();

            this.Close();
            //this.Invalidate(new Region(new Rectangle((int)x, (int)y, (int)rect.Width, (int)rect.Height)));
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            var form = new TranslateResultForm("原文内容显示", "这里是译文显示");

            form.ShowDialog();
        }