57 lines
1.6 KiB
C#
57 lines
1.6 KiB
C#
using VisionCommon;
|
|
using Hermes;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.IO;
|
|
|
|
namespace MilPattern {
|
|
public class BarCodeParamExt : ICloneable {
|
|
private const string FILE_NAME = "BarCodeParamExt.json";
|
|
|
|
public ROI FindROI { get; set; } = new ROI();
|
|
|
|
public BarCodeParamExt() {
|
|
}
|
|
|
|
public BarCodeParamExt(ROI findRoi) {
|
|
FindROI = findRoi.Clone() as ROI;
|
|
}
|
|
|
|
public object Clone() {
|
|
return new BarCodeParamExt() {
|
|
FindROI = FindROI.Clone() as ROI
|
|
};
|
|
}
|
|
|
|
internal static BarCodeParamExt Load(string dirPath) {
|
|
string filePath = Path.Combine(dirPath, FILE_NAME);
|
|
|
|
if (File.Exists(filePath)) {
|
|
return JsonConvert.DeserializeObject(
|
|
File.ReadAllText(filePath), typeof(BarCodeParamExt)) as BarCodeParamExt;
|
|
}
|
|
|
|
return new BarCodeParamExt();
|
|
}
|
|
|
|
internal static int Save(string dirPath, BarCodeParamExt codeParamExt) {
|
|
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, codeParamExt);
|
|
}
|
|
|
|
return E1.OK;
|
|
}
|
|
}
|
|
}
|