public MainWindowViewModel(PageManager pageManager, IEventAggregator ea, IFolderReactionMonitorModel monitor, IRegionManager regionManagar) { PageManager = pageManager; _Monitor = monitor; _RegionManager = regionManagar; MessageRequest = new InteractionRequest<Notification>(); _CompositeDisposable = new CompositeDisposable(); var e = ea.GetEvent<PubSubEvent<TaskbarIconBalloonMessageEventPayload>>(); e.Subscribe(x => { MessageRequest.Raise(new Notification() { Title = x.Title, Content = x.Message }); }); IsOpenSubContent = PageManager .ObserveProperty(x => x.IsOpenSubContent) .ToReactiveProperty(false); IsOpenSideMenu = PageManager .ToReactivePropertyAsSynchronized(x => x.IsOpenSideMenu); NotificationSource = new NotificationsSource(); var toastEvent = ea.GetEvent<PubSubEvent<ToastNotificationEventPayload>>(); toastEvent.Subscribe(x => { NotificationSource.Show(x.Message, x.Type); }); }
public SideMenuViewModel(PageManager page, IRegionManager regionManagar) { PageManager = page; _RegionManager = regionManagar; AppPolicyManageListItem = new MenuItemViewModel(AppPageType.AppPolicyManage) { Title = "App Policy List", Kind = PackIconKind.ViewList, MenuItemSelectedCommand = new DelegateCommand(() => { PageManager.OpenPage(AppPageType.AppPolicyManage); }) }; ReactionManageListItem = new MenuItemViewModel(AppPageType.ReactionManage) { Title = "Manage Reaction", Kind = PackIconKind.Monitor, MenuItemSelectedCommand = new DelegateCommand(() => { PageManager.OpenPage(AppPageType.ReactionManage); }) }; InstantActionListItem = new MenuItemViewModel(AppPageType.InstantAction) { Title = "Instant Action", Kind = PackIconKind.Run, MenuItemSelectedCommand = new DelegateCommand(() => { PageManager.OpenPage(AppPageType.InstantAction); }) }; HistoryListItem = new MenuItemViewModel(AppPageType.History) { Title = "History", Kind = PackIconKind.History, MenuItemSelectedCommand = new DelegateCommand(() => { PageManager.OpenPage(AppPageType.History); }) }; SettingsListItem = new MenuItemViewModel(AppPageType.Settings) { Title = "Settings", Kind = PackIconKind.Settings, MenuItemSelectedCommand = new DelegateCommand(() => { PageManager.OpenPage(AppPageType.Settings); }) }; AboutListItem = new MenuItemViewModel(AppPageType.About) { Title = "About", Kind = PackIconKind.CommentQuestionOutline, MenuItemSelectedCommand = new DelegateCommand(() => { PageManager.OpenPage(AppPageType.About); }) }; MenuItems = new List<MenuItemViewModel>() { AppPolicyManageListItem, InstantActionListItem, ReactionManageListItem, HistoryListItem, SettingsListItem, AboutListItem, }; PageManager.ObserveProperty(x => x.PageType) .Subscribe(x => { foreach(var nonSelectedItem in MenuItems.Where(y => y.PageType != x)) { nonSelectedItem.IsSelected = false; } MenuItems.Single(y => y.PageType == x).IsSelected = true; }); }