Beispiel #1
0
        private async void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            // Update current dispatcher
            Util.CurrentDispatcher = this.Dispatcher;

            if (startup)
            {
                startup = false;

                // Setup system tray
                SystemTray.SetProgressIndicator(this, ProgressIndicatorHelper.Instance.PI);
                SystemTray.Opacity         = 0;
                SystemTray.IsVisible       = true;
                SystemTray.ForegroundColor = Colors.Black;

                // Get Permissions
                if (LocationTracker.GetPermission())
                {
                    // Find location
                    ProgressIndicatorHelper.Instance.Push(LoadingEnum.Location);
                    LocationTracker.RetrieveLocation();
                }

                // Setup speech recognition
                await VoiceHelper.InitializeSpeech();
            }
        }
Beispiel #2
0
        /// <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();
        }
Beispiel #3
0
 /// <summary>
 /// RePopulate RouteIDs and also update speech inputs
 /// </summary>
 public static async Task RefreshRouteIDsAsync()
 {
     RefreshRouteIDs();
     await VoiceHelper.UpdateRoutePhraseList();
 }