view MetroWpf/Stocks.UI/DisplayStockPrice.cs @ 20:6109bc268b90

Latest
author adminsh@apollo
date Tue, 20 Mar 2012 13:37:46 +0000
parents
children
line wrap: on
line source

using GalaSoft.MvvmLight;
using Stocks.Common.Models;

namespace Stocks.UI
{
    public class DisplayStockPrice : ObservableObject
    {
        public static DisplayStockPrice Create(Price price)
        {
            return new DisplayStockPrice()
                       {
                           Symbol = price.Symbol,
                           CurrentPrice = price.CurrentPrice,
                           PreviousPrice = price.PreviousPrice
                       };
        }

        public void Update(Price price)
        {
            Symbol = price.Symbol;
            CurrentPrice = price.CurrentPrice;
            PreviousPrice = price.PreviousPrice;
        }

        public const string SymbolPropertyName = "Symbol";
        private string _symbol;
        public string Symbol
        {
            get { return _symbol; }
            private set
            {
                if (_symbol == value) return;
                _symbol = value;
                RaisePropertyChanged(SymbolPropertyName);
            }
        }

        public const string CompanyNamePropertyName = "CompanyName";
        private string _companyName;
        public string CompanyName
        {
            get { return _companyName; }
            private set
            {
                if (_companyName == value) return;
                _companyName = value;
                RaisePropertyChanged(CompanyNamePropertyName);
            }
        }

        public const string CurrentPricePropertyName = "CurrentPrice";
        private decimal _currentPrice = 0;
        public decimal CurrentPrice
        {
            get { return _currentPrice; }
            private set
            {
                if (_currentPrice == value) return;
                _currentPrice = value;
                RaisePropertyChanged(CurrentPricePropertyName);
            }
        }

        public const string PreviousPricePropertyName = "PreviousPrice";
        private decimal _previousPrice = 0;
        public decimal PreviousPrice
        {
            get { return _previousPrice; }
            private set
            {
                if (_previousPrice == value) return;
                _previousPrice = value;
                RaisePropertyChanged(PreviousPricePropertyName);
            }
        }

        public const string DeltaPropertyName = "Delta";
        private decimal _delta = 0;
        public decimal Delta
        {
            get { return _delta; }
            private set
            {
                if (_delta == value) return;
                _delta = value;
                RaisePropertyChanged(DeltaPropertyName);
            }
        }
    }
}