コード例 #1
0
        private bool IsValid()
        {
            if (listBoxOptions.SelectedIndex == -1)
            {
                DisplayMessage.Show(MessageId.TagSelectProvider);
                return(false);
            }

            return(true);
        }
コード例 #2
0
 public bool ValidateSelection()
 {
     if (!UrlHelper.IsUrl(UrlHelper.FixUpUrl(_webImageUrl.Text)))
     {
         DisplayMessage.Show(MessageId.InvalidWebImage);
         _webImageUrl.Focus();
         return(false);
     }
     return(true);
 }
コード例 #3
0
        private void buttonRestoreDefaults_Click(object sender, EventArgs e)
        {
            DialogResult result = DisplayMessage.Show(MessageId.TagConfirmRestoreProviders);

            if (result == DialogResult.Yes)
            {
                _manager.RestoreDefaults();
            }
            RefreshProviders(true);
        }
コード例 #4
0
 public void ShowLastError(IWin32Window owner)
 {
     if (ErrorOccurred)
     {
         DisplayMessage.Show(_errorMessageType, owner, _errorMessageParams);
     }
     else
     {
         Trace.Fail("Called ShowLastError when no error occurred");
     }
 }
        public override bool ValidatePanel()
        {
            if (WeblogName == String.Empty)
            {
                DisplayMessage.Show(MessageId.RequiredFieldOmitted, FindForm(), Res.Get(StringId.CWConfirmWeblogName));
                textBoxWeblogName.Focus();
                return(false);
            }

            return(true);
        }
コード例 #6
0
 private void buttonInsert_Click(object sender, EventArgs e)
 {
     if (!UrlHelper.IsUrl(_source.SourceImageLink))
     {
         if (DisplayMessage.Show(MessageId.InputIsNotUrl, this, _source.SourceImageLink) == System.Windows.Forms.DialogResult.No)
         {
             return;
         }
     }
     DialogResult = System.Windows.Forms.DialogResult.OK;
 }
コード例 #7
0
 private void handleLocationSearch()
 {
     if (Address.Trim() != String.Empty)
     {
         mapControl.LoadMap(Address);
     }
     else
     {
         DisplayMessage.Show(MessageId.NoMapAddressSpecified, this);
     }
 }
コード例 #8
0
        internal static bool ValidateLiveLocalConnection(bool showUI)
        {
            bool connected = PluginHttpRequest.InternetConnectionAvailable;

            if (!connected && showUI)
            {
                DisplayMessage.Show(MessageId.MapsNoInternetConnection);
            }

            return(connected);
        }
コード例 #9
0
        private static AutoRecoverPromptResult AutoRecoverPrompt(IWin32Window window, int count)
        {
            const int ID_RECOVER  = 100,
                      ID_DISCARD  = 101,
                      ID_ASKLATER = 2; // same as ID_CANCEL

            while (true)
            {
                TaskDialog td = new TaskDialog();

                td.WindowTitle     = ApplicationEnvironment.ProductNameQualified;
                td.MainInstruction = string.Format(CultureInfo.CurrentCulture,
                                                   Res.Get(StringId.AutoRecoverDialogInstruction),
                                                   ApplicationEnvironment.ProductNameQualified);
                td.Content = string.Format(CultureInfo.CurrentCulture,
                                           Res.Get(StringId.AutoRecoverDialogContent),
                                           ApplicationEnvironment.ProductNameQualified);
                //            td.MainIcon = TaskDialogIcon.Warning;

                td.AllowDialogCancellation = true;

                td.UseCommandLinks = true;
                td.Buttons.Add(new TaskDialogButton(ID_RECOVER, Res.Get(StringId.AutoRecoverDialogButtonRecover)));
                td.Buttons.Add(new TaskDialogButton(ID_DISCARD, Res.Get(StringId.AutoRecoverDialogButtonDiscard)));
                td.Buttons.Add(new TaskDialogButton(ID_ASKLATER, Res.Get(StringId.AutoRecoverDialogButtonAskLater)));

                int  result, radioResult;
                bool flag;
                td.Show(window, out result, out radioResult, out flag);
                switch (result)
                {
                case ID_RECOVER:
                    return(AutoRecoverPromptResult.Recover);

                case ID_DISCARD:
                    // WinLive 225110 - Pass ActiveWin32Window here as owner instead of default ForegroundWin32Window
                    // ForegroundWin32Window could return a window of an app that is in admin mode and if we are running
                    // non-admin then trying to use that as parent for MessageBox would cause it to return 'No' without showing
                    // the dialog.
                    if (DialogResult.Yes == DisplayMessage.Show(MessageId.AutoRecoverPromptDiscardConfirm, Win32WindowImpl.ActiveWin32Window))
                    {
                        return(AutoRecoverPromptResult.Discard);
                    }
                    continue;

                case ID_ASKLATER:
                    return(AutoRecoverPromptResult.AskLater);

                default:
                    Debug.Fail("Unknown ID " + result);
                    return(AutoRecoverPromptResult.AskLater);
                }
            }
        }
