banboshi_V1/halftoneproject-master/Code/UI/SizeLibProp.cs
2023-10-31 13:19:29 +08:00

98 lines
5.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using Advantech.Motion;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using ProductionControl.UI.PropExtend;
using static ProductionControl.UI.UIAxisDev;
namespace ProductionControl.UI
{
//[TypeConverter(typeof(PropertySorter))] //此属性使类无法序列化和反序列化
public class SizeLibProp
{
//[PropertyOrder(1), Browsable(true), Category("1 数据"), DisplayName("1.1 引擎路径"), Description("引擎路径")]
//public string EnginePath { get; set; }
[PropertyOrder(1), Browsable(true), Category("1 数据"), DisplayName("1.2 引擎文件名"), Description("引擎文件名")]
public string EngineName { get; set; }
[PropertyOrder(1), Browsable(true), Category("1 数据"), DisplayName("1.3 源图"), Description("源图"), JsonIgnore]
public string BmpPath { get; set; }
[PropertyOrder(1), Browsable(true), Category("1 数据"), DisplayName("1.4 索引"), Description("索引 0-9")]
public int Index { get; set; }
[PropertyOrder(1), Browsable(true), Category("1 数据"), DisplayName("1.5 保存标识"), Description("供后续轴移动时引用此标识数据,不设则在本工序内立即进行轴校正。")]
public string SizeTag { get; set; }
[PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("PT1"), Description("结果"), ReadOnly(true), JsonIgnore]
public double PT1 { get; set; }
[PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("PT2"), Description("结果"), ReadOnly(true), JsonIgnore]
public double PT2 { get; set; }
[PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("Shanxian"), Description("结果"), ReadOnly(true), JsonIgnore]
public double Shanxian { get; set; }
//[PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("RowP"), Description("结果"), ReadOnly(true), JsonIgnore]
//public double RowP { get; set; }
[PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("Circle_Ymm"), Description("结果"), ReadOnly(true), JsonIgnore]
public double Circle_Ymm { get; set; }
[PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("Circle_Xmm"), Description("结果"), ReadOnly(true), JsonIgnore]
public double Circle_Xmm { get; set; }
[PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("offsetX"), Description("结果"), ReadOnly(true), JsonIgnore]
public double offsetX { get; set; }
[PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("offsetY"), Description("结果"), ReadOnly(true), JsonIgnore]
public double offsetY { get; set; }
[PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("Mark点"), Description("Mark点"), ReadOnly(true), JsonIgnore]
public double[] MarkPointList { get; set; }
[PropertyOrder(15), Browsable(true), Category("2 结果"), DisplayName("信息"), Description("信息"), ReadOnly(true), JsonIgnore]
public string resultInfo { get; set; }
[PropertyOrder(25), Browsable(true), Category("3 控制"), DisplayName("3.1 运行前Sleep(ms)"), Description("休息时间")]
public uint SleepPre { get; set; }
[PropertyOrder(26), Browsable(true), Category("3 控制"), DisplayName("3.2 运行后Sleep(ms)"), Description("休息时间")]
public uint SleepLater { get; set; }
[PropertyOrder(27), Browsable(true), Category("3 控制"), DisplayName("3.3 异步运行"), Description("非阻塞后续流程运行(True-是False-否)")]
public bool AsynRun { get; set; } = true;
[PropertyOrder(28), Browsable(true), Category("3 控制"), DisplayName("3.4 禁用工序"), Description("禁用本工序(True-是False-否)")]
public bool Disable { get; set; }
/// <summary>
/// 序列化
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public string serialize()
{
return JsonConvert.SerializeObject(this);
}
/// <summary>
/// 反序列化
/// </summary>
/// <param name="json"></param>
/// <returns></returns>
public void deserialize(string json)
{
var o= JsonConvert.DeserializeObject<SizeLibProp>(json);
Type type = o.GetType();
System.Reflection.PropertyInfo[] properties = type.GetProperties();
foreach (System.Reflection.PropertyInfo property in properties)
{
string name = property.Name;
if (!type.GetProperty(name).IsDefined(typeof(JsonIgnoreAttribute), true))
{
var value = property.GetValue(o);
this.GetType().GetProperty(name).SetValue(this, value);
}
}
}
}
}