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(); }
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)); }
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())); }
public void OnTransitionGoodbyeTemporary() { ApplicationBar = null; if (_token != null) { StatusToken.TryComplete(ref _token); } }
private void OnListsLoaded(Model.UserLists uls) { PriorityQueue.AddUiWorkItem(() => { StatusToken.TryComplete(ref _refreshToken); NavigationService.GoBack(); }); }
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)); }
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(); }); }
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)); }
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); }); }
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(); }); }
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 }
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); } }); }
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); }