Example #1
0
        private void OpenMessage(SystemStatusDocument document)
        {
            // todo: 04 - Open SystemStatus: Navigating to a view in a region with context
            // When navigating, you can also supply context so the target view or
            // viewmodel can orient their data to something appropriate.  In this case,
            // we've chosen to pass the SystemStatus id in a name/value pair using and handmade Uri.
            //
            // The ControllerLogViewModel retrieves this context by implementing the INavigationAware
            // interface.
            //
            NavigationParameters parameters = new NavigationParameters();
            parameters.Add(ControllerLogIdKey, document.Id.ToString("N"));

            this.regionManager.RequestNavigate(RegionNames.MainContentRegion, new Uri(ControllerLogViewKey + parameters, UriKind.Relative));
        }
        void INavigationAware.OnNavigatedTo(NavigationContext navigationContext)
        {
            // todo: 09 - SystemStatus OnNavigatedTo : Accessing navigation context.
            // When this view model is navigated to it gains access to the
            // NavigationContext to determine if we are composing a new SystemStatus
            // or replying to an existing one.
            //
            // The navigation context offers the context information through
            // the Parameters property that is a string/value dictionary
            // built using the NavigationParameters class.
            //
            // In this example, we look for the 'ReplyTo' value to 
            // determine if we are replying to an SystemStatus and, if so, 
            // retrieving it's relevant information from the SystemStatus service
            // to pre-populate response values.
            //
            var SystemStatusDocument = new SystemStatusDocument();

            var parameters = navigationContext.Parameters;

            var replyTo = parameters[ReplyToParameterKey];
            Guid replyToId;
            if (replyTo != null)
            {
                if (replyTo is Guid)
                {
                    replyToId = (Guid)replyTo;
                }
                else
                {
                    replyToId = Guid.Parse(replyTo.ToString());
                }

                var replyToSystemStatus = this.SystemStatusService.GetSystemStatusDocument(replyToId);
                if (replyToSystemStatus != null)
                {
                    SystemStatusDocument.Name = Resources.ResponseMessagePrefix + replyToSystemStatus.Name;

                    SystemStatusDocument.Message =
                        Environment.NewLine +
                        replyToSystemStatus.Message
                            .Split(Environment.NewLine.ToCharArray())
                            .Select(l => l.Length > 0 ? Resources.ResponseLinePrefix + l : l)
                            .Aggregate((l1, l2) => l1 + Environment.NewLine + l2);
                }
            }

            this.SystemStatusDocument = SystemStatusDocument;

            // todo: 10 - SystemStatus OnNaviatedTo : Capture the navigation service journal
            // You can capture the navigation service or navigation service journal
            // to navigate the region you're placed in without having to expressly 
            // know which region to navigate.
            //
            // This is useful if you need to navigate 'back' at some point after this
            // view model closes.
            this.navigationJournal = navigationContext.NavigationService.Journal;
        }
Example #3
0
 public Task SendSystemStatusDocumentAsync(SystemStatusDocument SystemStatus)
 {
     return(Task.Delay(500));
 }
Example #4
0
        void INavigationAware.OnNavigatedTo(NavigationContext navigationContext)
        {
            // todo: 15 - Orient to the right context
            //
            // When this view model is navigated to, it gathers the
            // requested SystemStatusId from the navigation context's parameters.
            //
            // It also captures the navigation Journal so it
            // can offer a 'go back' command.
            var SystemStatusId = GetRequestedSystemStatusId(navigationContext);
            if (SystemStatusId.HasValue)
            {
                this.SystemStatus = this.SystemStatusService.GetSystemStatusDocument(SystemStatusId.Value);
            }

            this.navigationJournal = navigationContext.NavigationService.Journal;
        }
 public Task SendSystemStatusDocumentAsync(SystemStatusDocument SystemStatus)
 {
     return Task.Delay(500);
 }