| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- using Muchinfo.PC.Common.Helpers;
- using System.Collections.Generic;
- using System.Windows;
- namespace Muchinfo.MTPClient.Infrastructure.Helpers
- {
- /// <summary>
- /// 抬头字段匹配类
- /// </summary>
- public static class QuoteFieldMapHelper
- {
- #region Fields
- private static readonly List<string> DefaultColorFields;
- private static readonly List<string> DirectDisplayFields;
- private static readonly Dictionary<string, string> FieldMap;
- private static readonly List<string> RightAlignFields;
- private static readonly List<string> ChanageBorderFields;
- #endregion Fields
- #region Constructors
- static QuoteFieldMapHelper()
- {
- FieldMap = new Dictionary<string, string>(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<string>()
- {
- "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<string>
- {
- "GoodsCode", "Name", "LotUnit", "QuoteUnit", "SortName", "ExchangeName", "QuoteCurrency"
- };
- RightAlignFields = new List<string>()
- {
- //"GoodsCode", "Name" ,"Date","SortName","ExchangeName","DeliveryDate","QuoteCurrency","QuoteUnit"
- };
- //当行情价格改变时,显示边框的字段
- ChanageBorderFields = new List<string>()
- {
- "BidPrice", "AskPrice", "CurrentPrice"
- };
- }
- #endregion Constructors
- #region Methods
- #region Public Static Methods
- /// <summary>
- /// 设置字段对齐方式
- /// </summary>
- /// <param name="fieldName">Name of the field.</param>
- /// <returns>TextAlignment.</returns>
- public static TextAlignment GetFieldAlign(string fieldName)
- {
- return RightAlignFields.Contains(fieldName) ? TextAlignment.Right : TextAlignment.Center;
- }
- /// <summary>
- /// 是否是格式化的显示字段
- /// </summary>
- /// <param name="fieldName">Name of the field.</param>
- /// <returns><c>true</c> if [is display field] [the specified field name]; otherwise, <c>false</c>.</returns>
- public static bool IsDisplayField(string fieldName)
- {
- return !DirectDisplayFields.Contains(fieldName);
- }
- /// <summary>
- /// 获取映射后的字段颜色名称
- /// </summary>
- /// <param name="fieldName">映射字段名称</param>
- /// <returns>字段颜色名称</returns>
- public static string MapColorField(string fieldName)
- {
- if (DefaultColorFields.Contains(fieldName))
- return "DefaultColor";
- else
- return fieldName + "Color";
- }
- /// <summary>
- /// 获取映射后的字段名称
- /// </summary>
- /// <param name="fieldName">字段名称</param>
- /// <returns>映射字段名称</returns>
- public static string MapField(string fieldName)
- {
- if (FieldMap.ContainsKey(fieldName))
- return FieldMap[fieldName];
- else
- return fieldName;
- }
- /// <summary>
- /// 是否为显示边框的字段
- /// </summary>
- /// <param name="fieldName">映射字段名称</param>
- /// <returns>true为显示边框的字段,否则为false</returns>
- public static bool IsShowBorderField(string fieldName)
- {
- if (string.IsNullOrWhiteSpace(fieldName)) return false;
- return ChanageBorderFields.Contains(fieldName);
- }
- /// <summary>
- /// 获取映射显示变化的边框的字段
- /// </summary>
- /// <param name="fieldName">字段名称</param>
- /// <returns>行情绑定的字段名</returns>
- public static string MapShowBorderField(string fieldName)
- {
- return "Is" + fieldName + "Border";
- }
- #endregion Public Static Methods
- #endregion Methods
- }
- }
|