protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            _web.LoadCompleted += OnLoadCompleted;
            _web.Navigated     += OnNavigated;
            _web.Navigating    += OnNavigating;

            string ur = null;

            if (NavigationContext.QueryString.TryGetValue("uri", out ur))
            {
                var uri = new Uri(ur, UriKind.Absolute);
                if (uri != null)
                {
                    if (_token != null)
                    {
                        StatusToken.TryComplete(ref _token);
                    }
                    _token = CentralStatusManager.Instance.BeginShowEllipsisMessage("Loading information");

                    _uri = uri;
                    if (_isLoadComplete)
                    {
                        _web.Navigate(uri);
                    }
                    else
                    {
                        IntervalDispatcher.BeginInvoke(TimeSpan.FromSeconds(0.75), () => OnLoadCompleted(this, new System.Windows.Navigation.NavigationEventArgs(null, null)));
                    }
                }
            }

            UpdateAppBar();
        }
Exemple #2
0
 protected override StatusToken GetNext(StatusToken from, T context)
 {
     if (from.ToParent)
     {
         throw new Exception("Already finished traversing the tree! Should exit the tree before invoking Next on Root a second time!");
     }
     return(new StatusToken(0));
 }
Exemple #3
0
 protected override StatusToken GetNext(StatusToken from, T context)
 {
     if (from.ToChild)
     {
         return(new StatusToken(0));                              //Continue to child
     }
     return(new StatusToken(this, from.result.Opposite()));
 }
Exemple #4
0
        public void OnTransitionGoodbyeTemporary()
        {
            ApplicationBar = null;

            if (_token != null)
            {
                StatusToken.TryComplete(ref _token);
            }
        }
Exemple #5
0
        private void OnListsLoaded(Model.UserLists uls)
        {
            PriorityQueue.AddUiWorkItem(() =>
            {
                StatusToken.TryComplete(ref _refreshToken);

                NavigationService.GoBack();
            });
        }
Exemple #6
0
            protected override StatusToken GetNext(StatusToken from, T context)
            {
                if (from.ToParent)
                {
                    throw ExceptionHelper.NotPossible;        //Leaf nodes have no child
                }
                var result = action(context);                 //Execute behavior/action

                return(new StatusToken(this, result));
            }
Exemple #7
0
        private void OnListsFailed(Exception ex)
        {
            // Didn't refresh but we still at least know we have the venue.
            PriorityQueue.AddUiWorkItem(() =>
            {
                StatusToken.TryComplete(ref _refreshToken);

                MessageBox.Show("Your new list was created, however it won't be available immediately.", "New list", MessageBoxButton.OK);
                NavigationService.GoBack();
            });
        }
Exemple #8
0
            protected override StatusToken GetNext(StatusToken from, T context)
            {
                var token = base.GetNext(from, context);

                if (token.result != Result.success)
                {
                    return(token);                                                //If not going to continue the loop
                }
                //Restart sequence from the beginning
                return(base.GetNext(new StatusToken((byte)IndexInParent.Value), context));
            }
Exemple #9
0
        private void OnVenueLoaded(Model.Venue venue)
        {
            // Auto-check-in *OR* to go the venue page!
            Dispatcher.BeginInvoke(() =>
            {
                if (_token != null)
                {
                    StatusToken.TryComplete(ref _token);
                }

                CheckIn(venue);
            });
        }
Exemple #10
0
        private void OnVenueFailed(Exception e)
        {
            Dispatcher.BeginInvoke(() =>
            {
                if (_token != null)
                {
                    StatusToken.TryComplete(ref _token);
                }

                MessageBox.Show("Doesn't look to be a valid venue tag. You can report this if you think it should work.", "Not a foursquare QR code", MessageBoxButton.OK);

                _scanner.StartScanning();
            });
        }
Exemple #11
0
            protected override StatusToken GetNext(StatusToken from, T context)
            {
                if (from.ToChild)
                {
                    return(new StatusToken(0));                                                                  //If we just entered the node from a parent, start at 0
                }
                if (from.result == Result.success)
                {
                    return(new StatusToken(this, Result.success));                                               //Returns success when any of the child node returns success
                }
                int next = from.index + 1;

                if (next >= Children.Count)
                {
                    return(new StatusToken(this, Result.failure));                                        //Finished running all of the nodes
                }
                return(new StatusToken((byte)next));                                                      //Go to next node
            }
