using System.Drawing;
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;
//using System.Windows.Forms;

namespace WpfApp1.WinOcr
{
    internal class OcrSofia : Sofia
    {
        static string path = Directory.GetCurrentDirectory() + "\\TempImage";

        public OcrSofia() { }

        public string WindowsOcrToGetStringAndTranslate(string name)
        {
            string retxt = "";

            this.DirExists();
            Image image = null;
            /*
            MODI.Document modiDocument = new MODI.Document();
            modiDocument.Create(path + "\\" + name + ".jpg");
            modiDocument.OCR(MODI.MiLANGUAGES.miLANG_CHINESE_SIMPLIFIED, true, true);
            MODI.Image modiImage = (MODI.Image)modiDocument.Images[0];
            retxt = modiImage.Layout.Text;
            */
            return retxt;
        }

        public void DirExists()
        {
            if(Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
        }

/*
internal class OcrSofia : Sofia
    {
        public OcrSofia() { }

        public string WindowsOcrToGetStringAndTranslate()
        {
            string result = "";

            // 获取剪贴板中的图像
            Image image = Clipboard.GetImage();

            // 将图像保存到临时文件中
            string tempFile = Path.GetTempFileName();
            image.Save(tempFile, ImageFormat.Tiff);

            // 使用Windows OCR引擎识别图像中的文本
            MODI.Document modiDocument = new MODI.Document();
            modiDocument.Create(tempFile);
            modiDocument.OCR(MODI.MiLANGUAGES.miLANG_CHINESE_SIMPLIFIED, true, true);
            MODI.Image modiImage = (MODI.Image)modiDocument.Images[0];
            result = modiImage.Layout.Text;

            // 删除临时文件
            File.Delete(tempFile);

            return result;
        }
    }
*/
    }
}
