Beispiel #1
0
        private void closePopupButton_Click(object sender, RoutedEventArgs e)
        {
            firstRunPopup.IsOpen = false;
            DataContextManager.Settings.IsFirstRun = false;
            DataContextManager.Save();

            FocusNameText();
        }
Beispiel #2
0
        void Current_Launching(object sender, Microsoft.Phone.Shell.LaunchingEventArgs e)
        {
            DisplaySplash = true;
            FirstLoad     = true;

            DataContextManager.HandleLaunch();
            Utils.InitializeNotifications();
        }
Beispiel #3
0
        void control_RefreshComplete(object sender, EventArgs e)
        {
            _refreshCount--;

            if (_refreshCount <= 0)
            {
                detailControl.Refresh();

                if (returnCheck.IsChecked.Value)
                {
                    DataContextManager.SelectedCommute.LastUpdatedRet = DateTime.Now;
                }
                else
                {
                    DataContextManager.SelectedCommute.LastUpdated = DateTime.Now;
                }
                updatedLabel.Text = string.Concat("", DateTime.Now.ToString("MM/dd @ hh:mm tt"));

                ((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = true;
                progressBar.Visibility = System.Windows.Visibility.Collapsed;
                _refreshCount          = 0;

                if (0 != (DataContextManager.SelectedCommute.DaysOfWeek & (int)Math.Pow(2, (int)DateTime.Now.DayOfWeek)))
                {
                    MobileSrc.Commuter.Shared.RouteDefinition bestRoute = null;
                    foreach (MobileSrc.Commuter.Shared.RouteDefinition route in DataContextManager.SelectedCommute.Routes)
                    {
                        if (bestRoute == null)
                        {
                            bestRoute = route;
                        }
                        else
                        {
                            TimeSpan durA = (returnCheck.IsChecked.Value) ? route.EstimatedRetDuration : route.EstimatedDuration;
                            TimeSpan durB = (returnCheck.IsChecked.Value) ? bestRoute.EstimatedRetDuration : bestRoute.EstimatedDuration;
                            if (durA < durB)
                            {
                                bestRoute = route;
                            }
                        }
                    }

                    if (null != bestRoute)
                    {
                        string tileUrl = string.Format(@"http://mobilesrc.com/commuter/LiveTile.aspx?commute={0}&route={1}&duration={2}&interval={3}&day={4}&color={5}", DataContextManager.SelectedCommute.Name, bestRoute.Name, (int)((returnCheck.IsChecked.Value) ? bestRoute.EstimatedRetDuration.TotalMinutes : bestRoute.EstimatedDuration.TotalMinutes), "min", DateTime.Now.ToString("dddd @ hh:mm tt"), App.AccentColor);

                        Utils.RequestTileUpdate(tileUrl);
                    }
                }
                DataContextManager.Save();
            }
        }
Beispiel #4
0
 protected override void OnNavigatingFrom(System.Windows.Navigation.NavigatingCancelEventArgs e)
 {
     base.OnNavigatingFrom(e);
     if (e.NavigationMode == System.Windows.Navigation.NavigationMode.Back)
     {
         if (null != Closing)
         {
             Closing(this, null);
         }
         Utils.RegisterDevice();
         DataContextManager.Save();
     }
 }
Beispiel #5
0
        void definitionReturn_Updated(object sender, EventArgs e)
        {
            CommuteDefinition definition = (CommuteDefinition)sender;

            definition.Updated -= new EventHandler(definitionReturn_Updated);

            this.Dispatcher.BeginInvoke(() =>
            {
                this.commuterList.ItemsSource = null;
                this.commuterList.ItemsSource = DataContextManager.Commutes;
            });

            DataContextManager.Save();
        }
Beispiel #6
0
        private void deleteButton_Click(object sender, RoutedEventArgs e)
        {
            Button            button     = (Button)sender;
            CommuteDefinition definition = (CommuteDefinition)button.Tag;

            string szTitle   = definition.Name;
            string szMessage = "Are you sure you want to delete this commute?";

            if (MessageBox.Show(szMessage, szTitle, MessageBoxButton.OKCancel) == MessageBoxResult.OK)
            {
                DataContextManager.Commutes.Remove(definition);
                DataContextManager.Save();
            }
        }
Beispiel #7
0
        private void addCommuteButton_Click(object sender, RoutedEventArgs e)
        {
            // selected weather data
            MobileSrc.Commuter.Shared.CommuteDefinition commuter = new MobileSrc.Commuter.Shared.CommuteDefinition();
            commuter.Name  = "untitled";
            commuter.IsNew = true;

            _showCommute = commuter;

            DataContextManager.Commutes.Add(commuter);
            DataContextManager.Save();

            DataContextManager.SelectedCommute = commuter;
            NavigationService.GoBack();
        }
Beispiel #8
0
        protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
        {
            if (firstRunPopup.IsOpen)
            {
                e.Cancel             = true;
                firstRunPopup.IsOpen = false;
                DataContextManager.Settings.IsFirstRun = false;
                DataContextManager.Save();

                FocusNameText();
            }
            else
            {
                base.OnBackKeyPress(e);
            }
        }
Beispiel #9
0
        internal static void BindNotifications()
        {
            if (null != _channel)
            {
                RegisterDevice();

                if (_channel.IsShellTileBound && !DataContextManager.Settings.EnableTileNotifications)
                {
                    _channel.UnbindToShellTile();
                }
                else if (!_channel.IsShellTileBound && DataContextManager.Settings.EnableTileNotifications)
                {
                    var uris = new Collection <Uri>
                    {
                        new Uri("http://mobilesrc.com")
                    };

                    _channel.BindToShellTile(uris);
                }

                if (_channel.IsShellToastBound && !DataContextManager.Settings.EnableToastNotifications)
                {
                    _channel.UnbindToShellToast();
                }
                else if (!_channel.IsShellToastBound && DataContextManager.Settings.EnableToastNotifications)
                {
                    bool shouldSet = true;
                    if (!DataContextManager.Settings.HasNotifiedToast)
                    {
                        if (MessageBoxResult.OK != MessageBox.Show("Are you sure you want to enable toast notifications?", "Enable Toasts", MessageBoxButton.OKCancel))
                        {
                            DataContextManager.Settings.EnableToastNotifications = false;
                            shouldSet = false;
                        }
                        DataContextManager.Settings.HasNotifiedToast = true;
                        DataContextManager.Save();
                    }

                    if (shouldSet)
                    {
                        _channel.BindToShellToast();
                    }
                }
            }
        }
Beispiel #10
0
        protected override void OnSplashEnd()
        {
            this.ApplicationBar.IsVisible = true;
            this.updatedLabel.Visibility  = System.Windows.Visibility.Visible;
            this.pivotControl.Visibility  = System.Windows.Visibility.Visible;

            if (!DataContextManager.Settings.ShownRatingRequest && DataContextManager.Settings.FirstRunDate.AddDays(1) < DateTime.Now)
            {
                if (MessageBoxResult.OK == MessageBox.Show("We would love for you to help spread the word about Commuter. Would you like to review or rate Commuter now?", "Review Commuter?", MessageBoxButton.OKCancel))
                {
                    Microsoft.Phone.Tasks.MarketplaceReviewTask reviewTask = new MarketplaceReviewTask();
                    reviewTask.Show();
                }
                DataContextManager.Settings.ShownRatingRequest = true;
                DataContextManager.Save();
            }
            base.OnSplashEnd();
        }
Beispiel #11
0
 void Current_Activated(object sender, Microsoft.Phone.Shell.ActivatedEventArgs e)
 {
     DisplaySplash = false;
     DataContextManager.HandleActivated();
     TransitionControl = new TransitioningContentControl();
 }
Beispiel #12
0
 void Current_Closing(object sender, Microsoft.Phone.Shell.ClosingEventArgs e)
 {
     DataContextManager.HandleClosing();
 }
Beispiel #13
0
 void Current_Deactivated(object sender, Microsoft.Phone.Shell.DeactivatedEventArgs e)
 {
     DataContextManager.HandleDeactivated();
 }