main
1using solidware.financials.windows.ui.views;
2using solidware.financials.windows.ui.views.controls;
3
4namespace solidware.financials.windows.ui.presenters
5{
6 public class StockViewModel : Presenter
7 {
8 UICommandBuilder builder;
9
10 public StockViewModel(string symbol, UICommandBuilder builder)
11 {
12 this.builder = builder;
13 Symbol = symbol;
14 Price = Money.Null;
15 AdditionalInformation = new SimpleCommand(() => {});
16 }
17
18 public virtual string Symbol { get; set; }
19 public Observable<Money> Price { get; set; }
20 public ObservableCommand AdditionalInformation { get; set; }
21
22 public void present()
23 {
24 AdditionalInformation = builder.build<MoreCommand>(this);
25 }
26
27 public bool is_for(string symbol)
28 {
29 return Symbol.Equals(symbol);
30 }
31
32 public void change_price_to(decimal price)
33 {
34 Price.Value = price;
35 }
36
37 public class MoreCommand : UICommand<StockViewModel>
38 {
39 readonly ApplicationController controller;
40 readonly SingleStockPresenter.Factory factory;
41
42 public MoreCommand(ApplicationController controller, SingleStockPresenter.Factory factory)
43 {
44 this.controller = controller;
45 this.factory = factory;
46 }
47
48 public override void run(StockViewModel presenter)
49 {
50 controller
51 .load_tab<SingleStockPresenter, SingleStockTab>(factory.create_for(presenter.Symbol));
52 }
53 }
54 }
55}