public void PastebinLogin() { if (Config.PastebinSettings != null) { try { Pastebin pastebin = new Pastebin(APIKeys.PastebinKey, Config.PastebinSettings); if (pastebin.Login()) { UpdatePastebinStatus(); MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { UpdatePastebinStatus(); MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public UploadResult UploadText(Stream stream, string fileName) { TextUploader textUploader = null; switch (Info.TaskSettings.TextDestination) { case TextDestination.Pastebin: PastebinSettings settings = Program.UploadersConfig.PastebinSettings; if (string.IsNullOrEmpty(settings.TextFormat)) { settings.TextFormat = Info.TaskSettings.AdvancedSettings.TextFormat; } textUploader = new Pastebin(APIKeys.PastebinKey, settings); break; case TextDestination.Paste2: textUploader = new Paste2(new Paste2Settings { TextFormat = Info.TaskSettings.AdvancedSettings.TextFormat }); break; case TextDestination.Slexy: textUploader = new Slexy(new SlexySettings { TextFormat = Info.TaskSettings.AdvancedSettings.TextFormat }); break; case TextDestination.Pastee: textUploader = new Pastee { Lexer = Info.TaskSettings.AdvancedSettings.TextFormat }; break; case TextDestination.Paste_ee: textUploader = new Paste_ee(Program.UploadersConfig.Paste_eeUserAPIKey); break; case TextDestination.Gist: textUploader = Program.UploadersConfig.GistAnonymousLogin ? new Gist(Program.UploadersConfig.GistPublishPublic) : new Gist(Program.UploadersConfig.GistPublishPublic, Program.UploadersConfig.GistOAuth2Info); break; case TextDestination.Upaste: textUploader = new Upaste(Program.UploadersConfig.UpasteUserKey) { IsPublic = Program.UploadersConfig.UpasteIsPublic }; break; case TextDestination.Hastebin: textUploader = new Hastebin() { CustomDomain = Program.UploadersConfig.HastebinCustomDomain, SyntaxHighlighting = Program.UploadersConfig.HastebinSyntaxHighlighting }; break; case TextDestination.CustomTextUploader: CustomUploaderItem customUploader = GetCustomUploader(Program.UploadersConfig.CustomTextUploaderSelected); if (customUploader != null) { textUploader = new CustomTextUploader(customUploader); } break; } if (textUploader != null) { PrepareUploader(textUploader); return textUploader.UploadText(stream, fileName); } return null; }