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

Latest
author adminsh@apollo
date Tue, 20 Mar 2012 13:37:46 +0000
parents
children
rev   line source
20
adminsh@apollo
parents:
diff changeset
1 using GalaSoft.MvvmLight;
adminsh@apollo
parents:
diff changeset
2 using Stocks.Common.Models;
adminsh@apollo
parents:
diff changeset
3
adminsh@apollo
parents:
diff changeset
4 namespace Stocks.UI
adminsh@apollo
parents:
diff changeset
5 {
adminsh@apollo
parents:
diff changeset
6 public class DisplayStockPrice : ObservableObject
adminsh@apollo
parents:
diff changeset
7 {
adminsh@apollo
parents:
diff changeset
8 public static DisplayStockPrice Create(Price price)
adminsh@apollo
parents:
diff changeset
9 {
adminsh@apollo
parents:
diff changeset
10 return new DisplayStockPrice()
adminsh@apollo
parents:
diff changeset
11 {
adminsh@apollo
parents:
diff changeset
12 Symbol = price.Symbol,
adminsh@apollo
parents:
diff changeset
13 CurrentPrice = price.CurrentPrice,
adminsh@apollo
parents:
diff changeset
14 PreviousPrice = price.PreviousPrice
adminsh@apollo
parents:
diff changeset
15 };
adminsh@apollo
parents:
diff changeset
16 }
adminsh@apollo
parents:
diff changeset
17
adminsh@apollo
parents:
diff changeset
18 public void Update(Price price)
adminsh@apollo
parents:
diff changeset
19 {
adminsh@apollo
parents:
diff changeset
20 Symbol = price.Symbol;
adminsh@apollo
parents:
diff changeset
21 CurrentPrice = price.CurrentPrice;
adminsh@apollo
parents:
diff changeset
22 PreviousPrice = price.PreviousPrice;
adminsh@apollo
parents:
diff changeset
23 }
adminsh@apollo
parents:
diff changeset
24
adminsh@apollo
parents:
diff changeset
25 public const string SymbolPropertyName = "Symbol";
adminsh@apollo
parents:
diff changeset
26 private string _symbol;
adminsh@apollo
parents:
diff changeset
27 public string Symbol
adminsh@apollo
parents:
diff changeset
28 {
adminsh@apollo
parents:
diff changeset
29 get { return _symbol; }
adminsh@apollo
parents:
diff changeset
30 private set
adminsh@apollo
parents:
diff changeset
31 {
adminsh@apollo
parents:
diff changeset
32 if (_symbol == value) return;
adminsh@apollo
parents:
diff changeset
33 _symbol = value;
adminsh@apollo
parents:
diff changeset
34 RaisePropertyChanged(SymbolPropertyName);
adminsh@apollo
parents:
diff changeset
35 }
adminsh@apollo
parents:
diff changeset
36 }
adminsh@apollo
parents:
diff changeset
37
adminsh@apollo
parents:
diff changeset
38 public const string CompanyNamePropertyName = "CompanyName";
adminsh@apollo
parents:
diff changeset
39 private string _companyName;
adminsh@apollo
parents:
diff changeset
40 public string CompanyName
adminsh@apollo
parents:
diff changeset
41 {
adminsh@apollo
parents:
diff changeset
42 get { return _companyName; }
adminsh@apollo
parents:
diff changeset
43 private set
adminsh@apollo
parents:
diff changeset
44 {
adminsh@apollo
parents:
diff changeset
45 if (_companyName == value) return;
adminsh@apollo
parents:
diff changeset
46 _companyName = value;
adminsh@apollo
parents:
diff changeset
47 RaisePropertyChanged(CompanyNamePropertyName);
adminsh@apollo
parents:
diff changeset
48 }
adminsh@apollo
parents:
diff changeset
49 }
adminsh@apollo
parents:
diff changeset
50
adminsh@apollo
parents:
diff changeset
51 public const string CurrentPricePropertyName = "CurrentPrice";
adminsh@apollo
parents:
diff changeset
52 private decimal _currentPrice = 0;
adminsh@apollo
parents:
diff changeset
53 public decimal CurrentPrice
adminsh@apollo
parents:
diff changeset
54 {
adminsh@apollo
parents:
diff changeset
55 get { return _currentPrice; }
adminsh@apollo
parents:
diff changeset
56 private set
adminsh@apollo
parents:
diff changeset
57 {
adminsh@apollo
parents:
diff changeset
58 if (_currentPrice == value) return;
adminsh@apollo
parents:
diff changeset
59 _currentPrice = value;
adminsh@apollo
parents:
diff changeset
60 RaisePropertyChanged(CurrentPricePropertyName);
adminsh@apollo
parents:
diff changeset
61 }
adminsh@apollo
parents:
diff changeset
62 }
adminsh@apollo
parents:
diff changeset
63
adminsh@apollo
parents:
diff changeset
64 public const string PreviousPricePropertyName = "PreviousPrice";
adminsh@apollo
parents:
diff changeset
65 private decimal _previousPrice = 0;
adminsh@apollo
parents:
diff changeset
66 public decimal PreviousPrice
adminsh@apollo
parents:
diff changeset
67 {
adminsh@apollo
parents:
diff changeset
68 get { return _previousPrice; }
adminsh@apollo
parents:
diff changeset
69 private set
adminsh@apollo
parents:
diff changeset
70 {
adminsh@apollo
parents:
diff changeset
71 if (_previousPrice == value) return;
adminsh@apollo
parents:
diff changeset
72 _previousPrice = value;
adminsh@apollo
parents:
diff changeset
73 RaisePropertyChanged(PreviousPricePropertyName);
adminsh@apollo
parents:
diff changeset
74 }
adminsh@apollo
parents:
diff changeset
75 }
adminsh@apollo
parents:
diff changeset
76
adminsh@apollo
parents:
diff changeset
77 public const string DeltaPropertyName = "Delta";
adminsh@apollo
parents:
diff changeset
78 private decimal _delta = 0;
adminsh@apollo
parents:
diff changeset
79 public decimal Delta
adminsh@apollo
parents:
diff changeset
80 {
adminsh@apollo
parents:
diff changeset
81 get { return _delta; }
adminsh@apollo
parents:
diff changeset
82 private set
adminsh@apollo
parents:
diff changeset
83 {
adminsh@apollo
parents:
diff changeset
84 if (_delta == value) return;
adminsh@apollo
parents:
diff changeset
85 _delta = value;
adminsh@apollo
parents:
diff changeset
86 RaisePropertyChanged(DeltaPropertyName);
adminsh@apollo
parents:
diff changeset
87 }
adminsh@apollo
parents:
diff changeset
88 }
adminsh@apollo
parents:
diff changeset
89 }
adminsh@apollo
parents:
diff changeset
90 }