コード例 #10
0
ファイル: DisplayMessageManager.cs プロジェクト: bradur/LD37
    void DisplayMessage(string message)
    {
        DisplayMessage displayMessage = Instantiate(displayMessagePrefab);

        displayMessage.Init(message, displayMessageContainer, messageFadeTime);
        messageList.Add(displayMessage);
        for (int i = messageList.Count - 1; i >= 0; i--)
        {
            messageList[i].MoveUp();
        }
        displayMessage.Show();
    }
コード例 #11
0
        /// <summary>
        /// Launches a window requested by another instance of OpenLiveWriter.exe.
        /// </summary>
        private static bool LaunchAdditionalInstance(string[] args)
        {
            // This process received a request from another process before
            // initialization was complete; this request should be considered
            // a failure, and the other process should try again
            if (!initComplete)
            {
                return(false);
            }

            // Do this only after initComplete is true, otherwise currentUICulture could be null.
            CultureHelper.ApplyUICulture(currentUICulture.Name);

            try
            {
                // TODO:OLW
                // using (Setup Setup = new Setup())
                {
                    try
                    {
                        // TODO:OLW
                        // Set native code's preferred language list
                        // Setup.SetThreadUILanguages();

                        ApplicationLauncher.LaunchBloggingForm(args, null, false);
                        return(true);
                    }
                    catch (ManualKeepaliveOperationException)
                    {
                        return(false);
                    }
                    catch (Exception e)
                    {
                        Trace.Fail(e.ToString());
                        return(true);
                    }
                    finally
                    {
                        // TODO:OLW
                        // Setup.ClearThreadUILanguages();
                    }
                }
            }
            catch (Exception)
            {
                // Most likely we failed to create WLSetupClass, installation corrupt or incomplete
                // Redirect user to repair/reinstall.
                DisplayMessage.Show(MessageId.WriterCannotStart);
            }

            return(true);
        }
コード例 #12
0
 private void buttonInsert_Click(object sender, EventArgs e)
 {
     if (!UrlHelper.IsUrl(_source.SourceImageLink))
     {
         //Ask if they want to go back and correct the link or just abort it altogether
         if (DisplayMessage.Show(MessageId.InputIsNotUrl, this, _source.SourceImageLink) == System.Windows.Forms.DialogResult.Yes)
         {
             _source.TabSelected();
             return;
         }
     }
     DialogResult = System.Windows.Forms.DialogResult.OK;
 }
