main
1using System.Net.NetworkInformation;
2using MoMoney.Presentation;
3using momoney.presentation.model.eventing;
4using momoney.presentation.views;
5using MoMoney.Presentation.Winforms.Resources;
6using MoMoney.Service.Infrastructure.Eventing;
7
8namespace momoney.presentation.presenters
9{
10 public interface INotificationIconPresenter : IModule,
11 IEventSubscriber<ClosingTheApplication>,
12 IEventSubscriber<NewProjectOpened>
13 {
14 }
15
16 public class NotificationIconPresenter : INotificationIconPresenter
17 {
18 readonly INotificationIconView view;
19 readonly IEventAggregator broker;
20
21 public NotificationIconPresenter(INotificationIconView view, IEventAggregator broker)
22 {
23 this.view = view;
24 this.broker = broker;
25 }
26
27 public void run()
28 {
29 broker.subscribe_to<ClosingTheApplication>(this);
30 broker.subscribe_to<NewProjectOpened>(this);
31 NetworkChange.NetworkAvailabilityChanged += (sender, args) => view.display(ApplicationIcons.Application, args.IsAvailable ? "Connected To A Network" : "Disconnected From Network");
32 view.display(ApplicationIcons.Application, "mokhan.ca");
33 }
34
35 public void notify(ClosingTheApplication message)
36 {
37 view.Dispose();
38 }
39
40 public void notify(NewProjectOpened message)
41 {
42 view.opened_new_project();
43 }
44 }
45}