Mercurial > silverbladetech
annotate MetroWpf/Stocks.UI/Models/DisplayStockPrice.cs @ 106:62477c2e8837
Command tests
author | stevenhollidge <stevenhollidge@hotmail.com> |
---|---|
date | Sun, 06 May 2012 13:00:46 +0100 |
parents | 399398841fd0 |
children |
rev | line source |
---|---|
23
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
1 using System; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
2 using GalaSoft.MvvmLight; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
3 using Stocks.Common.Models; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
4 |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
5 namespace Stocks.UI.Models |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
6 { |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
7 public class DisplayStockPrice : ObservableObject |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
8 { |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
9 public static DisplayStockPrice Create(Price price) |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
10 { |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
11 return new DisplayStockPrice() |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
12 { |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
13 CompanyName = price.CompanyName, |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
14 Symbol = price.Symbol, |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
15 CurrentPrice = price.CurrentPrice, |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
16 PreviousPrice = price.PreviousPrice, |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
17 Timestamp = DateTime.Now |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
18 }; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
19 } |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
20 |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
21 public void Update(Price price) |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
22 { |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
23 Symbol = price.Symbol; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
24 CurrentPrice = price.CurrentPrice; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
25 PreviousPrice = price.PreviousPrice; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
26 Delta = price.CurrentPrice - price.PreviousPrice; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
27 Timestamp = DateTime.Now; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
28 } |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
29 |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
30 public const string SymbolPropertyName = "Symbol"; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
31 private string _symbol; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
32 public string Symbol |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
33 { |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
34 get { return _symbol; } |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
35 private set |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
36 { |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
37 if (_symbol == value) return; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
38 _symbol = value; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
39 RaisePropertyChanged(SymbolPropertyName); |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
40 } |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
41 } |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
42 |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
43 public const string CompanyNamePropertyName = "CompanyName"; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
44 private string _companyName; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
45 public string CompanyName |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
46 { |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
47 get { return _companyName; } |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
48 private set |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
49 { |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
50 if (_companyName == value) return; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
51 _companyName = value; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
52 RaisePropertyChanged(CompanyNamePropertyName); |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
53 } |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
54 } |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
55 |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
56 public const string CurrentPricePropertyName = "CurrentPrice"; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
57 private decimal _currentPrice = 0; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
58 public decimal CurrentPrice |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
59 { |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
60 get { return _currentPrice; } |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
61 private set |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
62 { |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
63 if (_currentPrice == value) return; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
64 _currentPrice = value; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
65 RaisePropertyChanged(CurrentPricePropertyName); |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
66 } |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
67 } |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
68 |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
69 public const string PreviousPricePropertyName = "PreviousPrice"; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
70 private decimal _previousPrice = 0; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
71 public decimal PreviousPrice |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
72 { |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
73 get { return _previousPrice; } |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
74 private set |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
75 { |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
76 if (_previousPrice == value) return; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
77 _previousPrice = value; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
78 RaisePropertyChanged(PreviousPricePropertyName); |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
79 } |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
80 } |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
81 |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
82 public const string DeltaPropertyName = "Delta"; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
83 private decimal _delta = 0; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
84 public decimal Delta |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
85 { |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
86 get { return _delta; } |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
87 private set |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
88 { |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
89 if (_delta == value) return; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
90 _delta = value; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
91 RaisePropertyChanged(DeltaPropertyName); |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
92 } |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
93 } |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
94 |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
95 public const string TimestampPropertyName = "Timestamp"; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
96 private DateTime _timestamp = DateTime.MinValue; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
97 public DateTime Timestamp |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
98 { |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
99 get { return _timestamp; } |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
100 private set |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
101 { |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
102 if (_timestamp == value) return; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
103 _timestamp = value; |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
104 RaisePropertyChanged(TimestampPropertyName); |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
105 } |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
106 } |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
107 } |
399398841fd0
Working version for Stocks (including loosely coupled components
adminsh@apollo
parents:
diff
changeset
|
108 } |