コード例 #13
0
        public override bool PrepareSave(SwitchToPanel switchToPanel)
        {
            // validate that we have a post api url
            if (WeblogName == String.Empty)
            {
                switchToPanel();
                DisplayMessage.Show(MessageId.RequiredFieldOmitted, FindForm(), TextHelper.StripAmpersands(Res.Get(StringId.WeblogName)));
                textBoxWeblogName.Focus();
                return(false);
            }

            return(true);
        }
        public override bool ValidatePanel()
        {
            // validate we have select a provider
            if (comboBoxSelectProvider.SelectedItem == BlogProviderDescriptionProxy.SelectProvider)
            {
                DisplayMessage.Show(MessageId.RequiredFieldOmitted, FindForm(), Res.Get(StringId.CWSelectProviderWeblogProvider));
                comboBoxSelectProvider.Focus();
                return(false);
            }
            // validate that we have a post api url
            else if (textBoxServerApiUrl.Text.Trim() == String.Empty)
            {
                DisplayMessage.Show(MessageId.RequiredFieldOmitted, FindForm(), Res.Get(StringId.CWSelectProviderApiUrl));
                textBoxServerApiUrl.Focus();
                return(false);
            }
            else if (!ValidateNoParameters(textBoxServerApiUrl))
            {
                return(false);
            }
            else
            {
                using (new WaitCursor())
                {
                    IBlogProviderDescription provider            = SelectedBlogProvider;
                    BlogAccountDetector      blogAccountDetector = new BlogAccountDetector(
                        provider.ClientType, provider.PostApiUrl, new BlogCredentialsAccessor(_accountId, _credentials));

                    if (blogAccountDetector.ValidateService())
                    {
                        BlogInfo blogInfo = blogAccountDetector.DetectAccount(_homepageUrl, null);
                        if (blogInfo != null)
                        {
                            _targetBlog = blogInfo;
                        }
                        _usersBlogs = blogAccountDetector.UsersBlogs;
                        return(true);
                    }
                    else
                    {
                        if (blogAccountDetector.ErrorMessageType != MessageId.None)
                        {
                            DisplayMessage.Show(blogAccountDetector.ErrorMessageType, FindForm(), blogAccountDetector.ErrorMessageParams);
                        }
                        textBoxServerApiUrl.Focus();
                        return(false);
                    }
                }
            }
        }
コード例 #15
0
 private static bool VerifyPostEditorFileIsEditable(string fileName)
 {
     // determine if the file is read-only (we don't support read-only b/c
     // we need to save the file before publishing it)
     if ((File.GetAttributes(fileName) & FileAttributes.ReadOnly) > 0)
     {
         DisplayMessage.Show(MessageId.ReadOnlyPostFile, Path.GetFileNameWithoutExtension(fileName));
         return(false);
     }
     else
     {
         return(true);
     }
 }
コード例 #16
0
        private bool ValidateTextBoxPositiveInteger(string name, TextBox textBox)
        {
            string textBoxValue = textBox.Text.Trim();

            if (textBoxValue == String.Empty || int.Parse(textBoxValue, CultureInfo.CurrentCulture) <= 0)
            {
                DisplayMessage.Show(MessageId.InvalidNumberPositiveOnly, this, name);
                textBox.Focus();
                return(false);
            }
            else
            {
                return(true);
            }
        }
コード例 #17
0
        private bool ValidateTextBoxGreaterThanZero(string name, TextBox textBox)
        {
            string textBoxValue = textBox.Text.Trim();

            if (textBoxValue == String.Empty || int.Parse(textBoxValue, CultureInfo.CurrentCulture) < 0)
            {
                DisplayMessage.Show(MessageId.InvalidNumberNonNegative, this, name);
                textBox.Focus();
                return(false);
            }
            else
            {
                return(true);
            }
        }
コード例 #18
0
        public bool DeletePost(string postId, bool isPage)
        {
            bool deletedRemotePost = PostDeleteHelper.SafeDeleteRemotePost(_blogId, postId, isPage);

            if (!deletedRemotePost)
            {
                DialogResult result = DisplayMessage.Show(MessageId.LocalDeleteConfirmation, isPage ? Res.Get(StringId.PageLower) : Res.Get(StringId.PostLower));
                if (result == DialogResult.No)
                {
                    return(false);
                }
            }

            return(PostDeleteHelper.SafeDeleteLocalPost(_blogId, postId));
        }
コード例 #19
0
 private void DeletePost(BlogPost post, IProgressHost progress)
 {
     try
     {
         progress.UpdateProgress(Res.Get(StringId.ProgressFinalizingEditingTemplateConfig));
         _blogClient.DeletePost(_blogAccount.BlogId, post.Id, true);
         progress.UpdateProgress(100, 100);
     }
     catch (Exception ex)
     {
         Trace.Fail("Unexpected exception occurred while deleting temporary post: " + ex.ToString());
         //show a message that user needs to delete their post
         DisplayMessage.Show(MessageId.TempPostDeleteFailed);
     }
 }
