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 AssistClient.UI.PropExtend;
using static AssistClient.UI.UIAxisDev;
namespace AssistClient.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(24), Browsable(true), Category("1 数据"), DisplayName("1.5 X轴反馈位置(mm)"), Description("实际/反馈位置"), JsonIgnore]
public double PosX { get; set; }
[PropertyOrder(24), Browsable(true), Category("1 数据"), DisplayName("1.5 Y轴反馈位置(mm)"), Description("实际/反馈位置"), JsonIgnore]
public double PosY { 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.4 禁用工序"), Description("禁用本工序")]
public bool Disable { get; set; }
///
/// 序列化
///
///
///
public string serialize()
{
return JsonConvert.SerializeObject(this);
}
///
/// 反序列化
///
///
///
public void deserialize(string json)
{
var o= JsonConvert.DeserializeObject(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);
}
}
}
}
}