private void SetDefaultSettings() { if (Program.DefaultTaskSettings != null) { TaskSettings defaultTaskSettings = Program.DefaultTaskSettings.Copy(); if (UseDefaultAfterCaptureJob) { AfterCaptureJob = defaultTaskSettings.AfterCaptureJob; } if (UseDefaultAfterUploadJob) { AfterUploadJob = defaultTaskSettings.AfterUploadJob; } if (UseDefaultDestinations) { ImageDestination = defaultTaskSettings.ImageDestination; ImageFileDestination = defaultTaskSettings.ImageFileDestination; TextDestination = defaultTaskSettings.TextDestination; TextFileDestination = defaultTaskSettings.TextFileDestination; FileDestination = defaultTaskSettings.FileDestination; URLShortenerDestination = defaultTaskSettings.URLShortenerDestination; URLSharingServiceDestination = defaultTaskSettings.URLSharingServiceDestination; } if (UseDefaultGeneralSettings) { GeneralSettings = defaultTaskSettings.GeneralSettings; } if (UseDefaultImageSettings) { ImageSettings = defaultTaskSettings.ImageSettings; } if (UseDefaultCaptureSettings) { CaptureSettings = defaultTaskSettings.CaptureSettings; } if (UseDefaultUploadSettings) { UploadSettings = defaultTaskSettings.UploadSettings; } if (UseDefaultActions) { ExternalPrograms = defaultTaskSettings.ExternalPrograms; } if (UseDefaultToolsSettings) { ToolsSettings = defaultTaskSettings.ToolsSettings; } if (UseDefaultAdvancedSettings) { AdvancedSettings = defaultTaskSettings.AdvancedSettings; } } }
public static void UploadImage(Image img, ImageDestination imageDestination, FileDestination imageFileDestination) { if (img != null) { TaskSettings taskSettings = TaskSettings.GetDefaultTaskSettings(); taskSettings.UseDefaultAfterCaptureJob = false; taskSettings.AfterCaptureJob = AfterCaptureTasks.UploadImageToHost; taskSettings.UseDefaultDestinations = false; taskSettings.ImageDestination = imageDestination; taskSettings.ImageFileDestination = imageFileDestination; RunImageTask(img, taskSettings); } }
public static void UploadImage(Image img, ImageDestination imageDestination) { if (img != null) { TaskSettings taskSettings = TaskSettings.GetDefaultTaskSettings(); taskSettings.UseDefaultDestinations = false; taskSettings.ImageDestination = imageDestination; RunImageTask(img, taskSettings); } }
public static ImageUploaderService GetImageUploaderServiceByEnum(ImageDestination enumValue) { return(imageUploaderServices.FirstOrDefault(x => x.EnumValue == enumValue)); }
private void UploadImage(ImageDestination imageUploaderType, Stream data) { ImageUploader imageUploader = null; switch (imageUploaderType) { case ImageDestination.ImageShack: imageUploader = new ImageShackUploader(Engine.ConfigUI.ApiKeysConfig.ImageShackKey, Engine.ConfigUploaders.ImageShackAccountType, Engine.ConfigUploaders.ImageShackRegistrationCode) { IsPublic = Engine.ConfigUploaders.ImageShackShowImagesInPublic }; break; case ImageDestination.TinyPic: imageUploader = new TinyPicUploader(Engine.ConfigUI.ApiKeysConfig.TinyPicID, Engine.ConfigUI.ApiKeysConfig.TinyPicKey, Engine.ConfigUploaders.TinyPicAccountType, Engine.ConfigUploaders.TinyPicRegistrationCode); break; case ImageDestination.Imgur: imageUploader = new Imgur(Engine.ConfigUploaders.ImgurAccountType, Engine.ConfigUI.ApiKeysConfig.ImgurAnonymousKey, Engine.ConfigUploaders.ImgurOAuthInfo) { ThumbnailType = Engine.ConfigUploaders.ImgurThumbnailType }; break; case ImageDestination.Flickr: imageUploader = new FlickrUploader(Engine.ConfigUI.ApiKeysConfig.FlickrKey, Engine.ConfigUI.ApiKeysConfig.FlickrSecret, Engine.ConfigUploaders.FlickrAuthInfo, Engine.ConfigUploaders.FlickrSettings); break; case ImageDestination.Photobucket: imageUploader = new Photobucket(Engine.ConfigUploaders.PhotobucketOAuthInfo, Engine.ConfigUploaders.PhotobucketAccountInfo); break; case ImageDestination.UploadScreenshot: imageUploader = new UploadScreenshot(Engine.ConfigUI.ApiKeysConfig.UploadScreenshotKey); break; case ImageDestination.Twitpic: var twitpicOpt = new TwitPicOptions(); twitpicOpt.Username = Engine.ConfigUploaders.TwitPicUsername; twitpicOpt.Password = Engine.ConfigUploaders.TwitPicPassword; // twitpicOpt.TwitPicUploadType = Engine.conf.TwitPicUploadMode; twitpicOpt.TwitPicThumbnailMode = Engine.ConfigUploaders.TwitPicThumbnailMode; twitpicOpt.ShowFull = Engine.ConfigUploaders.TwitPicShowFull; imageUploader = new TwitPicUploader(twitpicOpt); break; case ImageDestination.Twitsnaps: imageUploader = new TwitSnapsUploader(Engine.ConfigUI.ApiKeysConfig.TwitsnapsKey, Adapter.TwitterGetActiveAccount()); break; case ImageDestination.yFrog: var yfrogOp = new YfrogOptions(Engine.ConfigUI.ApiKeysConfig.ImageShackKey); yfrogOp.Username = Engine.ConfigUploaders.YFrogUsername; yfrogOp.Password = Engine.ConfigUploaders.YFrogPassword; yfrogOp.Source = Application.ProductName; // yfrogOp.UploadType = Engine.conf.YfrogUploadMode; imageUploader = new YfrogUploader(yfrogOp); break; /*case ImageDestination.MediaWiki: UploadToMediaWiki(); break;*/ case ImageDestination.FileUploader: foreach (FileDestination ft in WorkflowConfig.DestConfig.FileUploaders) { UploadFile(ft, data); } break; } if (imageUploader != null) { imageUploader.ProgressChanged += (x) => UploadProgressChanged(x); DestinationName = WorkflowConfig.DestConfig.ToStringImageUploaders(); DebugHelper.WriteLine("Initialized " + DestinationName); if (data != null) { if (Engine.ConfigUI == null) { Engine.ConfigUI = new XMLSettings(); } for (int i = 0; i <= Engine.ConfigUI.ErrorRetryCount; i++) { var ur_remote_img = new UploadResult { LocalFilePath = Info.LocalFilePath }; ur_remote_img = imageUploader.Upload(data, Info.FileName); ur_remote_img.Host = imageUploaderType.GetDescription(); AddUploadResult(ur_remote_img); Errors = imageUploader.Errors; if (UploadResults.Count > 0 && string.IsNullOrEmpty(UploadResults[UploadResults.Count - 1].URL)) { MyWorker.ReportProgress((int)ProgressType.ShowTrayWarning, string.Format("Retrying... Attempt {1}", imageUploaderType.GetDescription(), i + 1)); } else { break; } } } } }
private bool HasValidImageUploader(bool bHasValidFileUploader) { foreach (ToolStripMenuItem tsmi in tsddbDestImage.DropDownItems) { ImageDestination ut = (ImageDestination)tsmi.Tag; switch (ut) { case ImageDestination.FileUploader: tsmi.Enabled = bHasValidFileUploader; break; case ImageDestination.Flickr: tsmi.Enabled = !string.IsNullOrEmpty(Engine.ConfigUploaders.FlickrAuthInfo.Token); break; case ImageDestination.ImageShack: tsmi.Enabled = Engine.ConfigUploaders.ImageShackAccountType == AccountType.Anonymous || Engine.ConfigUploaders.ImageShackAccountType == AccountType.User && !string.IsNullOrEmpty(Engine.ConfigUploaders.ImageShackRegistrationCode); break; case ImageDestination.Imgur: tsmi.Enabled = Engine.ConfigUploaders.ImgurOAuthInfo != null; break; /*case ImageDestination.MediaWiki: * tsmi.Enabled = Engine.ConfigUploaders.MediaWikiAccountList.Count > 0; * break;*/ case ImageDestination.Photobucket: tsmi.Enabled = Engine.ConfigUploaders.PhotobucketOAuthInfo != null; break; case ImageDestination.TinyPic: tsmi.Enabled = Engine.ConfigUploaders.TinyPicAccountType == AccountType.Anonymous || Engine.ConfigUploaders.TinyPicAccountType == AccountType.User && !string.IsNullOrEmpty(Engine.ConfigUploaders.TinyPicRegistrationCode); break; case ImageDestination.Twitpic: tsmi.Enabled = !string.IsNullOrEmpty(Engine.ConfigUploaders.TwitPicPassword); break; case ImageDestination.Twitsnaps: tsmi.Enabled = Engine.ConfigUploaders.TwitterOAuthInfoList.Count > 0; break; case ImageDestination.UploadScreenshot: break; case ImageDestination.yFrog: tsmi.Enabled = !string.IsNullOrEmpty(Engine.ConfigUploaders.YFrogPassword); break; } } foreach (ToolStripMenuItem tsmi in tsddbDestImage.DropDownItems) { if (!tsmi.Enabled) { tsmi.Checked = false; // if not enabled then we don't need it checked either issue 604 } } foreach (ToolStripMenuItem tsmi in tsddbDestImage.DropDownItems) { if (tsmi.Enabled && tsmi.Checked) { return(true); } } return(false); }