main
1using gorilla.commons.utility;
2using MoMoney.Presentation;
3using momoney.presentation.model.eventing;
4using momoney.presentation.views;
5using MoMoney.Service.Infrastructure.Eventing;
6
7namespace momoney.presentation.presenters
8{
9 public interface ITaskTrayPresenter : IModule,
10 IEventSubscriber<SavedChangesEvent>,
11 IEventSubscriber<StartedRunningCommand>,
12 IEventSubscriber<FinishedRunningCommand>,
13 IEventSubscriber<NewProjectOpened>
14 {
15 }
16
17 public class TaskTrayPresenter : ITaskTrayPresenter
18 {
19 readonly ITaskTrayMessageView view;
20 readonly IEventAggregator broker;
21
22 public TaskTrayPresenter(ITaskTrayMessageView view, IEventAggregator broker)
23 {
24 this.view = view;
25 this.broker = broker;
26 }
27
28 public void run()
29 {
30 view.display("Welcome!");
31 view.display("Visit http://mokhan.ca for more information!");
32 broker.subscribe_to<SavedChangesEvent>(this);
33 broker.subscribe_to<NewProjectOpened>(this);
34 }
35
36 public void notify(SavedChangesEvent message)
37 {
38 view.display("successfully saved changes");
39 }
40
41 public void notify(NewProjectOpened message)
42 {
43 view.display("opened {0}", message.path);
44 }
45
46 public void notify(StartedRunningCommand message)
47 {
48 view.display("Running... {0}".formatted_using(message.running_action));
49 }
50
51 public void notify(FinishedRunningCommand message)
52 {
53 view.display("Finished... {0}".formatted_using(message.completed_action));
54 }
55 }
56}