public ChooseOCRAreaPage()
        {
            InitializeComponent();

            Common.ocr = OCRCommon.OCRAuto(Common.appSettings.OCRsource);

            //初始化钩子对象
            if (hook == null)
            {
                hook = new GlobalHook();
                hook.OnMouseActivity += new System.Windows.Forms.MouseEventHandler(Hook_OnMouseActivity);
            }
        }
Пример #2
0
        public ComicTransMainWindow()
        {
            InitializeComponent();

            TransResListView.ItemsSource = lstData;

            ComicImgList = new List <string>();
            CurrentPos   = 0;

            transRes1    = "";
            transRes2    = "";
            _translator1 = TranslateWindow.TranslatorAuto(Common.appSettings.FirstTranslator);
            _translator2 = TranslateWindow.TranslatorAuto(Common.appSettings.SecondTranslator);

            ocr = OCRCommon.OCRAuto(Common.appSettings.OCRsource);
            ocr.SetOCRSourceLang("jpn");
            if (Common.appSettings.OCRsource == "BaiduOCR")
            {
                if (ocr.OCR_Init(Common.appSettings.BDOCR_APIKEY, Common.appSettings.BDOCR_SecretKey) == false)
                {
                    HandyControl.Controls.Growl.ErrorGlobal($"百度OCR {Application.Current.Resources["APITest_Error_Hint"]}\n{ocr.GetLastError()}");
                }
            }
            else if (Common.appSettings.OCRsource == "Tesseract5_vert")
            {
                if (ocr.OCR_Init("", "") == false)
                {
                    HandyControl.Controls.Growl.ErrorGlobal($"Tesseract5_vert {Application.Current.Resources["APITest_Error_Hint"]}\n{ocr.GetLastError()}");
                }
            }
            else if (Common.appSettings.OCRsource == "TesseractOCR")
            {
                if (ocr.OCR_Init("", "") == false)
                {
                    HandyControl.Controls.Growl.ErrorGlobal($"TesseractOCR {Application.Current.Resources["APITest_Error_Hint"]}\n{ocr.GetLastError()}");
                }
            }


            scale = Common.GetScale();
            DrawingAttributes drawingAttributes = new DrawingAttributes
            {
                Color     = Colors.Red,
                Width     = 2,
                Height    = 2,
                StylusTip = StylusTip.Rectangle,
                //FitToCurve = true,
                IsHighlighter  = false,
                IgnorePressure = true,
            };

            inkCanvasMeasure.DefaultDrawingAttributes = drawingAttributes;

            viewModel = new ViewModel
            {
                MeaInfo    = "",
                InkStrokes = new StrokeCollection(),
            };

            DataContext = viewModel;
        }