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();
        }
Beispiel #2
0
        public void OnTransitionGoodbyeTemporary()
        {
            ApplicationBar = null;

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

                NavigationService.GoBack();
            });
        }
Beispiel #4
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();
            });
        }
Beispiel #5
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);
            });
        }
Beispiel #6
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();
            });
        }
Beispiel #7
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);
                }
            });
        }
Beispiel #8
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);
 }