using Muchinfo.PC.Common.Helpers; using System.Collections.Generic; using System.Windows; namespace Muchinfo.MTPClient.Infrastructure.Helpers { /// /// 抬头字段匹配类 /// public static class QuoteFieldMapHelper { #region Fields private static readonly List DefaultColorFields; private static readonly List DirectDisplayFields; private static readonly Dictionary FieldMap; private static readonly List RightAlignFields; private static readonly List ChanageBorderFields; #endregion Fields #region Constructors static QuoteFieldMapHelper() { FieldMap = new Dictionary(FormatHelper.StringEqualityComparer) { {"MarketCode", "GoodsCode"}, {"SName", "Name"}, {"Time", "Date"}, {"Buy", "BidPrice"}, {"Sell", "AskPrice"}, {"Pr", "CurrentPrice"}, {"ChgRt", "IncreasePercent"}, {"OpenPr", "Open"}, {"HighPr", "High"}, {"LowPr", "Low"}, {"ClosePrLast", "LastClose"}, {"YClear", "LastSettlement"}, {"Chg", "IncreaseValue"}, {"Amplitude", "Amplitude"}, {"position", "Positions"}, {"Addp", "DayAddPositions"}, {"Volume", "CurrentVolume"}, {"TVolume", "TotalVolume"}, {"BidVolume", "BidVolume"}, {"AskVolume", "AskVolume"}, {"WtUnit", "QuoteUnit"}, {"BoardLot", "LotUnit"}, {"Currency", "QuoteCurrency"}, {"Exchange", "ExchangeName"}, {"Sort", "SortName"}, {"APr", "AveragePrice"}, {"TrdSum", "TradeTurnover"}, {"Vratio", "QuantityRelativeRatio"}, {"OverturnRt", "TurnoverRate"}, {"PE", "PriceEarningRatio"}, {"Insite", "InSize"}, {"outsite", "OutSize"}, {"ORatio", "WeiBi"}, {"Ospread", "WeiCha"}, {"LShares", "NegotiableShares"}, {"LMktVal", "MarketCapitalizations"}, {"TShares", "TotalEquity"} }; //默认颜色的字段集合 DefaultColorFields = new List() { "Amplitude", "GoodsCode", "Date", "SortName", "LastClose", "LotUnit", "CurrentVolume", "AskVolume", "BidVolume", "QuoteCurrency","TotalVolume","LastSettlement", "Positions","DayAddPositions","QuoteUnit","TradeTurnover","TotalTurnover","TurnoverRate", "PriceEarningRatio","NegotiableShares","MarketCapitalizations","TotalEquity", "ExchangeName", }; //直接显示的字段集合 DirectDisplayFields = new List { "GoodsCode", "Name", "LotUnit", "QuoteUnit", "SortName", "ExchangeName", "QuoteCurrency" }; RightAlignFields = new List() { //"GoodsCode", "Name" ,"Date","SortName","ExchangeName","DeliveryDate","QuoteCurrency","QuoteUnit" }; //当行情价格改变时,显示边框的字段 ChanageBorderFields = new List() { "BidPrice", "AskPrice", "CurrentPrice" }; } #endregion Constructors #region Methods #region Public Static Methods /// /// 设置字段对齐方式 /// /// Name of the field. /// TextAlignment. public static TextAlignment GetFieldAlign(string fieldName) { return RightAlignFields.Contains(fieldName) ? TextAlignment.Right : TextAlignment.Center; } /// /// 是否是格式化的显示字段 /// /// Name of the field. /// true if [is display field] [the specified field name]; otherwise, false. public static bool IsDisplayField(string fieldName) { return !DirectDisplayFields.Contains(fieldName); } /// /// 获取映射后的字段颜色名称 /// /// 映射字段名称 /// 字段颜色名称 public static string MapColorField(string fieldName) { if (DefaultColorFields.Contains(fieldName)) return "DefaultColor"; else return fieldName + "Color"; } /// /// 获取映射后的字段名称 /// /// 字段名称 /// 映射字段名称 public static string MapField(string fieldName) { if (FieldMap.ContainsKey(fieldName)) return FieldMap[fieldName]; else return fieldName; } /// /// 是否为显示边框的字段 /// /// 映射字段名称 /// true为显示边框的字段,否则为false public static bool IsShowBorderField(string fieldName) { if (string.IsNullOrWhiteSpace(fieldName)) return false; return ChanageBorderFields.Contains(fieldName); } /// /// 获取映射显示变化的边框的字段 /// /// 字段名称 /// 行情绑定的字段名 public static string MapShowBorderField(string fieldName) { return "Is" + fieldName + "Border"; } #endregion Public Static Methods #endregion Methods } }