main
1using Gorilla.Commons.Infrastructure.Logging;
2using MoMoney.Presentation;
3using momoney.presentation.model.eventing;
4using MoMoney.Presentation.Model.Projects;
5using MoMoney.Presentation.Views;
6using MoMoney.Service.Infrastructure.Eventing;
7
8namespace momoney.presentation.presenters
9{
10 public interface ITitleBarPresenter : IModule,
11 IEventSubscriber<UnsavedChangesEvent>,
12 IEventSubscriber<SavedChangesEvent>,
13 IEventSubscriber<NewProjectOpened>,
14 IEventSubscriber<ClosingProjectEvent>
15 {
16 }
17
18 public class TitleBarPresenter : ITitleBarPresenter
19 {
20 readonly ITitleBar view;
21 readonly IProjectController project;
22 readonly IEventAggregator broker;
23
24 public TitleBarPresenter(ITitleBar view, IProjectController project, IEventAggregator broker)
25 {
26 this.view = view;
27 this.project = project;
28 this.broker = broker;
29 }
30
31 public void run()
32 {
33 view.display(project.name());
34 broker.subscribe_to<UnsavedChangesEvent>(this);
35 broker.subscribe_to<SavedChangesEvent>(this);
36 broker.subscribe_to<NewProjectOpened>(this);
37 broker.subscribe_to<ClosingProjectEvent>(this);
38 }
39
40 public void notify(UnsavedChangesEvent dto)
41 {
42 this.log().debug("adding asterik");
43 view.append_asterik();
44 }
45
46 public void notify(SavedChangesEvent message)
47 {
48 view.display(project.name());
49 view.remove_asterik();
50 }
51
52 public void notify(NewProjectOpened message)
53 {
54 view.display(project.name());
55 }
56
57 public void notify(ClosingProjectEvent message)
58 {
59 view.display(project.name());
60 }
61 }
62}