Exemplo n.º 1
0
        private void btAppaly_Click(object sender, EventArgs e)
        {
            if (selectedData != null)
            {
                string settingPath = selectedData.GetSettingPath();
                string dbPath      = selectedData.GetDBPath();


                if (string.IsNullOrEmpty(settingPath) && string.IsNullOrEmpty(dbPath))
                {
                    System.Diagnostics.Process.Start(selectedData.GetDownloadLink());
                }
                else
                {
                    bool isDownloadComplete = false;
                    if (settingPath != "")
                    {
                        using (WebClient client = new WebClient())
                        {
                            Stream stream = client.OpenRead(settingPath);
                            using (StreamReader reader = new StreamReader(stream))
                            {
                                string data = reader.ReadToEnd();
                                data = data.Replace("\r\n", "\n").Replace("\n", System.Environment.NewLine);
                                Util.SaveFile(GlobalDefine.SETTING_PATH + selectedData.GetSettingFileName(), data);

                                isDownloadComplete = true;
                            }
                        }
                    }

                    if (dbPath != "")
                    {
                        using (WebClient client = new WebClient())
                        {
                            Stream stream = client.OpenRead(dbPath);
                            using (StreamReader reader = new StreamReader(stream))
                            {
                                string data = reader.ReadToEnd();
                                data = data.Replace("\r\n", "\n").Replace("\n", System.Environment.NewLine);
                                Util.SaveFile(GlobalDefine.DB_PATH + selectedData.GetDBFileName(), data);
                            }
                        }
                    }

                    if (isDownloadComplete)
                    {
                        settingPath = GlobalDefine.SETTING_PATH + selectedData.GetSettingFileName();

                        FormManager.Instace.MyMainForm.OpenSettingFile(settingPath);
                        string message = "적용 및 다운로드 완료!" + System.Environment.NewLine + "OCR 영역 및 번역 설정은 다시 확인해 주세요" +
                                         System.Environment.NewLine + System.Environment.NewLine +

                                         "[다운 받은 파일]" + System.Environment.NewLine + "설정파일 : " + settingPath;

                        if (dbPath != "")
                        {
                            dbPath   = GlobalDefine.DB_PATH + selectedData.GetDBFileName();
                            message += System.Environment.NewLine + "DB파일 : " + dbPath;
                        }
                        MessageBox.Show(message, "MORT");
                    }
                    else
                    {
                        MessageBox.Show("적용 실패 - 재시도해 주세요", "MORT");
                    }
                }
            }
        }