Exemplo n.º 1
0
        public void ConvertThread()
        {
            if (String.IsNullOrEmpty(SourcePath))
            {
                return;
            }

            //準備資料
            string JsonSourcePath = this.SourcePath;
            string BackupPath     = System.IO.Path.Combine(JsonSourcePath, "BackUp");

            Func.CheckDirExist(BackupPath);
            string        SourceFilePatten = "*.json";
            List <string> JsonFilePathSet  = Func.GetFilesFromDir(JsonSourcePath, SourceFilePatten, true);

            ProcessBarPage.SetMaxAndMin(0, JsonFilePathSet.Count);
            ProcessBarPage.SetProgressValue(0);
            DcmNotExistPath = new List <string>();


            #region 開始轉換

            #endregion
            for (int i = 0; i < JsonFilePathSet.Count; i++)
            {
                ProcessBarPage.SetProgressValue(i);
                string  JsonFilePath            = JsonFilePathSet[i];
                string  ImageFileNameWithOutExt = System.IO.Path.GetFileNameWithoutExtension(JsonFilePath);
                string  DcmFilePath             = JsonFilePath.Substring(0, JsonFilePath.Length - 5) + ".dcm";
                DcmInfo TempDcmInfo;
                if (Func.CheckFileExist(DcmFilePath))
                {
                    TempDcmInfo = Image_Func.DcmDetailData(DcmFilePath);
                }
                else
                {
                    //如果Json路徑下沒有dcm檔案則跳過此次轉換
                    DcmNotExistPath.Add(JsonFilePath);
                    continue;
                }
                #region 備份檔案到備份路徑
                string V1LogStr   = Func.ReadText(JsonFilePath);
                string BackUpPath = System.IO.Path.Combine(BackupPath, ImageFileNameWithOutExt + ".json");
                Func.WriteText(BackUpPath, V1LogStr);
                #endregion
                //讀取V1檔案
                if (SaveResultV2.IsVersion2(V1LogStr))
                {
                    //如果是V2版本則免轉換跳過
                    continue;
                }
                SaveResultV1 V1Log = SaveResultV1.ReadFile(JsonFilePath);
                //轉V2
                SaveResultV2 V2Log = SaveResultV2.Convert(V1Log, TempDcmInfo);
                //複寫V1版本
                SaveResultV2.SaveFile(V2Log, JsonFilePath);
            }
            ProcessBarPage.CloseWindows();
            OK();
        }
Exemplo n.º 2
0
 private void tbOpenFile_Click(object sender, EventArgs e)
 {
     if (OriginalImage != null)
     {
         //if (MessageBox.Show("是否要對上一次的操作結果儲存?", "確認", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
         //{
         //    SaveLabelFile();
         //}
         SaveLabelFile();
     }
     using (OpenFileDialog dialog = new OpenFileDialog())
     {
         dialog.Filter = "*.dcm|*.dcm|All File(*.*)|*.*";
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             ImagePath_Dcm = dialog.FileName;
             string dcmFileName    = System.IO.Path.GetFileNameWithoutExtension(ImagePath_Dcm);
             string targetFileName = dcmFileName + ".jpg";
             //檢查存檔路徑是否跟讀取影像有相同的影像,如果有則直接載入影像,如果沒有則轉檔載入
             string targetFilePath = Path.Combine(SettingObj.SavePath, targetFileName);
             RightNowInfo = Image_Func.DcmDetailData(ImagePath_Dcm);
             if (!Func.CheckFileExist(targetFilePath))
             {
                 //檔案不存在
                 string jpgFilePath = Image_Func.DcmToJPG(ImagePath_Dcm, SettingObj.SavePath);
                 targetFilePath = jpgFilePath;
             }
             ImagePath_Jpg = targetFilePath;
             //顯示在ImageBox
             Bitmap            image = (Bitmap)Bitmap.FromFile(ImagePath_Jpg);
             Image <Bgr, Byte> img   = new Image <Bgr, Byte>(image);
             SettingImage(img);
             LoadingLabelFile(ImagePath_Dcm, ImagePath_Jpg);
             AdjustmentInit(true);
             ImageProc();
         }
     }
 }