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