private void SelectPostLinkForm_ValidatePost(object sender, ValidatePostEventArgs ea)
        {
            PostInfo postInfo = ea.PostInfo;

            if (postInfo.Permalink == String.Empty)
            {
                // see if we can do a direct fetch from the weblog
                using (new WaitCursor())
                {
                    BlogPost blogPost = PostHelper.SafeRetrievePost(postInfo, 10000);
                    if (blogPost != null)
                    {
                        _postLink  = blogPost.Permalink;
                        _postTitle = blogPost.Title;
                    }
                }

                // if we still don't have it then display an error message
                if (_postLink == String.Empty)
                {
                    // saving the company a few dollars by not putting this one
                    // in DisplayMessages.xml, since it's already been translated
                    // in Strings.resx.
                    DisplayMessage message = new DisplayMessage(MessageId.None);
                    message.Title = string.Format(CultureInfo.CurrentCulture, Res.Get(StringId.MissingPostLinkCaption),
                                                  postInfo.IsPage ? Res.Get(StringId.Page) : Res.Get(StringId.Post));
                    message.Text = string.Format(CultureInfo.CurrentCulture, Res.Get(StringId.MissingPostLinkExplanation),
                                                 postInfo.IsPage ? Res.Get(StringId.PageLower) : Res.Get(StringId.PostLower),
                                                 ApplicationEnvironment.ProductNameQualified);
                    message.Type    = MessageBoxIcon.Exclamation;
                    message.Buttons = MessageBoxButtons.OK;
                    message.Show(ea.OpenPostDialog);

                    // fail validation
                    ea.PostIsValid = false;
                }
            }
            else
            {
                _postLink  = postInfo.Permalink;
                _postTitle = postInfo.Title;
            }
        }
        private void SelectPostLinkForm_ValidatePost(object sender, ValidatePostEventArgs ea)
        {
            PostInfo postInfo = ea.PostInfo;
            if (postInfo.Permalink == String.Empty)
            {
                // see if we can do a direct fetch from the weblog
                using (new WaitCursor())
                {
                    BlogPost blogPost = PostHelper.SafeRetrievePost(postInfo, 10000);
                    if (blogPost != null)
                    {
                        _postLink = blogPost.Permalink;
                        _postTitle = blogPost.Title;
                    }
                }

                // if we still don't have it then display an error message
                if (_postLink == String.Empty)
                {
                    // saving the company a few dollars by not putting this one
                    // in DisplayMessages.xml, since it's already been translated
                    // in Strings.resx.
                    DisplayMessage message = new DisplayMessage(MessageId.None);
                    message.Title = string.Format(CultureInfo.CurrentCulture, Res.Get(StringId.MissingPostLinkCaption),
                                                  postInfo.IsPage ? Res.Get(StringId.Page) : Res.Get(StringId.Post));
                    message.Text = string.Format(CultureInfo.CurrentCulture, Res.Get(StringId.MissingPostLinkExplanation),
                                                 postInfo.IsPage ? Res.Get(StringId.PageLower) : Res.Get(StringId.PostLower),
                                                 ApplicationEnvironment.ProductNameQualified);
                    message.Type = MessageBoxIcon.Exclamation;
                    message.Buttons = MessageBoxButtons.OK;
                    message.Show(ea.OpenPostDialog);

                    // fail validation
                    ea.PostIsValid = false;
                }
            }
            else
            {
                _postLink = postInfo.Permalink;
                _postTitle = postInfo.Title;
            }
        }
Пример #3
0
        // see if there is anyone listening to the validate event (to veto the selection)
        private bool ValidateSelectedPost()
        {
            if (BlogPostInfo == null)
            {
                return(false);
            }

            // perform optional event based validation
            if (ValidatePost != null)
            {
                ValidatePostEventArgs ea = new ValidatePostEventArgs(this, BlogPostInfo);
                ValidatePost(this, ea);

                if (!ea.PostIsValid)
                {
                    return(false);
                }
            }

            // if we get through validation then return true
            return(true);
        }
Пример #4
0
        // see if there is anyone listening to the validate event (to veto the selection)
        private bool ValidateSelectedPost()
        {
            if (BlogPostInfo == null)
                return false;

            // perform optional event based validation
            if (ValidatePost != null)
            {
                ValidatePostEventArgs ea = new ValidatePostEventArgs(this, BlogPostInfo);
                ValidatePost(this, ea);

                if (!ea.PostIsValid)
                    return false;
            }

            // if we get through validation then return true
            return true;
        }