예제 #1
0
 public override UploadResult Upload(Stream stream, string fileName)
 {
     using (TwitterMsg msgBox = new TwitterMsg("Update Twitter Status"))
     {
         msgBox.ShowDialog();
         return(Upload(stream, fileName, msgBox.Message));
     }
 }
 public override UploadResult Upload(Stream stream, string fileName)
 {
     using (TwitterMsg msgBox = new TwitterMsg("Update Twitter Status"))
     {
         msgBox.ShowDialog();
         return Upload(stream, fileName, msgBox.Message);
     }
 }
        public static void TwitterMsg(string url)
        {
            OAuthInfo acc = TwitterGetActiveAccount();

            if (!string.IsNullOrEmpty(acc.UserToken))
            {
                TwitterMsg msg = new TwitterMsg(TwitterGetActiveAccount(), string.Format("{0} - Update Twitter Status...", acc.Description));
                msg.ActiveAccountName = acc.Description;
                msg.Icon          = Resources.zss_main;
                msg.Config        = Engine.ConfigUI.TwitterClientConfig;
                msg.FormClosed   += new FormClosedEventHandler(twitterClient_FormClosed);
                msg.txtTweet.Text = url;
                msg.Show();
            }
        }
        public override UploadResult Upload(Stream stream, string fileName)
        {
            switch (this.Options.TwitPicUploadType)
            {
            case TwitPicUploadType.UPLOAD_IMAGE_ONLY:
                return(Upload(stream, fileName, ""));

            case TwitPicUploadType.UPLOAD_IMAGE_AND_TWITTER:
                using (TwitterMsg msgBox = new TwitterMsg("Update Twitter Status"))
                {
                    msgBox.ShowDialog();
                    return(Upload(stream, fileName, msgBox.Message));
                }
            }
            return(null);
        }
        public static void TwitterMsg(string url)
        {
            TwitterAuthInfo acc = TwitterGetActiveAcct();

            if (!string.IsNullOrEmpty(acc.TokenSecret))
            {
                List <oAuthTwitter> oAccList = new List <oAuthTwitter>();
                foreach (TwitterAuthInfo oAuth in Engine.conf.TwitterAccountsList)
                {
                    oAccList.Add(new oAuthTwitter(Engine.TWITTER_CONSUMER_KEY, Engine.TWITTER_CONSUMER_SECRET, oAuth)
                    {
                        Enabled = acc.AccountName == oAuth.AccountName
                    });
                }
                TwitterMsg msg = new TwitterMsg(oAccList, string.Format("{0} - Update Twitter Status...", acc.AccountName));
                msg.ActiveAccountName = acc.AccountName;
                msg.Icon          = Resources.zss_main;
                msg.Config        = Engine.conf.TwitterClientConfig;
                msg.FormClosed   += new FormClosedEventHandler(twitterClient_FormClosed);
                msg.txtTweet.Text = url;
                msg.Show();
            }
        }
예제 #6
0
파일: UploadTask.cs 프로젝트: Z1ni/ShareX
        private void DoAfterUploadJobs()
        {
            try
            {
                if (Info.TaskSettings.AfterUploadJob.HasFlag(AfterUploadTasks.UseURLShortener) || Info.Job == TaskJob.ShortenURL ||
                    (Info.TaskSettings.AdvancedSettings.AutoShortenURLLength > 0 && Info.Result.URL.Length > Info.TaskSettings.AdvancedSettings.AutoShortenURLLength))
                {
                    UploadResult result = ShortenURL(Info.Result.URL);

                    if (result != null)
                    {
                        Info.Result.ShortenedURL = result.ShortenedURL;
                    }
                }

                if (Info.TaskSettings.AfterUploadJob.HasFlag(AfterUploadTasks.ShareURLToSocialNetworkingService))
                {
                    OAuthInfo twitterOAuth = Program.UploadersConfig.TwitterOAuthInfoList.ReturnIfValidIndex(Program.UploadersConfig.TwitterSelectedAccount);

                    if (twitterOAuth != null)
                    {
                        using (TwitterMsg twitter = new TwitterMsg(twitterOAuth))
                        {
                            twitter.Message = Info.Result.ToString();
                            twitter.Config  = Program.UploadersConfig.TwitterClientConfig;
                            twitter.ShowDialog();
                        }
                    }
                }

                if (Info.TaskSettings.AfterUploadJob.HasFlag(AfterUploadTasks.SendURLWithEmail))
                {
                    using (EmailForm emailForm = new EmailForm(Program.UploadersConfig.EmailRememberLastTo ? Program.UploadersConfig.EmailLastTo : string.Empty,
                                                               Program.UploadersConfig.EmailDefaultSubject, Info.Result.ToString()))
                    {
                        emailForm.Icon = ShareXResources.Icon;

                        if (emailForm.ShowDialog() == DialogResult.OK)
                        {
                            if (Program.UploadersConfig.EmailRememberLastTo)
                            {
                                Program.UploadersConfig.EmailLastTo = emailForm.ToEmail;
                            }

                            Email email = new Email
                            {
                                SmtpServer = Program.UploadersConfig.EmailSmtpServer,
                                SmtpPort   = Program.UploadersConfig.EmailSmtpPort,
                                FromEmail  = Program.UploadersConfig.EmailFrom,
                                Password   = Program.UploadersConfig.EmailPassword
                            };

                            email.Send(emailForm.ToEmail, emailForm.Subject, emailForm.Body);
                        }
                    }
                }

                if (Info.TaskSettings.AfterUploadJob.HasFlag(AfterUploadTasks.CopyURLToClipboard))
                {
                    string txt;

                    if (!string.IsNullOrEmpty(Info.TaskSettings.AdvancedSettings.ClipboardContentFormat))
                    {
                        txt = new UploadInfoParser().Parse(Info, Info.TaskSettings.AdvancedSettings.ClipboardContentFormat);
                    }
                    else
                    {
                        txt = Info.Result.ToString();
                    }

                    if (!string.IsNullOrEmpty(txt))
                    {
                        ClipboardHelpers.CopyText(txt);
                    }
                }
            }
            catch (Exception e)
            {
                DebugHelper.WriteException(e);
                if (Info.Result == null)
                {
                    Info.Result = new UploadResult();
                }
                Info.Result.Errors.Add(e.ToString());
            }
        }
예제 #7
0
        public override UploadResult Upload(Stream stream, string fileName)
        {
            switch (Options.UploadType)
            {
                case YfrogUploadType.UPLOAD_IMAGE_ONLY:
                    return Upload(stream, fileName, "");
                case YfrogUploadType.UPLOAD_IMAGE_AND_TWITTER:
                    using (TwitterMsg msgBox = new TwitterMsg("Update Twitter Status"))
                    {
                        msgBox.ShowDialog();
                        return Upload(stream, fileName, msgBox.Message);
                    }
            }

            return null;
        }
        static void twitterClient_FormClosed(object sender, FormClosedEventArgs e)
        {
            TwitterMsg msg = sender as TwitterMsg;

            Engine.conf.TwitterClientConfig = msg.Config;
        }