Exemplo n.º 1
0
        public static string[] getDrugDose(Bitmap source)
        {
            ///////////// ini 객체 생성 시작 /////////////////////////////////////////////////////
            //현재 프로그램이 실행되고 있는정보 가져오기: 디버깅 모드라면 bin/debug/프로그램명.exe
            FileInfo exefileinfo = new FileInfo(@"C:\Program Files\PLOCR\PLOCR.exe");
            string   pathini     = exefileinfo.Directory.FullName.ToString(); //프로그램 실행되고 있는데 path 가져오기
            string   fileName    = @"\PLOCRconfig.ini";                       // 환경설정 파일명
            string   filePath    = pathini + fileName;                        //ini 파일 경로

            PLOCR.IniUtil ini = new PLOCR.IniUtil(filePath);                  // 만들어 놓았던 iniUtil 객체 생성(생성자 인자로 파일경로 정보 넘겨줌)
            //////////// ini 객체 생성 끝 /////////////////////////////////////////////////////////

            int ct = 0;

            String[] tText = new String[13];  // 약품코드, 투약량, 횟수, 일수의 세로 13칸을 텍스트 배열로 넣기위해

            decimal[] x3old  = new decimal[13];
            decimal[] y3old  = new decimal[13];
            int[]     x3new  = new int[13];
            int[]     y3new  = new int[13];
            int[]     width  = new int[13];
            int[]     height = new int[13];

            do
            {
                string checkDoseX = ini.GetIniValue((ct + 1).ToString() + "번" + " " + "투약량", "X");
                if (checkDoseX != "")    // 환경설정에서 좌표가 설정되어 있지 않은 구역을 읽으려 할 경우 오류를 막기 위해서
                {
                    x3old[ct] = decimal.Parse(checkDoseX);
                }
                else
                {
                    MessageBox.Show("환경설정에서 투약량 X 좌표를 설정해주세요.");
                    System.Diagnostics.Process.GetCurrentProcess().Kill();      // 프로그램 강제 종료
                }
                string checkDoseY = ini.GetIniValue((ct + 1).ToString() + "번" + " " + "투약량", "Y");
                if (checkDoseY != "")
                {
                    y3old[ct] = decimal.Parse(checkDoseY);
                }
                else
                {
                    MessageBox.Show("환경설정에서 투약량 Y 좌표를 설정해주세요.");
                    System.Diagnostics.Process.GetCurrentProcess().Kill();      // 프로그램 강제 종료
                }
                decimal x1new = (decimal)Global.coordNo1X;
                decimal x2new = (decimal)Global.coordNo2X;
                x3new[ct] = NewPointX(x3old[ct], x1new, x2new);
                decimal y1new = (decimal)Global.coordNo1Y;
                decimal y2new = (decimal)Global.coordNo2Y;
                y3new[ct] = NewPointY(y3old[ct], y1new, y2new);
                string checkDoseWidth = ini.GetIniValue((ct + 1).ToString() + "번" + " " + "투약량", "가로");
                if (checkDoseWidth != "")
                {
                    width[ct] = int.Parse(checkDoseWidth);
                }
                else
                {
                    MessageBox.Show("환경설정에서 투약량 가로 좌표를 설정해주세요.");
                    System.Diagnostics.Process.GetCurrentProcess().Kill();      // 프로그램 강제 종료
                }
                string checkDoseHeight = ini.GetIniValue((ct + 1).ToString() + "번" + " " + "투약량", "세로");
                if (checkDoseHeight != "")
                {
                    height[ct] = int.Parse(checkDoseHeight);
                }
                else
                {
                    MessageBox.Show("환경설정에서 투약량 세로 좌표를 설정해주세요.");
                    System.Diagnostics.Process.GetCurrentProcess().Kill();      // 프로그램 강제 종료
                }

                //     MessageBox.Show("투약량 좌표는 : " + x3new[ct] + " " + y3new[ct]);

                tText[ct] = OcrEngine.ocrDoseLine(source, x3new[ct], y3new[ct], width[ct], height[ct]);

                //      MessageBox.Show("투약량은 = " + tText[ct]);

                if (string.IsNullOrEmpty(tText[ct]) == true)
                {
                    break;
                }

                ++ct;
            }while (ct < 13);
            {
                Global.Endct[2] = ct - 1;
                //     MessageBox.Show("Endcd[2]=" + Global.Endct[2]);
                return(tText);   // tText 배열로 텍스트 반환
            }
        }