public void StartQuery(string uri, string albumTitle) { UserState us = new UserState(); this.states.Add(us); us.opType = UserState.OperationType.query; us.filename = albumTitle; this.picasaService.QueryFeedAync(new Uri(uri), DateTime.MinValue, us); }
private void CreateAnotherSaveFile(UserState us) { if (us.feed.Entries.Count > 0) { PicasaEntry p = us.feed.Entries[0] as PicasaEntry; us.filename = us.foldername + "\\image" + us.counter.ToString() + ".jpg"; this.picasaService.QueryStreamAync(new Uri(p.Media.Content.Attributes["url"] as string), DateTime.MinValue, us); } else if (us.feed.Entries.Count == 0 && us.feed.NextChunk != null) { } else { this.Close(); } }
private void OnDone(object sender, AsyncOperationCompletedEventArgs e) { UserState ut = e.UserState as UserState; if (this.states.Contains(ut) == false) return; this.states.Remove(ut); if (e.Error == null && e.Cancelled == false) { if (ut.opType == UserState.OperationType.query || ut.opType == UserState.OperationType.queryForBackup) { if (e.Feed != null) { this.photoFeed = e.Feed as PicasaFeed; this.InitializeList(ut.filename); } } if (ut.opType == UserState.OperationType.upload) { if (e.Entry != null) { ListViewItem item = new ListViewItem(e.Entry.Title.Text); item.Tag = e.Entry; this.PhotoList.Items.Add(item); this.FileInfo.Text = "Upload succeeded"; } } if (ut.opType == UserState.OperationType.download || ut.opType == UserState.OperationType.downloadList) { if (e.ResponseStream != null) { WriteFile(ut.filename, e.ResponseStream); this.FileInfo.Text = "Saved file: " + ut.filename; } } if (ut.opType == UserState.OperationType.downloadList) { // we need to create a new object for uniqueness UserState u = new UserState(); u.counter = ut.counter + 1; u.feed = ut.feed; u.foldername = ut.foldername; u.opType = UserState.OperationType.downloadList; if (u.feed.Entries.Count > 0) { u.feed.Entries.RemoveAt(0); this.PhotoList.Items.RemoveAt(0); } this.states.Add(u); SaveAnotherPictureDelegate d = new SaveAnotherPictureDelegate(this.CreateAnotherSaveFile); this.BeginInvoke(d, u); } if (ut.opType == UserState.OperationType.queryForBackup) { UserState u = new UserState(); u.opType = UserState.OperationType.downloadList; u.feed = this.photoFeed; u.counter = 1; u.foldername = ut.foldername; u.filename = ut.foldername + "\\image1.jpg"; this.states.Add(u); SaveAnotherPictureDelegate d = new SaveAnotherPictureDelegate(this.CreateAnotherSaveFile); this.BeginInvoke(d, u); } } this.progressBar.Value = 0; if (this.states.Count == 0) { this.CancelAsync.Enabled = false; this.CancelAsync.Visible = false; } }
private void UploadPhoto_Click(object sender, System.EventArgs e) { DialogResult result = openFileDialog.ShowDialog(); if( result == DialogResult.OK ) { string[] files = openFileDialog.FileNames; // Open each file and display the image in PictureBox1. // Call Application.DoEvents to force a repaint after each // file is read. foreach (string file in files ) { System.IO.FileInfo fileInfo = new System.IO.FileInfo(file); System.IO.FileStream fileStream = fileInfo.OpenRead(); this.FileInfo.Text = "Starting upload...."; PicasaEntry entry = new PhotoEntry(); UserState ut = new UserState(); ut.opType = UserState.OperationType.upload; this.states.Add(ut); entry.MediaSource = new Google.GData.Client.MediaFileSource(fileStream, file, "image/jpeg"); this.picasaService.InsertAsync(new Uri(this.photoFeed.Post), entry, ut); } } }
public void DoSaveImageFile(PicasaEntry entry, string filename) { if (entry.Media != null && entry.Media.Content != null) { UserState ut = new UserState(); ut.opType = UserState.OperationType.download; ut.filename = filename; this.states.Add(ut); this.picasaService.QueryStreamAync(new Uri(entry.Media.Content.Attributes["url"] as string), DateTime.MinValue, ut); } }
public void BackupAlbum(string albumUri, string foldername) { UserState us = new UserState(); us.opType = UserState.OperationType.queryForBackup; us.filename = "Starting backup to : " + foldername; us.foldername = foldername; this.states.Add(us); this.picasaService.QueryFeedAync(new Uri(albumUri), DateTime.MinValue, us); }
private void OnDone(object sender, AsyncOperationCompletedEventArgs e) { UserState ut = e.UserState as UserState; if (this.states.Contains(ut) == false) { return; } this.states.Remove(ut); if (e.Error == null && e.Cancelled == false) { if (ut.opType == UserState.OperationType.query || ut.opType == UserState.OperationType.queryForBackup) { if (e.Feed != null) { this.photoFeed = e.Feed as PicasaFeed; this.InitializeList(ut.filename); } } if (ut.opType == UserState.OperationType.upload) { if (e.Entry != null) { ListViewItem item = new ListViewItem(e.Entry.Title.Text); item.Tag = e.Entry; this.PhotoList.Items.Add(item); this.FileInfo.Text = "Upload succeeded"; } } if (ut.opType == UserState.OperationType.download || ut.opType == UserState.OperationType.downloadList) { if (e.ResponseStream != null) { WriteFile(ut.filename, e.ResponseStream); this.FileInfo.Text = "Saved file: " + ut.filename; } } if (ut.opType == UserState.OperationType.downloadList) { // we need to create a new object for uniqueness UserState u = new UserState(); u.counter = ut.counter + 1; u.feed = ut.feed; u.foldername = ut.foldername; u.opType = UserState.OperationType.downloadList; if (u.feed.Entries.Count > 0) { u.feed.Entries.RemoveAt(0); this.PhotoList.Items.RemoveAt(0); } this.states.Add(u); SaveAnotherPictureDelegate d = new SaveAnotherPictureDelegate(this.CreateAnotherSaveFile); this.BeginInvoke(d, u); } if (ut.opType == UserState.OperationType.queryForBackup) { UserState u = new UserState(); u.opType = UserState.OperationType.downloadList; u.feed = this.photoFeed; u.counter = 1; u.foldername = ut.foldername; u.filename = ut.foldername + "\\image1.jpg"; this.states.Add(u); SaveAnotherPictureDelegate d = new SaveAnotherPictureDelegate(this.CreateAnotherSaveFile); this.BeginInvoke(d, u); } } this.progressBar.Value = 0; if (this.states.Count == 0) { this.CancelAsync.Enabled = false; this.CancelAsync.Visible = false; } }