Beispiel #1
0
        private void loginToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LoginDialog ld = new LoginDialog();

            ld.ShowDialog();

            if (ld.DialogResult == DialogResult.OK)
            {
                pam = new PicasaAlbumsManager(ld.Username, ld.Password);

                //How do we handle failures?
                // pam.login();
                // We done, yet :-/ ...... Well, I wrote some code for it
                // using exception handling, but I thought it was crap, and deleted it.

                // This is how:

                try {
                    pam.login();

                    this.lblStatus.Text = "Connected as " + ld.Username;
                    myAlbums            = pam.getAllAlbums();

                    albumList.DisplayMember = pam.DisplayMember;
                    for (int i = 0; i < myAlbums.Count; i++)
                    {
                        albumList.Items.Add(myAlbums[i]);
                    }
                } catch (UnauthorizedAccessException) {
                    NotifyDialog bad_login = new NotifyDialog();
                    bad_login.NotificationMessage = "Wrong password. Try again.";
                    bad_login.ShowDialog();
                }
            }
        }
Beispiel #2
0
        private void PopulateAlbumOptionMenu(PicasaWeb picasa)
        {
            PicasaAlbumCollection albums = null;

            if (picasa != null)
            {
                try {
                    albums = picasa.GetAlbums();
                } catch {
                    Console.WriteLine("Can't get the albums");
                    picasa = null;
                }
            }

            Gtk.Menu menu = new Gtk.Menu();

            bool disconnected = picasa == null || !account.Connected || albums == null;

            if (disconnected || albums.Count == 0)
            {
                string msg = disconnected ? Catalog.GetString("(Not Connected)")
                                        : Catalog.GetString("(No Albums)");

                Gtk.MenuItem item = new Gtk.MenuItem(msg);
                menu.Append(item);

                ok_button.Sensitive        = false;
                album_optionmenu.Sensitive = false;
                album_button.Sensitive     = false;

                if (disconnected)
                {
                    album_button.Sensitive = false;
                }
            }
            else
            {
                foreach (PicasaAlbum album in albums.AllValues)
                {
                    System.Text.StringBuilder label_builder = new System.Text.StringBuilder();

                    label_builder.Append(album.Title);

                    Gtk.MenuItem item = new Gtk.MenuItem(label_builder.ToString());
                    ((Gtk.Label)item.Child).UseUnderline = false;
                    menu.Append(item);
                }

                ok_button.Sensitive        = items.Length > 0;
                album_optionmenu.Sensitive = true;
                album_button.Sensitive     = true;
            }

            menu.ShowAll();
            album_optionmenu.Menu = menu;
        }
        private void PopulateAlbumOptionMenu(Mono.Google.Picasa.PicasaWeb picasa)
        {
            if (picasa != null)
            {
                try {
                    albums = picasa.GetAlbums();
                } catch {
                    Log.Warning("Picasa: can't get the albums");
                    albums = null;
                    picasa = null;
                }
            }

            bool disconnected = picasa == null || !account.Connected || albums == null;

            if (disconnected || albums.Count == 0)
            {
                string msg = disconnected ? Catalog.GetString("(Not Connected)")
                                        : Catalog.GetString("(No Albums)");

                album_optionmenu.AppendText(msg);

                export_button.Sensitive    = false;
                album_optionmenu.Sensitive = false;
                album_button.Sensitive     = false;

                if (disconnected)
                {
                    album_button.Sensitive = false;
                }
            }
            else
            {
                foreach (PicasaAlbum album in albums.AllValues)
                {
                    System.Text.StringBuilder label_builder = new System.Text.StringBuilder();

                    label_builder.Append(album.Title);
                    label_builder.Append(" (" + album.PicturesCount + ")");

                    album_optionmenu.AppendText(label_builder.ToString());
                }

                export_button.Sensitive    = items.Length > 0;
                album_optionmenu.Sensitive = true;
                album_button.Sensitive     = true;
            }
        }
Beispiel #4
0
        public void HandleAlbumAdded(string title)
        {
            GoogleAccount account = (GoogleAccount)accounts [gallery_optionmenu.History];

            PopulateAlbumOptionMenu(account.Picasa);

            // make the newly created album selected
            PicasaAlbumCollection albums = account.Picasa.GetAlbums();

            for (int i = 0; i < albums.Count; i++)
            {
                if (((PicasaAlbum)albums[i]).Title == title)
                {
                    album_optionmenu.SetHistory((uint)i);
                }
            }
        }