コード例 #20
0
        public override bool PrepareSave(SwitchToPanel switchToPanel)
        {
            if (FileUploadSupport == FileUploadSupport.FTP)
            {
                FtpUploaderSettings ftpUploaderSettings = new FtpUploaderSettings(TemporaryBlogSettings.FileUploadSettings);
                if (ftpUploaderSettings.FtpServer == String.Empty)
                {
                    switchToPanel();
                    DisplayMessage.Show(MessageId.FtpSettingsRequired, FindForm());
                    buttonConfigureFtp.Focus();
                    return(false);
                }
            }

            return(true);
        }
コード例 #21
0
        private void DeleteProvider()
        {
            if (!IsValid())
            {
                return;
            }

            TagProvider  provider = (TagProvider)listBoxOptions.SelectedItem;
            DialogResult result   = DisplayMessage.Show(MessageId.TagConfirmDeleteProvider, provider.Name);

            if (result == DialogResult.Yes)
            {
                _manager.Delete(provider);
                RefreshProviders(true);
            }
        }
コード例 #22
0
        protected override void OnValidating(CancelEventArgs e)
        {
            if (string.IsNullOrEmpty(textBoxWidth.Text) || string.IsNullOrEmpty(textBoxHeight.Text))
            {
                if (string.IsNullOrEmpty(textBoxWidth.Text))
                {
                    textBoxWidth.Select();
                }
                else
                {
                    textBoxHeight.Select();
                }

                DisplayMessage.Show(MessageId.WidthHeightRequired, this);
                e.Cancel = true;
            }
        }
        private bool ValidateNoParameters(TextBox textBoxEntry)
        {
            // pick out the <param> values in the server url string
            string parameters = BlogProviderParameters.ExtractParameterList(textBoxEntry.Text.Trim());

            // if there are values then tell the user they must fill them in
            if (parameters.Length > 0)
            {
                DisplayMessage.Show(MessageId.ServerParameterNotSpecified, textBoxEntry.FindForm(), parameters.ToString());
                textBoxEntry.Focus();
                return(false);
            }
            else
            {
                return(true);
            }
        }
コード例 #24
0
        public override bool PrepareSave(SwitchToPanel switchToPanel)
        {
            string urls = txtUrls.Text;

            if (urls.Trim().Length == 0 && chkPing.Checked)
            {
                switchToPanel();
                txtUrls.Focus();
                DisplayMessage.Show(MessageId.PingUrlRequired);
                return(false);
            }

            int insertedCharacters = 0;

            for (Match m = Regex.Match(urls, "([^\r\n]+)"); m.Success; m = m.NextMatch())
            {
                string url = m.Value.Trim();
                if (url.Length == 0)
                {
                    continue;
                }
                if (!UrlHelper.IsUrl(url))
                {
                    int realIndex = m.Index + insertedCharacters;

                    const string DEFAULT_SCHEME = "http://";

                    if (UrlHelper.IsUrl(DEFAULT_SCHEME + url))
                    {
                        txtUrls.Text        = txtUrls.Text.Substring(0, realIndex) + DEFAULT_SCHEME + txtUrls.Text.Substring(realIndex);
                        insertedCharacters += DEFAULT_SCHEME.Length;
                    }
                    else
                    {
                        switchToPanel();
                        txtUrls.Select(realIndex, m.Length);
                        txtUrls.Focus();
                        txtUrls.HideSelection = false;
                        DisplayMessage.Show(MessageId.InvalidPingUrl);
                        txtUrls.HideSelection = true;
                        return(false);
                    }
                }
            }
            return(true);
        }
コード例 #25
0
        bool IBlogPostEditor.ValidatePublish()
        {
            // see if we need to halt publishing to specify a category
            if (Visible)
            {
                if (PostEditorSettings.CategoryReminder && (CategoryContext.Categories.Length > 0) && (CategoryContext.SelectedCategories.Length == 0))
                {
                    if (DisplayMessage.Show(typeof(CategoryReminderDisplayMessage), FindForm(), "\r\n\r\n") == DialogResult.No)
                    {
                        Focus();
                        return(false);
                    }
                }
            }

            // proceed
            return(true);
        }
