using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DW5S.ViewModel;
namespace DW5S.Entity
{
///
/// 指示某个属性需要导出
///
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public class ExportCellAttribute : Attribute
{
///
/// 指示某个属性需要导出
///
public ExportCellAttribute()
{
}
///
/// 指示某个属性需要导出
///
/// 浮点数(默认f4)、时间(默认yyyy-MM-dd HH:mm:ss)等导出时的格式化字符串
public ExportCellAttribute(string format)
{
this.Format = format;
}
///
/// 浮点数(默认f4)、时间(默认yyyy-MM-dd HH:mm:ss)等导出时的格式化字符串
///
public string Format { get; set; }
///
/// 列的排列顺序,未指定的ColumnIndex的按照属性顺序排在之后
///
public int ColumnIndex { get; set; } = -1;
}
///
/// 指示某个属性在ToolTip中显示
///
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public class ToolTipAttribute : Attribute
{
///
/// 指示某个属性在ToolTip中显示
///
public ToolTipAttribute()
{
}
///
/// 指示某个属性在ToolTip中显示
///
/// 浮点数(默认f4)、时间(默认yyyy-MM-dd HH:mm:ss)等导出时的格式化字符串
public ToolTipAttribute(string format)
{
this.Format = format;
}
///
/// 浮点数(默认f4)、时间(默认yyyy-MM-dd HH:mm:ss)等导出时的格式化字符串
///
public string Format { get; set; }
///
/// ToolTip从上到下的排列顺序,未指定的Index将按照属性顺序排在之后
///
public int Index { get; set; } = 10000;
}
///
/// 定位点绑定到地图的对象
///
public class PosData : BaseViewModel
{
///
/// 信号时刻
///
[Display(Name = "信号时刻")]
[DisplayFormat(DataFormatString = "yyyy-MM-dd HH:mm:ss.fff")]
[ExportCell(ColumnIndex = 0)]//如果导出了SigTime,则内部会自动按照SigTime降序排列后再导出
[ToolTip(Index = 0)]
public DateTime SigTime { get; set; }
///
/// 定位经度
///
[Display(Name = "定位经度", AutoGenerateField = false)]
[ExportCell("f4")]
[ToolTip("f4")]
public double PosLon { get; set; }
///
/// 定位纬度
///
[Display(Name = "定位纬度", AutoGenerateField = false)]
[ExportCell("f4")]
[ToolTip("f4")]
public double PosLat { get; set; }
///
/// 定位经度
///
[Display(Name = "镜像经度", AutoGenerateField = false)]
[ExportCell("f4")]
[ToolTip("f4")]
public double MirrLon { get; set; }
///
/// 定位纬度
///
[Display(Name = "镜像纬度", AutoGenerateField = false)]
[ExportCell("f4")]
[ToolTip("f4")]
public double MirrLat { get; set; }
///
/// 置信度
///
[Display(Name = "置信度")]
[ExportCell()]
[ToolTip()]
public int Confidence { get; set; }
///
/// 当前点是否被选中(默认false)
///
[Display(Name = "是否选中", AutoGenerateField = false)]
[NotMapped]
public bool Selected { get; set; }
///
/// 当前点是否可见(默认true)
///
[Display(Name = "是否可见", AutoGenerateField = false)]
[NotMapped]
public bool Visible { get; set; } = true;
///
/// 用于生成颜色的一个key,相同的key具有相同的颜色,当ColorKey为html颜色时则使用此颜色(如#A1B2FF),默认红色#CC3333
/// 、
[Display(Name = "颜色标记", AutoGenerateField = false)]
[NotMapped]
public string ColorKey { get; set; } = "#CC3333";
///
/// 判断定位点是否在一个框选的矩形区域内
///
///
///
///
///
///
public bool InRectangle(double startLon, double startLat, double endLon, double endLat)
{
return PosLon >= startLon && PosLon <= endLon && PosLat >= startLat && PosLat <= endLat;
}
///
/// 内部调用的属性
///
[Display(AutoGenerateField = false)]
[NotMapped]
public int ClusterCount { get; set; } = 1;
///
/// 内部调用的属性
///
[Display(AutoGenerateField = false)]
[NotMapped]
public int ClusterKey { get; set; } = int.MinValue;
}
}