private void lstDisplayMessages_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     DisplayMessage displayMessage = new DisplayMessage(MessageId);
     string title = displayMessage.Title;
     string text = displayMessage.Text;
     txtCaption.Text = title;
     txtMessage.Text = text;
 }
        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;
            }
        }
 public WebPublishMessage(MessageId messageId, params object[] textFormatArgs)
 {
     _displayMessage = new DisplayMessage(messageId);
     _textFormatArgs = textFormatArgs;
 }
Пример #4
0
        public void DisplayException(IWin32Window owner, Exception ex)
        {
            // display a custom display message for exceptions that have one
            // registered, otherwise display the generic error form
            if (ex is BlogClientProviderException)
            {
                IBlogProvider provider = BlogProviderManager.FindProvider(_settings.ProviderId);
                if (provider != null)
                {
                    BlogClientProviderException pe = ex as BlogClientProviderException;
                    MessageId messageId = provider.DisplayMessageForProviderError(pe.ErrorCode, pe.ErrorString);
                    if (messageId != MessageId.None)
                    {
                        DisplayMessage.Show(messageId, owner);
                        return;
                    }
                }
            }
            else if (ex is WebException)
            {
                WebException we = (WebException)ex;
                HttpWebResponse resp = we.Response as HttpWebResponse;
                if (resp != null)
                {
                    string friendlyError = HttpRequestHelper.GetFriendlyErrorMessage(we);
                    Trace.WriteLine("Server response body:\r\n" + friendlyError);
                    ex = new BlogClientHttpErrorException(
                        UrlHelper.SafeToAbsoluteUri(resp.ResponseUri),
                        friendlyError,
                        we);
                }
                else
                {
                    DisplayMessage msg = new DisplayMessage(MessageId.ErrorConnecting);
                    ex = new BlogClientException(msg.Title, msg.Text);
                }
                HttpRequestHelper.LogException(we);
            }

            // no custom message, use default UI
            DisplayableExceptionDisplayForm.Show(owner, ex);
        }
Пример #5
0
        /// <summary>
        /// Shows the DisplayMessage of the specified type.
        /// </summary>
        /// <param name="type">The DisplayMessage type.</param>
        /// <param name="args">Optional format arguments.</param>
        /// <returns>The DialogResult.</returns>
        public static DialogResult Show(MessageId messageId, IWin32Window owner, params object[] args)
        {
            if (messageId == MessageId.None)
            {
                Trace.Fail("MessageId.None passed to DisplayMessage.Show");
                return DialogResult.None;
            }

            DisplayMessage message = new DisplayMessage(messageId);

            return message.Show(owner, args);
        }
        public override bool ValidateSelection()
        {
            string title = txtTitle.Text.Trim();
            txtTags.Text = _currentPublisher.FormatTags(txtTags.Text);
            string tags = txtTags.Text;
            string description = txtDescription.Text.Trim();
            string filePath = txtFile.Text.Trim();

            // Make sure they filled in all the feilds
            if (((CategoryItem)comboBoxCategory.SelectedItem).CategoryId == Guid.Empty.ToString() ||
                title == String.Empty ||
                description == String.Empty ||
                tags == String.Empty ||
                filePath == String.Empty)
            {
                DisplayMessage.Show(MessageId.VideoRequiredFields, ParentForm, ApplicationEnvironment.ProductNameQualified);
                return false;
            }

            // Make sure they agreed to the terms of use
            if (!cbAcceptTerms.Checked)
            {
                DisplayMessage.Show(MessageId.MustAcceptTermsOfUse, ParentForm, ApplicationEnvironment.ProductNameQualified);
                return false;
            }

            // Make sure they are logged in
            if (!_currentPublisher.Auth.IsLoggedIn)
            {
                if (_currentPublisher.Auth.Login(true, FindForm()))
                {
                    videoLoginStatusControl.UpdateStatus();
                }
                else
                {
                    return false;
                }
            }

            if (!PathHelper.IsPathVideo(filePath))
            {
                DisplayMessage.Show(MessageId.VideoPathInvalid, ParentForm, ApplicationEnvironment.ProductNameQualified);
                return false;
            }

            try
            {
                // Try to make a video
                _video = _currentPublisher.GetVideo(title, description, tags, ((CategoryItem)comboBoxCategory.SelectedItem).CategoryId, ((CategoryItem)comboBoxCategory.SelectedItem).CategoryName, ((SecurityItem)comboBoxPermissions.SelectedItem).SecurityId, ((SecurityItem)comboBoxPermissions.SelectedItem).SecurityName);

                if (_video == null)
                    return false;

            }
            catch (WebException ex)
            {
                Trace.WriteLine("Failed to start video publish: " + ex);
                DisplayMessage message = new DisplayMessage(Res.Get(StringId.VideoNetworkError), Res.Get(StringId.VideoError));
                message.Show(ParentForm, ApplicationEnvironment.ProductNameQualified);
                return false;
            }
            catch (VideoPublishException ex)
            {
                DisplayMessage message = new DisplayMessage(ex.Message, Res.Get(StringId.VideoError));
                message.Show(ParentForm, ApplicationEnvironment.ProductNameQualified);
                return false;
            }

            // Save the name of the user that published the video, we will need
            // this later when we open a post with an unpublished video
            _video.Username = _currentPublisher.Auth.Username;

            return true;
        }