/* * Copyright (c) 2025 LG Electronics Inc. * SPDX-License-Identifier: LicenseRef-LGE-Proprietary */ using VisionCommon; using Hermes; using Newtonsoft.Json; using System; using System.IO; namespace MilPattern { public class MmfParamExt : ICloneable { private const string FILE_NAME = "MmfParamExt.json"; public ROI FindROI { get; set; } = new ROI(); public bool IsQuickFind { get; set; } = false; public MmfParamExt() { } public MmfParamExt(ROI findRoi) { FindROI = findRoi.Clone() as ROI; } public object Clone() { return new MmfParamExt() { FindROI = FindROI.Clone() as ROI, IsQuickFind = this.IsQuickFind, }; } public static bool Exists(string dirPath) { string filePath = Path.Combine(dirPath, FILE_NAME); return File.Exists(filePath); } internal static MmfParamExt Load(string dirPath) { string filePath = Path.Combine(dirPath, FILE_NAME); if (File.Exists(filePath)) { return JsonConvert.DeserializeObject( File.ReadAllText(filePath), typeof(MmfParamExt)) as MmfParamExt; } return new MmfParamExt(); } public static int Save(string dirPath, MmfParamExt mmfParamExt) { string filePath = Path.Combine(dirPath, FILE_NAME); if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } using (var fs = File.Create(filePath)) using (var sw = new StreamWriter(fs)) using (var jtw = new JsonTextWriter(sw) { Formatting = Formatting.Indented, Indentation = 2, }) { (new JsonSerializer()).Serialize(jtw, mmfParamExt); } return E1.OK; } } }