summaryrefslogtreecommitdiff
path: root/product/desktop.ui/presenters/SingleStockPresenter.cs
blob: e146935f77a10a635a0cc1cb812703dfff81ac7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using gorilla.utility;
using solidware.financials.infrastructure.eventing;
using solidware.financials.messages;

namespace solidware.financials.windows.ui.presenters
{
    public class SingleStockPresenter : TabPresenter, EventSubscriber<CurrentStockPrice>
    {
        string symbol_to_watch;

        public SingleStockPresenter(string symbol_to_watch)
        {
            this.symbol_to_watch = symbol_to_watch;
            Chart = new ObservableCollection<KeyValuePair<DateTime, decimal>>();
        }

        public ICollection<KeyValuePair<DateTime, decimal>> Chart { get; set; }

        public string Header
        {
            get { return symbol_to_watch; }
        }

        public void present() {}

        public void notify(CurrentStockPrice message)
        {
            if (symbol_to_watch.Equals(message.Symbol))
                Chart.Add(new KeyValuePair<DateTime, decimal>(Clock.now(), message.Price));
        }

        public class Factory
        {
            public virtual SingleStockPresenter create_for(string symbol)
            {
                throw new NotImplementedException();
            }
        }
    }
}