using System; using System.Collections.Generic; using System.Linq; using System.Text; using Newtonsoft.Json; namespace POSV.Bean { [Serializable] [JsonObject(MemberSerialization.OptIn)] public class PrinterItem : IEquatable { /// /// 打印机ID /// [JsonProperty(PropertyName = "id")] public string Id { get; set; } = ""; /// /// 打印机名称 /// [JsonProperty(PropertyName = "name")] public string Name { get; set; } = ""; /// /// 打印机可用端口 /// [JsonProperty(PropertyName = "port")] public string Port { get; set; } /** * 打印机动态库支持 */ [JsonProperty(PropertyName = "dynamic")] public string DynamicLibrary { get; set; } /** * 打印机类型 */ [JsonProperty(PropertyName = "type")] public int Type { get; set; } /** * 打印机分辨率 */ [JsonProperty(PropertyName = "dpi")] public int Dpi { get; set; } /** * 页宽 */ [JsonProperty(PropertyName = "width")] public int PageWidth { get; set; } /// /// 打印机参数配置 /// [JsonProperty(PropertyName = "data")] public Dictionary Data { get; set; } /** * 初始化指令 */ [JsonProperty(PropertyName = "ic")] public string InitCommand { get; set; } /** * 倍宽字体指令 */ [JsonProperty(PropertyName = "dwc")] public string DoubleWidthCommand { get; set; } /** * 切纸指令 */ [JsonProperty(PropertyName = "cc")] public string CutPageCommand { get; set; } /** * 字体倍高指令 */ [JsonProperty(PropertyName = "dhc")] public string DoubleHeightCommand { get; set; } /** * 普通字体指令 */ [JsonProperty(PropertyName = "nc")] public string NormalCommand { get; set; } /** * 倍宽倍高指令 */ [JsonProperty(PropertyName = "dwhc")] public string DoubleWidthHeightCommand { get; set; } /** * 钱箱指令 */ [JsonProperty(PropertyName = "cashbox")] public string CashboxCommand { get; set; } /** * 是否顾客自己添加 */ [JsonProperty(PropertyName = "custom")] public int UserDefined { get; set; } /// /// 左对齐 /// [JsonProperty(PropertyName = "left")] public string AlignLeftCommand { get; set; } = "27,97,48"; /// /// 右对齐 /// [JsonProperty(PropertyName = "center")] public string AlignCenterCommand { get; set; } = "27,97,49"; /// /// 右对齐 /// [JsonProperty(PropertyName = "right")] public string AlignRightCommand { get; set; } = "27,97,50"; /// /// 回退纸张 /// [JsonProperty(PropertyName = "feedBack")] public string FeedBackCommand { get; set; } = "27,101,n"; /// /// 蜂鸣 /// [JsonProperty(PropertyName = "beep")] public string BeepCommand { get; set; } = "27,66"; public bool Equals(PrinterItem other) { if (other == null) { return false; } if (this.Data.Keys.Count != other.Data.Keys.Count) { return false; } foreach (var key in this.Data.Keys) { if (!(this.Data[key].Equals(other.Data[key]))) { return false; } } return this.Port == other.Port && this.Name == other.Name && this.Id == other.Id; } public override string ToString() { return this.Name; } } }