/// <summary> /// Notify the user that an error has occurred. /// </summary> /// <param name="title">Error title (used as the error caption).</param> /// <param name="description">Error description (displayed within a scrolling /// text-box so can be longer and/or display diagnostic information).</param> public static void DisplayError(string title, string description) { LogError(String.Format(CultureInfo.CurrentCulture, "{0}: {1}", title, description)); DisplayableException displayableException = new DisplayableException(title, description); using (DisplayableExceptionDisplayForm form = new DisplayableExceptionDisplayForm(displayableException)) form.ShowDialog(Win32WindowImpl.ForegroundWin32Window); }
public static bool SafeDeleteLocalPost(FileInfo postFile) { try { PostEditorFile postEditorFile = PostEditorFile.GetExisting(postFile); if (postEditorFile != null) postEditorFile.Delete(); return true; } catch (Exception ex) { DisplayableException displayableException = new DisplayableException( StringId.ErrorOccurredDeletingDraft, StringId.ErrorOccurredDeletingDraftDetails, ex.Message); DisplayableExceptionDisplayForm.Show(Win32WindowImpl.ForegroundWin32Window, displayableException); return false; } }
public static bool SafeDeleteLocalPost(string blogId, string postId) { try { PostEditorFile post = PostEditorFile.FindPost(PostEditorFile.RecentPostsFolder, blogId, postId); if (post != null) { post.Delete(); } return true; } catch (Exception ex) { DisplayableException displayableException = new DisplayableException( StringId.ErrorOccurredDeletingDraft, StringId.ErrorOccurredDeletingDraftDetails, ex.Message); DisplayableExceptionDisplayForm.Show(Win32WindowImpl.ForegroundWin32Window, displayableException); return false; } }
private void buttonOptions_Click(object sender, System.EventArgs e) { ContentSourceInfo selectedContentSource = GetSelectedPlugin(); if (selectedContentSource != null) { if (selectedContentSource.WriterPluginHasEditableOptions) { try { selectedContentSource.Instance.EditOptions(FindForm()); } catch (NotImplementedException ex) { ContentSourceManager.DisplayContentRetreivalError(FindForm(), ex, selectedContentSource); } catch (Exception exception) { Trace.Fail(exception.ToString()); DisplayableException dex = new DisplayableException( Res.Get(StringId.UnexpectedErrorPluginTitle), string.Format(CultureInfo.CurrentCulture, Res.Get(StringId.UnexpectedErrorPluginDescription), selectedContentSource.Name, exception.Message)); DisplayableExceptionDisplayForm.Show(FindForm(), dex); } } } }
private bool DeletePostFile(PostEditorFile postFile) { try { // screen files which have already been deleted through other means if (!postFile.IsDeleted) postFile.Delete(); return true; } catch (Exception ex) { DisplayableException displayableException = new DisplayableException( StringId.ErrorOccurredDeletingDraft, StringId.ErrorOccurredDeletingDraftDetails, ex.Message); DisplayableExceptionDisplayForm.Show(_mainFrameWindow, displayableException); return false; } }
private static void DisplayPluginException(IWin32Window owner, ContentSourceInfo csi, Exception e) { Trace.Fail(e.ToString()); DisplayableException ex = new DisplayableException( Res.Get(StringId.UnexpectedErrorPluginTitle), string.Format(CultureInfo.CurrentCulture, Res.Get(StringId.UnexpectedErrorPluginDescription), csi.Name, e.Message)); DisplayableExceptionDisplayForm.Show(owner, ex); }
private void UpdateHtmlForPreview(ref string html) { foreach (ContentSourceInfo csi in ContentSourceManager.GetActiveHeaderFooterPlugins(_mainFrameWindow, _currentEditorAccount.Id)) { ISmartContent smartContent = GetSmartContentForPublishHook(csi); // TODO: Check for unbalanced HTML HeaderFooterSource plugin = (HeaderFooterSource)csi.Instance; HeaderFooterSource.Position position; string generatedHtml; try { generatedHtml = plugin.GeneratePreviewHtml(smartContent, this, out position); } catch (Exception e) { Trace.Fail(e.ToString()); DisplayableException ex = new DisplayableException( Res.Get(StringId.UnexpectedErrorPluginTitle), string.Format(CultureInfo.CurrentCulture, Res.Get(StringId.UnexpectedErrorPluginDescription), csi.Name, e.Message)); DisplayableExceptionDisplayForm.Show(_mainFrameWindow, ex); continue; } if (string.IsNullOrEmpty(generatedHtml)) continue; if (SmartContentInsertionHelper.ContainsUnbalancedDivs(generatedHtml)) { Trace.Fail("Unbalanced divs detected in HTML generated by " + csi.Name + ": " + html); DisplayMessage.Show(MessageId.MalformedHtmlIgnored, _mainFrameWindow, csi.Name); continue; } // Don't use float alignment for footers--it causes them to float around // stuff that isn't part of the post bool noFloat = position == HeaderFooterSource.Position.Footer; generatedHtml = SmartContentInsertionHelper.GenerateBlock(ContentSourceManager.HEADERS_FOOTERS, null, smartContent, false, generatedHtml, noFloat, null); if (position == HeaderFooterSource.Position.Header) html = generatedHtml + html; else if (position == HeaderFooterSource.Position.Footer) html = html + generatedHtml; else Debug.Fail("Unknown position: " + position); } }