using GalaSoft.MvvmLight; using Muchinfo.MTPClient.Data.Helper; using Muchinfo.MTPClient.Data.Model; using Muchinfo.MTPClient.Resources; using System.Windows; using System.Windows.Media; namespace Muchinfo.MTPClient.Data.DTO { public class QuoteGoodsDTO : ObservableObject { #region Propertities /// /// 获取和设置标签(获取行情时用) /// public string Symbol { get { return _exchangeCode.PadLeft(3, ' ') + _goodsCode.PadLeft(6, ' '); } } /// /// ExchangeCode /// private string _exchangeCode; /// /// Sets and gets the ExchangeCode property. /// Changes to that property's value raise the PropertyChanged event. /// public string ExchHqCode { get { return _exchangeCode; } set { Set(() => ExchHqCode, ref _exchangeCode, value); } } /// /// GoodsCode /// private string _goodsCode; /// /// Sets and gets the GoodsCode property. /// Changes to that property's value raise the PropertyChanged event. /// public string GoodsCode { get { return _goodsCode; } set { Set(() => GoodsCode, ref _goodsCode, value); } } public string GoodsHqCode { get; set; } /// /// ShowIndex /// private int? _showIndex; /// /// Sets and gets the ShowIndex property. /// Changes to that property's value raise the PropertyChanged event. /// public int? ShowIndex { get { return _showIndex; } set { Set(() => ShowIndex, ref _showIndex, value); } } /// /// DateDisplay /// private string _dateDisplay; /// /// Sets and gets the DateDisplay property. /// Changes to that property's value raise the PropertyChanged event. /// public string DateDisplay { get { return _dateDisplay; } set { Set(() => DateDisplay, ref _dateDisplay, value); } } /// /// Name /// private string _name; /// /// Sets and gets the Name property. /// Changes to that property's value raise the PropertyChanged event. /// public string Name { get { // todo:商品字称最大长度 //int MaxLen = 2; //if (_name.Length > MaxLen) //{ // return _name.Substring(0, MaxLen) + "..."; //} return _name; } set { Set(() => Name, ref _name, value); } } private string _AgreeUnitDisplay; /// /// 合约单位显示 /// public string AgreeUnitDisplay { get { return _AgreeUnitDisplay; } set { _AgreeUnitDisplay = value; } } /// /// AskPriceDisplay /// private string _askPriceDisplay; /// /// Sets and gets the AskPriceDisplay property. /// Changes to that property's value raise the PropertyChanged event. /// public string AskPriceDisplay { get { return _askPriceDisplay; } set { Set(() => AskPriceDisplay, ref _askPriceDisplay, value); } } /// /// AskPriceColor /// private Brush _askPriceColor; /// /// Sets and gets the AskPriceColor property. /// Changes to that property's value raise the PropertyChanged event. /// public Brush AskPriceColor { get { return _askPriceColor; } set { Set(() => AskPriceColor, ref _askPriceColor, value); } } /// /// BidPriceDisplay /// private string _bidPriceDisplay; /// /// Sets and gets the BidPriceDisplay property. /// Changes to that property's value raise the PropertyChanged event. /// public string BidPriceDisplay { get { return _bidPriceDisplay; } set { Set(() => BidPriceDisplay, ref _bidPriceDisplay, value); } } private string _bidVolumeDisplay = string.Empty; /// /// 买量显示 /// Changes to that property's value raise the PropertyChanged event. /// public string BidVolumeDisplay { get { return _bidVolumeDisplay; } set { Set(() => BidVolumeDisplay, ref _bidVolumeDisplay, value); } } private string _askVolumeDisplay = string.Empty; /// /// 卖量显示 /// Changes to that property's value raise the PropertyChanged event. /// public string AskVolumeDisplay { get { return _askVolumeDisplay; } set { Set(() => AskVolumeDisplay, ref _askVolumeDisplay, value); } } /// /// BidPriceColor /// private Brush _bidPriceColor; /// /// Sets and gets the BidPriceColor property. /// Changes to that property's value raise the PropertyChanged event. /// public Brush BidPriceColor { get { return _bidPriceColor; } set { Set(() => BidPriceColor, ref _bidPriceColor, value); } } /// /// OpenDisplay /// private string _openDisplay; /// /// Sets and gets the OpenDisplay property. /// Changes to that property's value raise the PropertyChanged event. /// public string OpenDisplay { get { return _openDisplay; } set { Set(() => OpenDisplay, ref _openDisplay, value); } } /// /// OpenColor /// private Brush _openColor; /// /// Sets and gets the OpenColor property. /// Changes to that property's value raise the PropertyChanged event. /// public Brush OpenColor { get { return _openColor; } set { Set(() => OpenColor, ref _openColor, value); } } /// /// LastCloseDisplay /// private string _lastCloseDisplay; /// /// Sets and gets the LastCloseDisplay property. /// Changes to that property's value raise the PropertyChanged event. /// public string LastCloseDisplay { get { return _lastCloseDisplay; } set { Set(() => LastCloseDisplay, ref _lastCloseDisplay, value); } } /// /// LowDisplay /// private string _lowDisplay; /// /// Sets and gets the LowDisplay property. /// Changes to that property's value raise the PropertyChanged event. /// public string LowDisplay { get { return _lowDisplay; } set { Set(() => LowDisplay, ref _lowDisplay, value); } } /// /// LowColor /// private Brush _lowColor; /// /// Sets and gets the LowColor property. /// Changes to that property's value raise the PropertyChanged event. /// public Brush LowColor { get { return _lowColor; } set { Set(() => LowColor, ref _lowColor, value); } } /// /// HighDisplay /// private string _highDisplay; /// /// Sets and gets the HighDisplay property. /// Changes to that property's value raise the PropertyChanged event. /// public string HighDisplay { get { return _highDisplay; } set { Set(() => HighDisplay, ref _highDisplay, value); } } /// /// HighColor /// private Brush _highColor; /// /// Sets and gets the HighColor property. /// Changes to that property's value raise the PropertyChanged event. /// public Brush HighColor { get { return _highColor; } set { Set(() => HighColor, ref _highColor, value); } } /// /// IncreasePercentDisplay /// private string _increasePercentDisplay; /// /// Sets and gets the IncreasePercentDisplay property. /// Changes to that property's value raise the PropertyChanged event. /// public string IncreasePercentDisplay { get { return _increasePercentDisplay; } set { Set(() => IncreasePercentDisplay, ref _increasePercentDisplay, value); } } /// /// IncreasePercentColor /// private Brush _increasePercentColor; /// /// Sets and gets the IncreasePercentColor property. /// Changes to that property's value raise the PropertyChanged event. /// public Brush IncreasePercentColor { get { return _increasePercentColor; } set { Set(() => IncreasePercentColor, ref _increasePercentColor, value); } } /// /// IncreaseValueDisplay /// private string _increaseValueDisplay; /// /// Sets and gets the IncreaseValueDisplay property. /// Changes to that property's value raise the PropertyChanged event. /// public string IncreaseValueDisplay { get { return _increaseValueDisplay; } set { Set(() => IncreaseValueDisplay, ref _increaseValueDisplay, value); } } /// /// IncreaseValueColor /// private Brush _increaseValueColor; /// /// Sets and gets the IncreaseValueColor property. /// Changes to that property's value raise the PropertyChanged event. /// public Brush IncreaseValueColor { get { return _increaseValueColor; } set { Set(() => IncreaseValueColor, ref _increaseValueColor, value); } } private Brush _defaultColor; /// /// 默认颜色 /// public Brush DefaultColor { get { return _defaultColor; } set { Set(() => DefaultColor, ref _defaultColor, value); } } private Brush _goodsCodeColor; /// /// 商品代码颜色 /// public Brush GoodsCodeColor { get { return _goodsCodeColor; } set { Set(() => GoodsCodeColor, ref _goodsCodeColor, value); } } private Brush _nameColor; /// /// 商品名称颜色 /// public Brush NameColor { get { return _nameColor; } set { Set(() => NameColor, ref _nameColor, value); } } private decimal _lot; /// /// 商品下单数量-大字报价牌用 /// /// The lot. public decimal Lot { get { return _lot; } set { Set(() => Lot, ref _lot, value); } } private GoodsParameters _goodsParameters; /// /// 查询回来的商品参数 /// public GoodsParameters GoodsParameters { get { return _goodsParameters; } set { _goodsParameters = value; } } /// /// CurrentPriceDisplay /// private string _currentPriceDisplay; /// /// Sets and gets the CurrentPriceDisplay property. /// Changes to that property's value raise the PropertyChanged event. /// public string CurrentPriceDisplay { get { return _currentPriceDisplay; } set { Set(() => CurrentPriceDisplay, ref _currentPriceDisplay, value); } } /// /// CurrentPriceColor /// private Brush _currentPriceColor; /// /// Sets and gets the CurrentPriceColor property. /// Changes to that property's value raise the PropertyChanged event. /// public Brush CurrentPriceColor { get { return _currentPriceColor; } set { Set(() => CurrentPriceColor, ref _currentPriceColor, value); } } /// /// VolumeDisplay /// private string _currentvolumeDisplay; /// /// Sets and gets the VolumeDisplay property. /// Changes to that property's value raise the PropertyChanged event. /// public string CurrentVolumeDisplay { get { return _currentvolumeDisplay; } set { Set(() => CurrentVolumeDisplay, ref _currentvolumeDisplay, value); } } /// /// RaisesPriceDisplay /// private string _raisesPriceDisplay; /// /// 涨停价-显示字符 /// public string RaisesPriceDisplay { get { return _raisesPriceDisplay; } set { Set(() => RaisesPriceDisplay, ref _raisesPriceDisplay, value); } } /// /// 涨停价颜色 /// private Brush _raisesPriceColor; /// /// 涨停价颜色 /// /// The color of the raises price. public Brush RaisesPriceColor { get { return _raisesPriceColor; } set { Set(() => RaisesPriceColor, ref _raisesPriceColor, value); } } /// /// FallsPriceDisplay /// private string _fallsPriceDisplay; /// /// 跌停价-显示字符 /// public string FallsPriceDisplay { get { return _fallsPriceDisplay; } set { Set(() => FallsPriceDisplay, ref _fallsPriceDisplay, value); } } private string _turnoverRateDisplay; public string TurnoverRateDisplay { get { return _turnoverRateDisplay; } set { Set(() => TurnoverRateDisplay, ref _turnoverRateDisplay, value); } } /// /// 跌停价颜色 /// private Brush _fallsPriceColor; /// /// 跌停价颜色 /// public Brush FallsPriceColor { get { return _fallsPriceColor; } set { Set(() => FallsPriceColor, ref _fallsPriceColor, value); } } /// /// IsAskPriceBorder /// private bool _isAskPriceBorder; /// /// Sets and gets the IsAskPriceBorder property. /// Changes to that property's value raise the PropertyChanged event. /// public bool IsAskPriceBorder { get { return _isAskPriceBorder; } set { Set(() => IsAskPriceBorder, ref _isAskPriceBorder, value); } } /// /// IsCurrentPriceBorder /// private bool _isCurrentPriceBorder; /// /// Sets and gets the IsCurrentPriceBorder property. /// Changes to that property's value raise the PropertyChanged event. /// public bool IsCurrentPriceBorder { get { return _isCurrentPriceBorder; } set { Set(() => IsCurrentPriceBorder, ref _isCurrentPriceBorder, value); } } /// /// IsBidPriceBorder /// private bool _isBidPriceBorder; /// /// Sets and gets the IsBidPriceBorder property. /// Changes to that property's value raise the PropertyChanged event. /// public bool IsBidPriceBorder { get { return _isBidPriceBorder; } set { Set(() => IsBidPriceBorder, ref _isBidPriceBorder, value); } } private decimal _increaseValue; /// /// 涨跌(现价-昨收) /// /// The _increaseValue. public decimal IncreaseValue { get { return _increaseValue; } set { Set(() => IncreaseValue, ref _increaseValue, value); } } /// /// 市场ID /// public long GoodsGroupId { get; set; } private decimal _minOpenNumber; /// /// 最小建仓数量 /// public decimal MinOpenNumber { get { return _minOpenNumber; } set { Set(() => MinOpenNumber, ref _minOpenNumber, value); } } public uint GoodsId { get; set; } /// /// 交易端模式 /// public eTradeMode TradeMode { get; set; } private Visibility _mySelectedFlagVisibility = Visibility.Collapsed; /// /// 我的自选标记是否显示 /// /// My selected flag visibility. public Visibility MySelectedFlagVisibility { get { return _mySelectedFlagVisibility; } set { Set(() => MySelectedFlagVisibility, ref _mySelectedFlagVisibility, value); } } private string _totalVolumeDisplay; /// /// 总量 /// public string TotalVolumeDisplay { get { return _totalVolumeDisplay; } set { Set(() => TotalVolumeDisplay, ref _totalVolumeDisplay, value); } } private string _totalTurnoverDisplay; /// /// 总额 /// public string TotalTurnoverDisplay { get { return _totalTurnoverDisplay; } set { Set(() => TotalTurnoverDisplay, ref _totalTurnoverDisplay, value); } } private string _positionsDisplay; /// /// 持仓量 /// public string PositionsDisplay { get { return _positionsDisplay; } set { Set(() => PositionsDisplay, ref _positionsDisplay, value); } } /// /// 显示代码名称 /// //public string CodeNameDisplay //{ // get // { // return string.Format("{0}:{1}", GoodsCode, Name); // } //} private string _lastPositions; /// /// 昨持仓量 /// public string LastPositionsDisplay { get { return _lastPositions; } set { Set(() => LastPositionsDisplay, ref _lastPositions, value); } } private string _inventoryDisplay; /// /// 库存量 /// public string InventoryDisplay { get { return _inventoryDisplay; } set { Set(() => InventoryDisplay, ref _inventoryDisplay, value); } } /// /// 显示代码名称 /// public string CodeNameDisplay { get { return string.Format("{0}:{1}", GoodsCode, Name); } } #endregion #region Constructor /// /// Initializes a new instance of the class. /// /// The goods. public QuoteGoodsDTO(QuoteGoods goods) { if (goods == null) return; UpdateFromQuoteGoods(goods, false); } #endregion #region Methods /// /// 根据QuoteGoods更新实例 /// /// The goods. /// if set to true [is update]. /// QuoteGoodsDTO. public void UpdateFromQuoteGoods(QuoteGoods goods, bool isUpdate = true) { if (goods == null) return; if (!isUpdate) { ExchHqCode = goods.ExchHqCode; GoodsCode = goods.GoodsCode; GoodsHqCode = goods.GoodsHqCode; Name = goods.Name; ShowIndex = goods.ShowIndex; if (goods.GoodsParameters != null) { GoodsGroupId = goods.GoodsParameters.SortId; Lot = MinOpenNumber; TradeMode = goods.TradeMode; GoodsId = goods.GoodsId; } } DateDisplay = goods.DateDisplay; AskPriceDisplay = goods.AskPriceDisplay; AskVolumeDisplay = goods.AskVolumeDisplay; AskPriceColor = goods.AskPriceColor; BidPriceDisplay = goods.BidPriceDisplay; BidVolumeDisplay = goods.BidVolumeDisplay; BidPriceColor = goods.BidPriceColor; CurrentPriceColor = goods.CurrentPriceColor; CurrentPriceDisplay = goods.CurrentPriceDisplay; OpenDisplay = goods.OpenDisplay; OpenColor = goods.OpenColor; HighColor = goods.HighColor; HighDisplay = goods.HighDisplay; LowColor = goods.LowColor; LowDisplay = goods.LowDisplay; LastCloseDisplay = goods.LastCloseDisplay; IncreasePercentColor = goods.IncreasePercentColor; IncreasePercentDisplay = goods.IncreasePercentDisplay; IncreaseValueDisplay = goods.IncreaseValueDisplay; IncreaseValueColor = goods.IncreaseValueColor; DefaultColor = goods.DefaultColor; GoodsCodeColor = goods.GoodsCodeColor; NameColor = goods.NameColor; CurrentVolumeDisplay = goods.CurrentVolumeDisplay; RaisesPriceDisplay = goods.RaisesPriceDisplay; RaisesPriceColor = goods.RaisesPriceColor; FallsPriceDisplay = goods.FallsPriceDisplay; FallsPriceColor = goods.FallsPriceColor; // Lot = goods.Lot; //GoodsParameters = goods.GoodsParameters; AgreeUnitDisplay = goods.AgreeUnitDisplay; TotalVolumeDisplay = goods.TotalVolumeDisplay; TotalTurnoverDisplay = goods.TotalTurnoverDisplay; InventoryDisplay = goods.InventoryDisplay; PositionsDisplay = goods.PositionsDisplay; TurnoverRateDisplay = goods.TurnoverRateDisplay; IsAskPriceBorder = goods.IsAskPriceBorder; IsBidPriceBorder = goods.IsCurrentPriceBorder; IsCurrentPriceBorder = goods.IsCurrentPriceBorder; IncreaseValue = (goods.CurrentPrice == 0) ? 0 : goods.IncreaseValue; } #endregion #region "P+X分组属性" /// /// 交割商品名称(关联交易商品 存放交割商品名称) /// public string DeliveryGoodsName { get; set; } /// /// 仅用于P+X交割时表示P方还是X, X为主商品 true:X, false: P /// public bool IsMain { get; set; } /// /// 以P为主显示 /// /// The p and x display. public string PAndXDisplay { get { if (IsMain) return Client_Resource.Delivery_PDisplay; return Client_Resource.Delivery_XDisplay; } } /// /// P,X的tooltip, 以P为主显示 /// /// The p and x tool tip. public string PAndXToolTip { get { if (IsMain) return Client_Resource.Delivery_PDesc; return Client_Resource.Delivery_XDesc; } } /// /// 商品列表行背景色 /// /// The row background. public SolidColorBrush RowBackground { get { if (IsMain) return ResourceHelper.GetFromResource("QuoteRowBackgroundBrushP"); return new SolidColorBrush(Colors.Transparent); } } #endregion } }