Esempio n. 1
0
        public override System.Windows.Forms.DialogResult CreateContent(System.Windows.Forms.IWin32Window dialogOwner, ref string newContent)
        {
            using (InsertFlickrImageForm flickr = new InsertFlickrImageForm(new FlickrContext(base.Options)))
            {
                System.Windows.Forms.DialogResult formResult = flickr.ShowDialog(dialogOwner);

                FlickrContext context = new FlickrContext(base.Options);
                context.FlickrUserId   = flickr.FlickrUserId.Trim();
                context.FlickrUserName = flickr.FlickrUserName.Trim();

                if (formResult == System.Windows.Forms.DialogResult.OK)
                {
                    newContent = FlickrPluginHelper.GenerateFlickrHtml(flickr.SelectedPhoto, flickr.ImageSourceUrl, flickr.CssClass, flickr.BorderThickness, flickr.VerticalPadding, flickr.HorizontalPadding, flickr.Alignment, flickr.EnableHyperLink, flickr.FlickrUserId);
                }
                return(formResult);
            }
        }
Esempio n. 2
0
        public override void CreateContentFromUrl(string url, ref string title, ref string newContent)
        {
            Match m = Regex.Match(url, PHOTO_REGEX_URL);

            if (!m.Success)
            {
                base.CreateContentFromUrl(url, ref title, ref newContent);
            }
            else
            {
                string photoId = m.Groups["id"].Value;

                // get photo
                FlickrNet.Flickr flickrProxy = FlickrPluginHelper.GetFlickrProxy();

                FlickrNet.PhotoInfo photo = flickrProxy.PhotosGetInfo(photoId);

                title      = photo.Title;
                newContent = string.Format("<p><a href=\"{0}\" title=\"{2}\"><img alt=\"{2}\" border=\"0\" src=\"{1}\"></a></p>", photo.WebUrl, photo.MediumUrl, HtmlServices.HtmlEncode(photo.Title));
            }
        }
Esempio n. 3
0
        public override System.Windows.Forms.DialogResult CreateContent(System.Windows.Forms.IWin32Window dialogOwner, ref string newContent)
        {
            DialogResult       result;
            DoWorkEventHandler handler = null;

            FlickrNet.Auth validAuthToken = null;
            FlickrContext  context        = new FlickrContext(base.Options);

            token = context.FlickrAuthToken;

            // we have a token saved already and
            // need to verify it with Flickr
            if (!string.IsNullOrEmpty(token))
            {
                using (VerifyAuth vauth = new VerifyAuth())
                {
                    if (handler == null)
                    {
                        handler = delegate(object sender, DoWorkEventArgs args)
                        {
                            FlickrNet.Flickr fp = FlickrPluginHelper.GetFlickrProxy();
                            validAuthToken = fp.AuthCheckToken(token);
                            if (validAuthToken != null)
                            {
                                token = validAuthToken.Token;
                            }
                        };
                    }
                    vauth.DoWork += handler;
                    result        = vauth.ShowDialog(dialogOwner);
                    if (result != DialogResult.OK)
                    {
                        return(result);
                    }
                }
            }

            /* we didn't get a valid auth token
             * it might have expired or is just invalid/revoked
             * prompt the user to re-auth
             * OR
             * we don't have a saved token and know
             * we need to get one first so show the auth process
             */
            if (string.IsNullOrEmpty(token) || (validAuthToken == null))
            {
                token = AuthManager.Authenticate(dialogOwner, context);
            }

            if (string.IsNullOrEmpty(token))
            {
                return(DialogResult.Cancel);
            }

            using (InsertFlickrImageForm flickr = new InsertFlickrImageForm(new FlickrContext(base.Options)))
            {
                System.Windows.Forms.DialogResult formResult = flickr.ShowDialog(dialogOwner);

                context.FlickrUserId     = flickr.FlickrUserId.Trim();
                context.FlickrUserName   = flickr.FlickrUserName.Trim();
                context.FlickrAuthUserId = flickr.FlickrAuthUserId.Trim();

                if (formResult == System.Windows.Forms.DialogResult.OK)
                {
                    ImageSize imgsize = flickr.SelectedImageSize;

                    foreach (FlickrNet.Photo photo in flickr.SelectedPhotos)
                    {
                        newContent += FlickrPluginHelper.GenerateFlickrHtml(photo, GetImageUrl(photo, imgsize), flickr.CssClass, flickr.BorderThickness, flickr.VerticalPadding, flickr.HorizontalPadding, flickr.Alignment, flickr.EnableHyperLink, flickr.FlickrUserId);
                    }
                }
                return(formResult);
            }
        }