Ejemplo n.º 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();
            }
        }
Ejemplo n.º 2
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

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

            if (this.startup)
            {
                // Initialize progress bar
                this.InitializeProgress();

                // Setup ViewModel
                string route_id;
                string route_name;
                if (this.NavigationContext.QueryString.TryGetValue("route_id", out route_id))
                {
                    this.ViewModel = new StopResultVM(AppSettings.KnownRoutes.Value[route_id]);
                    await InitializeFromViewModel();
                }
                else if (this.NavigationContext.QueryString.TryGetValue(VoiceHelper.RouteNumPhraseList, out route_name))
                {
                    ProgressIndicatorHelper.Instance.Push(LoadingEnum.Routes);
                    BusRoute br = await TransitInfo.SearchForRoute(route_name);

                    ProgressIndicatorHelper.Instance.Remove(LoadingEnum.Routes);
                    if (LocationTracker.GetPermission())
                    {
                        LocationTracker.RetrieveLocation();
                    }
                    if (br != null)
                    {
                        this.ViewModel = new StopResultVM(br);
                        await InitializeFromViewModel();
                    }
                    else
                    {
                        MessageBox.Show(string.Format("Could not find route {0}.", route_name),
                                        "No matches", MessageBoxButton.OK);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Finish initialization after setting the viewmodel
        /// </summary>
        private void InitializeFromViewModel()
        {
            this.DataContext = this.ViewModel;

            // Initialize progress bar
            InitializeProgress();

            // Get location if necessary
            if (LocationTracker.Location == null && LocationTracker.GetPermission())
            {
                ProgressIndicatorHelper.Instance.Push(LoadingEnum.Location);
                LocationTracker.RetrieveLocation();
            }

            // Update recent stops
            RecentStopsQueue.Push(ViewModel.Context);

            // Preven further initialization
            this.startup = false;
        }