コード例 #26
0
        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;
            }
        }
コード例 #27
0
ファイル: Blog.cs プロジェクト: chonghua/OpenLiveWriter-zh-CN
        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);
        }
コード例 #28
0
        public static BlogEditingTemplateFile[] DetectTemplate(IBlogClientUIContext uiContext, Control parentControl, IBlogSettingsAccessor blogSettings, bool probeForManifest, out Color?postBodyBackgroundColor)
        {
            postBodyBackgroundColor = null;

            try
            {
                // create a new detector
                BlogEditingTemplateDetector detector = new BlogEditingTemplateDetector(uiContext, parentControl, blogSettings, probeForManifest);

                // execute with a progress dialog
                ProgressHelper.ExecuteWithProgress(
                    Res.Get(StringId.DownloadingWeblogStyle),
                    new ProgressOperation(detector.DetectTemplate),
                    uiContext,
                    uiContext);

                // propagate exception
                if (detector.ExceptionOccurred)
                {
                    throw detector.Exception;
                }

                postBodyBackgroundColor = detector.PostBodyBackgroundColor;
                // return the template
                return(detector.BlogTemplateFiles);
            }
            catch (OperationCancelledException)
            {
                return(new BlogEditingTemplateFile[0]);
            }
            catch (BlogClientOperationCancelledException)
            {
                Debug.WriteLine("BlogClient operation cancelled");
                return(new BlogEditingTemplateFile[0]);
            }
            catch (Exception e)
            {
                Trace.Fail("Error occurred while downloading weblog style" + e.ToString());
                DisplayMessage.Show(MessageId.TemplateDownloadFailed);
                return(new BlogEditingTemplateFile[0]);
            }
        }
コード例 #29
0
 public GlossaryLinkItem EditEntry(Form parent, string text)
 {
     //shows form to edit existing entry
     using (AddLinkDialog editForm = new AddLinkDialog(_entries.Keys))
     {
         editForm.Edit = true;
         GlossaryLinkItem editItem = (GlossaryLinkItem)_entries[text];
         editForm.LinkText        = editItem.Text;
         editForm.Url             = editItem.Url;
         editForm.Title           = editItem.Title;
         editForm.OpenInNewWindow = editItem.OpenInNewWindow;
         editForm.Rel             = editItem.Rel;
         if (DialogResult.OK == editForm.ShowDialog(parent))
         {
             //if the link text was changed, make sure to delete the original entry
             if (!editItem.Text.Equals(editForm.LinkText, StringComparison.CurrentCultureIgnoreCase))
             {
                 if (_entries.ContainsKey(editForm.LinkText))
                 {
                     if (DisplayMessage.Show(MessageId.ConfirmReplaceEntry) == DialogResult.Yes)
                     {
                         RemoveEntry(text);
                     }
                     else
                     {
                         return(null);
                     }
                 }
                 lock (_lock)
                 {
                     DeleteEntry(editItem.Text);
                     return(AddEntry(editForm.LinkText, editForm.Url, editForm.Title, editForm.Rel, editForm.OpenInNewWindow));
                 }
             }
             else
             {
                 return(AddEntry(editForm.LinkText, editForm.Url, editForm.Title, editForm.Rel, editForm.OpenInNewWindow));
             }
         }
     }
     return(null);
 }
コード例 #30
0
 void IHtmlEditorCommandSource.InsertLink()
 {
     using (new WaitCursor())
     {
         if (!_canInsertHyperlink)
         {
             DisplayMessage.Show(MessageId.TitleNotLinkable);
             return;
         }
         using (HyperlinkForm hyperlinkForm = new HyperlinkForm(CommandManager, ShowAllLinkOptions))
         {
             hyperlinkForm.LinkText  = _textBox.SelectedText;
             hyperlinkForm.EditStyle = false;
             if (hyperlinkForm.ShowDialog(Owner) == DialogResult.OK)
             {
                 InsertLink(hyperlinkForm.Hyperlink, hyperlinkForm.LinkText, hyperlinkForm.LinkTitle, hyperlinkForm.Rel, hyperlinkForm.NewWindow);
             }
         }
     }
 }