Пример #1
0
        public MainViewModel()
        {
            Mediator.Register(this, (AddModuleMessage message) => CurrentPage.AddModule(message.Module, false));

            Mediator.Register(this, async(DialogRequestMessage message) =>
            {
                object response = await DialogHost.Show(message.DialogContent, "RootDialog");
                if (message.ResponseToken != null)
                {
                    Mediator.Send(new DialogResponseMessage(response, message.ResponseToken), message.ResponseToken);
                }
            });

            Mediator.Register(this, async(NotificationMessage message) =>
            {
                LastNotification?.Hide();
                LastNotification = NotificationService.CreatePredefinedNotification(message.Caption, message.Content, null, message.Image);

                await LastNotification.ShowAsync().ContinueWith(task =>
                {
                    if (task.Result == NotificationResult.Activated)
                    {
                        App.BringToFront();

                        int pageIndex = PageCollection.GetPageIndex(message.Module);
                        if (pageIndex >= 0)
                        {
                            SelectedPageIndex = pageIndex;
                        }

                        Properties.Settings.Default.IsCollapsed = false;
                    }

                    LastNotification = null;
                });
            });
        }