Ejemplo n.º 1
0
        /// <summary>
        /// Gets content that should be displayed for a given navigator. In most cases, this is just the Navigator.Content object, except for
        /// PhotoNavigators where is a photo-document wrapper class.
        /// </summary>
        /// <param name="navigator">Navigator whose content must be retrieved.</param>
        /// <returns>The object that forms the content of the Navigator.</returns>
        private object _GetNavigatorContent(Navigator navigator)
        {
            object content = null;

            if (navigator != null)
            {
                var photoNavigator   = navigator as PhotoNavigator;
                var albumNavigator   = navigator as PhotoAlbumNavigator;
                var contactNavigator = navigator as ContactNavigator;
                if (photoNavigator != null)
                {
                    var photo = photoNavigator.Content as FacebookPhoto;
                    content = photo;

                    // If photo navigator's parent is a photo album, set active photo album to this value
                    var parent = photoNavigator.Parent as PhotoAlbumNavigator;
                    if (parent != null)
                    {
                        this.ActivePhotoAlbum = parent.Content as FacebookPhotoAlbum;
                    }
                    else
                    {
                        this.ActivePhotoAlbum = null;
                    }

                    this.ActivePhoto = photo;
                }
                else if (albumNavigator != null)
                {
                    FacebookPhotoAlbum album = albumNavigator.Content as FacebookPhotoAlbum;
                    content = album;
                    this.ActivePhotoAlbum = album;
                    this.ActivePhoto      = null;
                }
                else if (contactNavigator != null)
                {
                    FacebookContact contact = contactNavigator.Content as FacebookContact;
                    content = contact;
                }
                else
                {
                    // Return navigator's content
                    content = navigator.Content;
                }
            }

            return(content);
        }
Ejemplo n.º 2
0
 public PhotoAlbumNavigator(FacebookPhotoAlbum album, Navigator parent)
     : base(album, album.AlbumId, parent)
 {
     _album = album;
 }
 public void AddAlbum(FacebookPhotoAlbum album)
 {
     _albumCache.SetValue(album.AlbumId, album);
 }
Ejemplo n.º 4
0
 public FacebookPhoto AddPhotoToAlbum(FacebookPhotoAlbum album, string caption, string imageFile)
 {
     return(ServiceProvider.FacebookService.AddPhotoToAlbum(album, caption, imageFile));
 }
Ejemplo n.º 5
0
        private void OnUploadExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            Assert.IsNull(_workerThread);

            string albumName        = _albumName.Text;
            string albumDescription = _albumDescription.Text;
            string albumLocation    = _albumLocation.Text;

            FacebookPhotoAlbum album = _albumsComboBox.SelectedItem as FacebookPhotoAlbum;

            Page                       = PhotoUploaderPage.Upload;
            UploadAlbumName            = album != null ? album.Title : albumName;
            _closeCancelButton.Content = "Cancel";
            UploadCount                = 0;
            FileCount                  = Files.Count;

            FacebookClientApplication.Current2.MainWindow.SetTaskbarProgress(0);

            _uploadStatus.Text = "";

            // This is terrible, but for some reason I can't get StringFormat to work correctly with the MultiBinding in this case.
            // This needs to be looked into next time there's any investment made into the PhotoUploadWizard.
            // (There are other things here that are also terrible (i.e. not localizable, not designable) so this isn't making anything worse...)
            _uploadPhotoStatusTextBlock.Text = "Uploading photo " + (UploadCount + 1) + " of " + FileCount + " to album " + UploadAlbumName;

            _workerThread = new Thread(new ThreadStart(() =>
            {
                try
                {
                    if (album == null)
                    {
                        album = ServiceProvider.ViewManager.CreatePhotoAlbum(albumName, albumDescription, albumLocation);
                    }

                    int count = 0;

                    foreach (var file in Files)
                    {
                        Dispatcher.BeginInvoke(new Action(() =>
                        {
                            BitmapImage image = new BitmapImage(new Uri(file.Path));
                            image.Freeze();
                            _nextPhotoImage.Source = image;
                        }));

                        string path = DragContainer.ConstrainImage(file.Path, FacebookImage.GetDimensionSize(FacebookImageDimensions.Big));
                        ServiceProvider.ViewManager.AddPhotoToAlbum(album, file.Description, path);
                        count++;

                        Dispatcher.BeginInvoke(new Action(() =>
                        {
                            UploadCount = count;
                            _uploadPhotoStatusTextBlock.Text = "Uploading photo " + (UploadCount + 1) + " of " + FileCount + " to album " + UploadAlbumName;
                            FacebookClientApplication.Current2.MainWindow.SetTaskbarProgress((float)UploadCount / Files.Count);
                        }));
                    }

                    Dispatcher.BeginInvoke(new Action(() =>
                    {
                        ServiceProvider.ViewManager.NavigationCommands.NavigateToContentCommand.Execute(album);
                        FacebookClientApplication.Current2.MainWindow.ClearTaskbarProgress();
                        Hide();
                    }));
                }
                catch (ThreadAbortException)
                {
                }
                catch (Exception)
                {
                    Dispatcher.BeginInvoke(new Action(() =>
                    {
                        _nextPhotoImage.Source     = null;
                        _uploadStatus.Text         = "Upload failed.";
                        _closeCancelButton.Content = "Close";
                    }));
                }
            }));
            _workerThread.Start();
        }
Ejemplo n.º 6
0
 public PhotoExplorerAlbumNode(FacebookPhotoAlbum album)
     : base(album, string.Empty)
 {
     this.Album = album;
 }