Exemple #12
0
        public void CreateNewList(
            string listTitle,
            string optionalDescription,
            bool isCollaborative,
            Action <CompactList> success,
            Action <Exception> error)
        {
            List <string> components = new List <string>
            {
                "name",
                listTitle
            };

            if (!string.IsNullOrEmpty(optionalDescription))
            {
                components.Add("description");
                components.Add(optionalDescription);
            }
            if (isCollaborative)
            {
                components.Add("collaborative");
                components.Add("true"); // or "true" as docs say?
            }

            var uuri = FourSquareWebClient.BuildFourSquareUri(
                "lists/add",
                GeoMethodType.Optional,

                components.ToArray());

            var r = new FourSquareServiceRequest
            {
                Uri        = uuri.Uri,
                PostString = string.Empty,
            };

            var token = CentralStatusManager.Instance.BeginShowEllipsisMessage("Creating new list");

            r.CallAsync(
                (str, ex) =>
            {
                Exception exx = ex;

                try
                {
                    FourSquare.IgnoreNextNotification = true;
                    var json = FourSquareDataLoaderBase <LoadContext> .ProcessMetaAndNotificationsReturnJson(str);
                    FourSquare.IgnoreNextNotification = false;

                    var vjson      = json["list"];
                    CompactList cl = null;
                    if (vjson != null)
                    {
                        cl = CompactList.ParseJson(vjson);
                    }

                    success(cl);

                    token.CompleteWithAcknowledgement();
                }
                catch (Exception e)
                {
                    exx = e;
                }

                if (exx != null)
                {
                    error(exx);
                    StatusToken.TryComplete(ref token);
                }
            });
        }
Exemple #13
0
        public void AddVenue(
            string name,
            Dictionary <string, string> dataPairs,
            Action <CompactVenue> okNewVenue,
            Action <DuplicateVenueChallenge> duplicatesChallenge,
            Action <Exception> error)
        {
            ValidateIsUser();

            var flat = new List <string>();

            dataPairs["name"] = name;
            foreach (var kp in dataPairs)
            {
                if (!string.IsNullOrEmpty(kp.Value))
                {
                    flat.Add(kp.Key);
                    flat.Add(kp.Value);
                }
            }

            var uuri = FourSquareWebClient.BuildFourSquareUri(
                "venues/add",
                GeoMethodType.Optional,
                flat.ToArray()
                );
            var r = new FourSquareServiceRequest
            {
                Uri        = uuri.Uri,
                PostString = string.Empty,
            };

            var token = CentralStatusManager.Instance.BeginShowEllipsisMessage("Saving place");

            r.CallAsync(
                (str, ex) =>
            {
                Exception exx = ex;

                try
                {
                    FourSquare.IgnoreNextNotification = true;
                    var json = FourSquareDataLoaderBase <LoadContext> .ProcessMetaAndNotificationsReturnJson(str);
                    FourSquare.IgnoreNextNotification = false;

                    string ignoreDuplicatesKey = Json.TryGetJsonProperty(json, "ignoreDuplicatesKey");
                    if (!string.IsNullOrEmpty(ignoreDuplicatesKey))
                    {
                        var duplicates = json["candidateDuplicateVenues"];
                        if (duplicates != null)
                        {
                            List <CompactVenue> dupes = new List <CompactVenue>();
                            foreach (var dupe in duplicates)
                            {
                                var dd = CompactVenue.ParseJson(dupe);
                                if (dd != null)
                                {
                                    dupes.Add(dd);
                                }
                            }

                            DuplicateVenueChallenge dvc  = new DuplicateVenueChallenge();
                            dvc.CandidateDuplicateVenues = dupes;
                            dvc.IgnoreDuplicatesKey      = ignoreDuplicatesKey;
                            duplicatesChallenge(dvc);

                            token.Complete();
                            return;
                        }
                    }

                    var vjson       = json["venue"];
                    CompactVenue cv = null;
                    if (vjson != null)
                    {
                        cv = CompactVenue.ParseJson(vjson);
                    }

                    okNewVenue(cv);

                    token.CompleteWithAcknowledgement();
                }
                catch (Exception e)
                {
                    exx = e;
                }

                if (exx != null)
                {
                    error(exx);
                    StatusToken.TryComplete(ref token);
                }
            });
        }
 void OnNavigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
 {
     StatusToken.TryComplete(ref _token);
 }