summaryrefslogtreecommitdiff
path: root/product/Boot/Modules/ToolbarModule.cs
blob: 443e90116d6a97ee24099d903ae285b11cb29115 (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
44
45
46
using MoMoney.Presentation.Model.Menu;
using MoMoney.Presentation.Model.messages;
using MoMoney.Presentation.Presenters;
using MoMoney.Presentation.Presenters.Shell;
using MoMoney.Service.Infrastructure.Eventing;

namespace MoMoney.Modules
{
    public class ToolbarModule : IToolbarModule
    {
        readonly IEventAggregator broker;
        readonly IRunPresenterCommand command;

        public ToolbarModule(IEventAggregator broker, IRunPresenterCommand command)
        {
            this.broker = broker;
            this.command = command;
        }

        public void run()
        {
            broker.subscribe(this);
            command.run<IToolbarPresenter>();
        }

        public void notify(NewProjectOpened message)
        {
            broker.publish<IToolbarButton>(x => x.refresh());
        }

        public void notify(ClosingProjectEvent message)
        {
            broker.publish<IToolbarButton>(x => x.refresh());
        }

        public void notify(SavedChangesEvent message)
        {
            broker.publish<IToolbarButton>(x => x.refresh());
        }

        public void notify(UnsavedChangesEvent message)
        {
            broker.publish<IToolbarButton>(x => x.refresh());
        }
    }
}