public UploadResult UploadImage(Stream stream, string fileName) { ImageUploader imageUploader = null; switch (Info.TaskSettings.ImageDestination) { case ImageDestination.Imgur: if (Program.UploadersConfig.ImgurOAuth2Info == null) { Program.UploadersConfig.ImgurOAuth2Info = new OAuth2Info(APIKeys.ImgurClientID, APIKeys.ImgurClientSecret); } imageUploader = new Imgur_v3(Program.UploadersConfig.ImgurOAuth2Info) { UploadMethod = Program.UploadersConfig.ImgurAccountType, DirectLink = Program.UploadersConfig.ImgurDirectLink, ThumbnailType = Program.UploadersConfig.ImgurThumbnailType, UploadAlbumID = Program.UploadersConfig.ImgurAlbumID }; break; case ImageDestination.ImageShack: Program.UploadersConfig.ImageShackSettings.ThumbnailWidth = Info.TaskSettings.AdvancedSettings.ThumbnailPreferredWidth; Program.UploadersConfig.ImageShackSettings.ThumbnailHeight = Info.TaskSettings.AdvancedSettings.ThumbnailPreferredHeight; imageUploader = new ImageShackUploader(APIKeys.ImageShackKey, Program.UploadersConfig.ImageShackSettings); break; case ImageDestination.TinyPic: imageUploader = new TinyPicUploader(APIKeys.TinyPicID, APIKeys.TinyPicKey, Program.UploadersConfig.TinyPicAccountType, Program.UploadersConfig.TinyPicRegistrationCode); break; case ImageDestination.Flickr: imageUploader = new FlickrUploader(APIKeys.FlickrKey, APIKeys.FlickrSecret, Program.UploadersConfig.FlickrAuthInfo, Program.UploadersConfig.FlickrSettings); break; case ImageDestination.Photobucket: imageUploader = new Photobucket(Program.UploadersConfig.PhotobucketOAuthInfo, Program.UploadersConfig.PhotobucketAccountInfo); break; case ImageDestination.Picasa: imageUploader = new Picasa(Program.UploadersConfig.PicasaOAuth2Info) { AlbumID = Program.UploadersConfig.PicasaAlbumID }; break; case ImageDestination.Twitter: OAuthInfo twitterOAuth = Program.UploadersConfig.TwitterOAuthInfoList.ReturnIfValidIndex(Program.UploadersConfig.TwitterSelectedAccount); imageUploader = new Twitter(twitterOAuth); break; case ImageDestination.CustomImageUploader: if (Program.UploadersConfig.CustomUploadersList.IsValidIndex(Program.UploadersConfig.CustomImageUploaderSelected)) { imageUploader = new CustomImageUploader(Program.UploadersConfig.CustomUploadersList[Program.UploadersConfig.CustomImageUploaderSelected]); } break; } if (imageUploader != null) { PrepareUploader(imageUploader); return imageUploader.Upload(stream, fileName); } return null; }
public void PicasaRefreshAlbumList() { try { lvPicasaAlbumList.Items.Clear(); if (OAuth2Info.CheckOAuth(Config.PicasaOAuth2Info)) { List<PicasaAlbumInfo> albums = new Picasa(Config.PicasaOAuth2Info).GetAlbumList(); if (albums != null && albums.Count > 0) { foreach (PicasaAlbumInfo album in albums) { ListViewItem lvi = new ListViewItem(album.ID); lvi.SubItems.Add(album.Name ?? ""); lvi.SubItems.Add(album.Summary ?? ""); lvi.Tag = album; lvPicasaAlbumList.Items.Add(lvi); } } } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public UploadResult UploadImage(Stream stream, string fileName) { ImageUploader imageUploader = null; switch (Info.TaskSettings.ImageDestination) { case ImageDestination.ImageShack: Program.UploadersConfig.ImageShackSettings.ThumbnailWidth = Info.TaskSettings.AdvancedSettings.ThumbnailPreferredWidth; Program.UploadersConfig.ImageShackSettings.ThumbnailHeight = Info.TaskSettings.AdvancedSettings.ThumbnailPreferredHeight; imageUploader = new ImageShackUploader(APIKeys.ImageShackKey, Program.UploadersConfig.ImageShackSettings); break; case ImageDestination.TinyPic: imageUploader = new TinyPicUploader(APIKeys.TinyPicID, APIKeys.TinyPicKey, Program.UploadersConfig.TinyPicAccountType, Program.UploadersConfig.TinyPicRegistrationCode); break; case ImageDestination.Imgur: if (Program.UploadersConfig.ImgurOAuth2Info == null) { Program.UploadersConfig.ImgurOAuth2Info = new OAuth2Info(APIKeys.ImgurClientID, APIKeys.ImgurClientSecret); } imageUploader = new Imgur_v3(Program.UploadersConfig.ImgurOAuth2Info) { UploadMethod = Program.UploadersConfig.ImgurAccountType, ThumbnailType = Program.UploadersConfig.ImgurThumbnailType, UploadAlbumID = Program.UploadersConfig.ImgurAlbumID }; break; case ImageDestination.Flickr: imageUploader = new FlickrUploader(APIKeys.FlickrKey, APIKeys.FlickrSecret, Program.UploadersConfig.FlickrAuthInfo, Program.UploadersConfig.FlickrSettings); break; case ImageDestination.Photobucket: imageUploader = new Photobucket(Program.UploadersConfig.PhotobucketOAuthInfo, Program.UploadersConfig.PhotobucketAccountInfo); break; case ImageDestination.Picasa: imageUploader = new Picasa(Program.UploadersConfig.PicasaOAuth2Info) { AlbumID = Program.UploadersConfig.PicasaAlbumID }; break; case ImageDestination.Twitpic: int indexTwitpic = Program.UploadersConfig.TwitterSelectedAccount; if (Program.UploadersConfig.TwitterOAuthInfoList != null && Program.UploadersConfig.TwitterOAuthInfoList.IsValidIndex(indexTwitpic)) { imageUploader = new TwitPicUploader(APIKeys.TwitPicKey, Program.UploadersConfig.TwitterOAuthInfoList[indexTwitpic]) { TwitPicThumbnailMode = Program.UploadersConfig.TwitPicThumbnailMode, ShowFull = Program.UploadersConfig.TwitPicShowFull }; } break; case ImageDestination.Twitsnaps: int indexTwitsnaps = Program.UploadersConfig.TwitterSelectedAccount; if (Program.UploadersConfig.TwitterOAuthInfoList.IsValidIndex(indexTwitsnaps)) { imageUploader = new TwitSnapsUploader(APIKeys.TwitsnapsKey, Program.UploadersConfig.TwitterOAuthInfoList[indexTwitsnaps]); } break; case ImageDestination.yFrog: YfrogOptions yFrogOptions = new YfrogOptions(APIKeys.ImageShackKey); yFrogOptions.Username = Program.UploadersConfig.YFrogUsername; yFrogOptions.Password = Program.UploadersConfig.YFrogPassword; yFrogOptions.Source = Application.ProductName; imageUploader = new YfrogUploader(yFrogOptions); break; case ImageDestination.CustomImageUploader: if (Program.UploadersConfig.CustomUploadersList.IsValidIndex(Program.UploadersConfig.CustomImageUploaderSelected)) { imageUploader = new CustomImageUploader(Program.UploadersConfig.CustomUploadersList[Program.UploadersConfig.CustomImageUploaderSelected]); } break; } if (imageUploader != null) { PrepareUploader(imageUploader); return imageUploader.Upload(stream, fileName); } return null; }
public void PicasaAuthOpen() { try { OAuth2Info oauth = new OAuth2Info(APIKeys.GoogleClientID, APIKeys.GoogleClientSecret); string url = new Picasa(oauth).GetAuthorizationURL(); if (!string.IsNullOrEmpty(url)) { Config.PicasaOAuth2Info = oauth; Helpers.OpenURL(url); DebugHelper.WriteLine("PicasaAuthOpen - Authorization URL is opened: " + url); } else { DebugHelper.WriteLine("PicasaAuthOpen - Authorization URL is empty."); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private UploadResult UploadScreenshot(string ssPath) { ImageUploader imageUploader = null; UploadResult ur = null; if (File.Exists(ssPath)) { if (!string.IsNullOrEmpty(Program.Settings.PtpImgCode)) { imageUploader = new PtpImageUploader(Crypt.Decrypt(Program.Settings.PtpImgCode)); } else { switch ((ImageDestination)Program.Settings.ImageUploaderType) { case ImageDestination.TinyPic: imageUploader = new TinyPicUploader(ZKeys.TinyPicID, ZKeys.TinyPicKey, Program.UploadersConfig.TinyPicAccountType, Program.UploadersConfig.TinyPicRegistrationCode); break; case ImageDestination.Imgur: if (Program.UploadersConfig.ImgurOAuth2Info == null) { Program.UploadersConfig.ImgurOAuth2Info = new OAuth2Info(APIKeys.ImgurClientID, APIKeys.ImgurClientSecret); } imageUploader = new Imgur_v3(Program.UploadersConfig.ImgurOAuth2Info) { UploadMethod = Program.UploadersConfig.ImgurAccountType, ThumbnailType = Program.UploadersConfig.ImgurThumbnailType, UploadAlbumID = Program.UploadersConfig.ImgurAlbumID }; break; case ImageDestination.Flickr: imageUploader = new FlickrUploader(APIKeys.FlickrKey, APIKeys.FlickrSecret, Program.UploadersConfig.FlickrAuthInfo, Program.UploadersConfig.FlickrSettings); break; case ImageDestination.Photobucket: imageUploader = new Photobucket(Program.UploadersConfig.PhotobucketOAuthInfo, Program.UploadersConfig.PhotobucketAccountInfo); break; case ImageDestination.Picasa: imageUploader = new Picasa(Program.UploadersConfig.PicasaOAuth2Info) { AlbumID = Program.UploadersConfig.PicasaAlbumID }; break; case ImageDestination.Twitpic: int indexTwitpic = Program.UploadersConfig.TwitterSelectedAccount; if (Program.UploadersConfig.TwitterOAuthInfoList != null && Program.UploadersConfig.TwitterOAuthInfoList.IsValidIndex(indexTwitpic)) { imageUploader = new TwitPicUploader(APIKeys.TwitPicKey, Program.UploadersConfig.TwitterOAuthInfoList[indexTwitpic]) { TwitPicThumbnailMode = Program.UploadersConfig.TwitPicThumbnailMode, ShowFull = Program.UploadersConfig.TwitPicShowFull }; } break; case ImageDestination.Twitsnaps: int indexTwitsnaps = Program.UploadersConfig.TwitterSelectedAccount; if (Program.UploadersConfig.TwitterOAuthInfoList.IsValidIndex(indexTwitsnaps)) { imageUploader = new TwitSnapsUploader(APIKeys.TwitsnapsKey, Program.UploadersConfig.TwitterOAuthInfoList[indexTwitsnaps]); } break; case ImageDestination.yFrog: YfrogOptions yFrogOptions = new YfrogOptions(APIKeys.ImageShackKey); yFrogOptions.Username = Program.UploadersConfig.YFrogUsername; yFrogOptions.Password = Program.UploadersConfig.YFrogPassword; yFrogOptions.Source = Application.ProductName; imageUploader = new YfrogUploader(yFrogOptions); break; } } if (imageUploader != null) { ReportProgress(ProgressType.UPDATE_STATUSBAR_DEBUG, string.Format("Uploading {0}.", Path.GetFileName(ssPath))); ur = imageUploader.Upload(ssPath); } if (ur != null) { if (!string.IsNullOrEmpty(ur.URL)) { ReportProgress(ProgressType.UPDATE_STATUSBAR_DEBUG, string.Format("Uploaded {0}.", Path.GetFileName(ssPath))); } } else { ReportProgress(ProgressType.UPDATE_STATUSBAR_DEBUG, string.Format("Failed uploading {0}. Try again later.", Path.GetFileName(ssPath))); } } return ur; }