Exemplo n.º 1
0
        /// <summary>
        /// 將檔案從V1版本轉成V2版本
        /// </summary>
        /// <param name="saveobj"></param>
        /// <returns></returns>
        public static SaveResultV2 Convert(SaveResultV1 saveobj, DcmInfo info)
        {
            SaveResultV2 Result = new SaveResultV2(saveobj.FileName);

            Result.SaveTime  = DateTime.Now;
            Result.KeyPoints = new List <Nullable <Point> >();
            #region 處理塑膠管
            Result.KeyPoints.AddRange(SaveResultV1.PointConvert(info.Width, info.Height, saveobj.tube));
            //foreach (Point p in saveobj.tube)
            //{
            //    Result.KeyPoints.Add(p);
            //}
            #endregion
            #region 處理氣管分岔
            foreach (List <Point> LP in saveobj.bifurcation)
            {
                Result.KeyPoints.AddRange(SaveResultV1.PointConvert(info.Width, info.Height, LP));
                //foreach (Point p in LP)
                //{
                //    Result.KeyPoints.Add(p);
                //}
            }
            #endregion
            //巡迴KetPoint後如果點數沒有等於4+3+3+3=13,就代表點數不完整,則遺棄所有的點
            if (Result.KeyPoints.Count != 13)
            {
                Result.KeyPoints = new List <Nullable <Point> >();
            }
            return(Result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 將紀錄檔寫入[如果檔案存在,則複寫檔案]
        /// </summary>
        /// <param name="Path">路徑</param>
        public static void SaveFile(SaveResultV2 saveobj, string Path)
        {
            string Jsonstr    = JsonConvert.SerializeObject(saveobj);
            string prettyJson = JValue.Parse(Jsonstr).ToString(Formatting.Indented);

            Func.WriteText(Path, prettyJson);
        }
Exemplo n.º 3
0
        public static List <SaveResultV2> ReadFile(List <string> Paths)
        {
            List <SaveResultV2> Logs = new List <SaveResultV2>();

            foreach (string path in Paths)
            {
                SaveResultV2 item = SaveResultV2.ReadFile(path);
                Logs.Add(item);
            }
            return(Logs);
        }
Exemplo n.º 4
0
 /// <summary>
 /// 從檔案讀取記錄檔
 /// </summary>
 /// <param name="Path">檔案路徑</param>
 /// <returns></returns>
 public static SaveResultV2 ReadFile(string Path)
 {
     if (Func.CheckFileExist(Path))
     {
         string       str     = Func.ReadText(Path);
         string       JsonStr = Func.ReadText(Path);
         SaveResultV2 item    = JsonConvert.DeserializeObject <SaveResultV2>(JsonStr);
         return(item);
     }
     else
     {
         throw new IOException("File Not Fount");
     }
 }
Exemplo n.º 5
0
        public static SaveResultV2 ReadFromString(string JsonStr, DcmInfo info)
        {
            SaveResultV2 item;

            if (SaveResultV2.IsVersion2(JsonStr))
            {
                item = JsonConvert.DeserializeObject <SaveResultV2>(JsonStr);
            }
            else
            {
                SaveResultV1 item_old = SaveResultV1.ConvertSaveFile(JsonStr);
                item = SaveResultV2.Convert(item_old, info);
            }
            return(item);
        }