コード例 #1
0
ファイル: TrackingPage.xaml.cs プロジェクト: pdz8/ms13apphack
        /// <summary>
        /// Execute upon arriving from navigation
        /// </summary>
        /// <param name="e"></param>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            // Update the current dispatcher
            Util.CurrentDispatcher = this.Dispatcher;

            // Setup Context and ViewModel
            if (this.startup)
            {
                string stop_id;
                if (this.NavigationContext.QueryString.TryGetValue("stop_id", out stop_id))
                {
                    // Initialize ViewModel
                    this.ViewModel = new TrackingVM(AppSettings.KnownStops.Value[stop_id]);

                    // Finish initialization after ViewModel is set
                    this.InitializeFromViewModel();

                    // Update phrase list for stops
                    await VoiceHelper.UpdateStopNamePhraseList();
                }
                else if (this.NavigationContext.QueryString.ContainsKey(VoiceHelper.VoiceCommandName))
                {
                    string commandName = this.NavigationContext.QueryString[VoiceHelper.VoiceCommandName];
                    string stopName;
                    if (this.NavigationContext.QueryString.TryGetValue(VoiceHelper.StopNamePhraseList, out stopName))
                    {
                        var     possibleStops = RecentStopsQueue.RecentBusStops.Concat(BusStop.PinnedStops);
                        BusStop stopContext   = possibleStops.FirstOrDefault(s => s.Name == stopName);
                        if (stopContext != null)
                        {
                            // Initialize ViewModel
                            this.ViewModel = new TrackingVM(stopContext);

                            // Finish initialization after ViewModel is set
                            this.InitializeFromViewModel();

                            // Automatically start tracking
                            if (commandName == VoiceHelper.AlarmSetCommand)
                            {
                                this.ViewModel.BeginGeofence();
                            }
                        }
                    }
                }
            }

            // Animate app bar
            this.AppBarEntrance.Begin();
            this.AppBarButtonsEntrance.Begin();
        }