예제 #1
0
        public AitReminderPresenter(IMainWindow mainWindow)
        {
            IRemindersManager remindersManager = new RemindersManager();

            remindersManager.ReminderActivated += (o, e) =>
            {
                var remindersMenager = o as RemindersManager;

                if (remindersManager == null)
                {
                    return;
                }

                mainWindow.ReminderNotification(remindersMenager, e.Reminder);
            };

            remindersManager.RemindersChanged += (o, a) =>
            {
                mainWindow.RemindersStatusBarView.SetNumberOfReminders((IRemindersManager)o);
            };

            IRemindersListView      remindersListView      = mainWindow.RemindersListView;
            IRemindersStatusBarView remindersStatusBarView = mainWindow.RemindersStatusBarView;

            var menuCommands = new IMenuCommand[]
            {
                new FileMenuCommmand(
                    new IMenuCommand[]
                {
                    new NewMenuCommand(mainWindow, remindersManager),
                    new OpenMenuCommand(mainWindow, remindersManager),
                    new SaveMenuCommand(remindersManager),
                    new SaveAsMenuCommand(mainWindow, remindersManager),
                    new CloseMenuCommand(mainWindow),
                }),
                new EditMenuCommand(
                    new IMenuCommand[]
                {
                    new AddNewReminderMenuCommand(mainWindow, remindersManager),
                    new EditReminderMenuCommand(mainWindow, remindersManager, remindersListView),
                    new RemoveReminderMenuCommand(remindersManager, remindersListView),
                }),
                new HelpMenuCommand(
                    new IMenuCommand[]
                {
                    new AboutMenuCommand(mainWindow)
                })
            };

            mainWindow.MenuView.SetMenuCommands(menuCommands);

            mainWindow.RemindersListView.SetReminders(remindersManager.Reminders);
            mainWindow.RemindersListView.SelectionChanged += (a, e) =>
            {
                EventAggregator.Instance.Publish(new ReminderIsSelectedEventAggregator(e.Reminder == null ? false : true));
            };
        }
        public RemoveReminderMenuCommand(IRemindersManager remindersManager, IRemindersListView remindersListView, IEnumerable <IMenuCommand> subCommands) : base(subCommands)
        {
            _remindersManager  = remindersManager;
            _remindersListView = remindersListView;
            Header             = "Remove";

            IsEnabled = false;

            EventAggregator.Instance.Subscribe <ReminderIsSelectedEventAggregator>(r => IsEnabled = r.IsSelected);
        }
        public EditReminderMenuCommand(IMainWindow mainWindow,
                                       IRemindersManager remindersManager,
                                       IRemindersListView reminderListView,
                                       IEnumerable <IMenuCommand> subCommands) :
            base(subCommands)
        {
            _mainWindow       = mainWindow;
            _remindersManager = remindersManager;
            _reminderListView = reminderListView;
            Header            = "Edit";

            IsEnabled = false;

            EventAggregator.Instance.Subscribe <ReminderIsSelectedEventAggregator>(r => IsEnabled = r.IsSelected);
        }
 public EditReminderMenuCommand(IMainWindow mainWindow,
                                IRemindersManager remindersManager,
                                IRemindersListView reminderListView) :
     this(mainWindow, remindersManager, reminderListView, null)
 {
 }
 public RemoveReminderMenuCommand(IRemindersManager remindersManager, IRemindersListView remindersListView) : this(remindersManager, remindersListView, null)
 {
 }