Example #1
0
 private async Task LoadDetails(User userDetails)
 {
     // if the page is for the current user then show the upload option
     if (AppSettings.CurrentUser != null && AppSettings.CurrentUser.user != null && userDetails.id == AppSettings.CurrentUser.user.id)
     {
         upload.Visibility = Windows.UI.Xaml.Visibility.Visible;
     }
     else 
     {
         upload.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
         aboutText.Height = 180;
         // load the details of the user.If it was the current user we would already have had the full details
         string url = AppSettings.BaseUrl + "users/show";
    var userResult= await  AppSettings.Oauth500Px.MakeRequest(Picfinity.Common.Oauth500px.RequestType.GET).ExecuteNonAuthorizedRequest<UserDetails>(url,
             new Dictionary<string, string>() {
                 {"consumer_key", AppSettings.ConsumerKey},
                 {"id", userDetails.id.ToString()}
             });
    userDetails = userResult.user;
     }
     progressBar.Visibility = Windows.UI.Xaml.Visibility.Visible;
     userProfile.DataContext = userDetails;
     // load the user specific photos 
     string userPhotos = AppSettings.PhotosUrl + "?user_id=" + userDetails.id + "&feature=user&consumer_key=51Se7wpTdDZPMD3edVsU7WzfCIl8kSDYsejF5TM7&image_size[]=3&image_size[]=4";
     PhotoStream stream = new PhotoStream(" Photos", userPhotos);
     string userFavs = AppSettings.PhotosUrl + "?user_id=" + userDetails.id + "&feature=user_favorites&consumer_key=51Se7wpTdDZPMD3edVsU7WzfCIl8kSDYsejF5TM7&image_size[]=3&image_size[]=4";
     PhotoStream streamFavs = new PhotoStream("Favorites", userFavs);
     UserStreams = new List<PhotoStream>() { stream, streamFavs };
     Task<bool> task = new Task<bool>(() => AssignDataSource());
     task.Start();
     bool result = await task;
     if (result)
     {
         this.DefaultViewModel["Groups"] = UserStreams;
         progressBar.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
     }
     else
     {
         // loading 
         this.Frame.Navigate(typeof(NoInternetPage));
     }
 }
Example #2
0
        private void OnQuerySubmitted(object sender, SearchPaneQuerySubmittedEventArgs args)
        {

            if (string.IsNullOrEmpty(args.QueryText) || AppSettings.Oauth500Px == null)
            {
                return;
            }
            Dictionary<string, string> parameters = new Dictionary<string, string>()
            {
                {"consumer_key",AppSettings.ConsumerKey},
                {"term",args.QueryText}
            };

            string searchUrl = AppSettings.PhotosUrl + "/search" + "?consumer_key=" + AppSettings.ConsumerKey  +"&image_size[]=3&image_size[]=4" + "&term=" + args.QueryText;

            var result = new PhotoStream("Search - " + args.QueryText, searchUrl);
            Frame rootframe = Window.Current.Content as Frame;
            if (rootframe != null)
            {
                rootframe.Navigate(typeof(GroupDetailPage), result);
            }
        }
Example #3
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
        {
            // Allow saved page state to override the initial item to display
            if (pageState != null && pageState.ContainsKey("SelectedItem"))
            {
                navigationParameter = pageState["SelectedItem"];
            }

            //if (AppSettings.CurrentUser != null)
            //{
            //    currentUser.DataContext = AppSettings.CurrentUser;
            //    currentUser.Visibility = Windows.UI.Xaml.Visibility.Visible;
            //}

            // TODO: Create an appropriate data model for your problem domain to replace the sample data
            var navParamAsArray = navigationParameter as Object[];
            Photo item = null;
            PhotoStream stream = null;
            // If the details are passed in as the navigation parameter then we use that
            if (navParamAsArray != null)
            {
                item = navParamAsArray[1] as Photo;
                stream = navParamAsArray[0] as PhotoStream;
            }

            if (item != null && stream != null)
            {
                // store the stream and the current photo so that we can navigate back to this page
                currentStream = stream;
                this.DefaultViewModel["Group"] = stream.StreamPhotos;
                flipView.SelectedItem = item;
                currentItem = item;
                GetPhotoDetails();
            }

            IsInSlideShow = false;
            playSlideShow.Visibility = Windows.UI.Xaml.Visibility.Visible;
            stopSlideShow.Visibility = Windows.UI.Xaml.Visibility.Collapsed;

        }