public ContentEditorProxy(ContentEditorFactory factory, IContentEditorSite contentEditorSite, IInternetSecurityManager internetSecurityManager, IHTMLDocument2 htmlDocument, HtmlInsertOptions options, int dlControlFlags, string color, string wpost) { string content = htmlDocument.body.innerHTML; htmlDocument.body.innerHTML = "{post-body}"; string wysiwygHTML = HTMLDocumentHelper.HTMLDocToString(htmlDocument); BlogPost documentToBeLoaded = null; IBlogPostEditingContext editingContext = null; if (string.IsNullOrEmpty(wpost) || !File.Exists(wpost)) { documentToBeLoaded = new BlogPost(); editingContext = new BlogPostEditingContext(ContentEditorAccountAdapter.AccountId, documentToBeLoaded); } else { PostEditorFile wpostxFile = PostEditorFile.GetExisting(new FileInfo(wpost)); editingContext = wpostxFile.Load(false); editingContext.BlogPost.Contents = ""; } if (!string.IsNullOrEmpty(content)) { delayedInsertOperations.Enqueue(new DelayedInsert(content, options)); } ContentEditorProxyCore(factory, contentEditorSite, internetSecurityManager, wysiwygHTML, null, editingContext, new ContentEditorTemplateStrategy(), dlControlFlags, color); }
public IContentEditor CreateEditorFromMoniker(IContentEditorSite contentEditorSite, IInternetSecurityManager internetSecurityManager, IMoniker moniker, uint codepage, HtmlInsertOptions options, string color, int dlControlFlags, string wpost) { codepage = EmailShim.GetCodepage(codepage); string name; string html = HTMLDocumentHelper.MonikerToString(moniker, codepage, out name); if (CultureHelper.IsRtlCodepage(codepage)) { EmailContentTarget target = GlobalEditorOptions.ContentTarget as EmailContentTarget; if (target != null) { target.EnableRtlMode(); } } if (string.IsNullOrEmpty(html)) { html = "<html><body></body></html>"; } html = EmailShim.GetContentHtml(name, html); // Create a IHtmlDocument2 from the html which will then be loaded into the editor IHTMLDocument2 htmlDocument; htmlDocument = HTMLDocumentHelper.StringToHTMLDoc(html, name); return(new ContentEditorProxy(this, contentEditorSite, internetSecurityManager, htmlDocument, options, dlControlFlags, color, wpost)); }
/// <summary> /// Initializes the IContentEditor. /// </summary> /// <param name="factory"></param> /// <param name="contentEditorSite"></param> /// <param name="internetSecurityManager"></param> /// <param name="wysiwygHTML"></param> /// <param name="previewHTML"></param> /// <param name="newEditingContext"></param> /// <param name="templateStrategy"></param> /// <param name="dlControlFlags"> /// For Mail, these flags should always include DLCTL_DLIMAGES | DLCTL_VIDEOS | DLCTL_BGSOUNDS so that local /// images, videos and sounds are loaded. To block external content, it should also include /// DLCTL_PRAGMA_NO_CACHE | DLCTL_FORCEOFFLINE | DLCTL_NO_CLIENTPULL so that external images are not loaded /// and are displayed as a red X instead. /// </param> /// <param name="color"></param> private void ContentEditorProxyCore(ContentEditorFactory factory, IContentEditorSite contentEditorSite, IInternetSecurityManager internetSecurityManager, string wysiwygHTML, string previewHTML, IBlogPostEditingContext newEditingContext, BlogPostHtmlEditorControl.TemplateStrategy templateStrategy, int dlControlFlags, string color) { try { Debug.Assert(contentEditorSite is IUIFramework, "IContentEditorSite must also implement IUIFramework"); Debug.Assert(contentEditorSite is IDropTarget, "IContentEditorSite must also implement IDropTarget"); ApplyInstalledCulture(); this.factory = factory; _wysiwygHTML = wysiwygHTML; _previewHTML = previewHTML; _contentEditorSite = contentEditorSite; IntPtr p = _contentEditorSite.GetWindowHandle(); WINDOWINFO info = new WINDOWINFO(); User32.GetWindowInfo(p, ref info); panel = new Panel(); panel.Top = 0; panel.Left = 0; panel.Width = Math.Max(info.rcWindow.Width, 200); panel.Height = Math.Max(info.rcWindow.Height, 200); panel.CreateControl(); User32.SetParent(panel.Handle, p); accountAdapter = new ContentEditorAccountAdapter(); mainFrame = new MainFrameWindowAdapter(p, panel, _contentEditorSite, accountAdapter.Id); context = newEditingContext; contentEditor = new ContentEditor(mainFrame, panel, mainFrame, internetSecurityManager, templateStrategy, dlControlFlags); // Prevents asserts contentEditor.DisableSpelling(); contentEditor.OnEditorAccountChanged(accountAdapter); contentEditor.DocumentComplete += new EventHandler(blogPostHtmlEditor_DocumentComplete); contentEditor.GotFocus += new EventHandler(contentEditor_GotFocus); contentEditor.LostFocus += new EventHandler(contentEditor_LostFocus); contentEditor.Initialize(context, accountAdapter, wysiwygHTML, previewHTML, false); if (!string.IsNullOrEmpty(color)) { contentEditor.IndentColor = color; } this.factory.GlobalSpellingOptionsChanged += GlobalSpellingOptionsChangedHandler; } catch (Exception ex) { // Something went wrong, make sure we don't reuse a cached editor HtmlEditorControl.DisposeCachedEditor(); Trace.Fail(ex.ToString()); Trace.Flush(); throw; } }
public MainFrameWindowAdapter(IntPtr parentWindowHandle, Control editorHostPanel, IContentEditorSite contentEditorSite, string accountId) { _parentWindowHandle = parentWindowHandle; _editorHostPanel = editorHostPanel; _contentEditorSite = contentEditorSite; editorHostPanel.LocationChanged += new EventHandler(editorHostPanel_LocationChanged); editorHostPanel.SizeChanged += new EventHandler(editorHostPanel_SizeChanged); editorHostPanel.Layout += new LayoutEventHandler(editorHostPanel_Layout); _accountId = accountId; }
public void Dispose() { contentEditor.DocumentComplete -= new EventHandler(blogPostHtmlEditor_DocumentComplete); contentEditor.GotFocus -= new EventHandler(contentEditor_GotFocus); contentEditor.LostFocus -= new EventHandler(contentEditor_LostFocus); contentEditor.Dispose(); panel.Dispose(); accountAdapter.Dispose(); mainFrame.Dispose(); Marshal.ReleaseComObject(_contentEditorSite); _contentEditorSite = null; accountAdapter = null; contentEditor = null; panel = null; context = null; }
public IContentEditor CreateEditorFromHtmlDocument(IContentEditorSite contentEditorSite, IInternetSecurityManager internetSecurityManager, IHTMLDocument2 htmlDocument, HtmlInsertOptions options, int dlControlFlags) { return new ContentEditorProxy(this, contentEditorSite, internetSecurityManager, htmlDocument, options, dlControlFlags, null, null); }
public IContentEditor CreateEditorFromDraft(IContentEditorSite contentEditorSite, IInternetSecurityManager internetSecurityManager, string wysiwygHtml, string pathToDraftFile, int dlControlFlags) { return new ContentEditorProxy(this, contentEditorSite, internetSecurityManager, wysiwygHtml, null, pathToDraftFile, dlControlFlags); }
/// <summary> /// Initializes the IContentEditor. /// </summary> /// <param name="factory"></param> /// <param name="contentEditorSite"></param> /// <param name="internetSecurityManager"></param> /// <param name="wysiwygHTML"></param> /// <param name="previewHTML"></param> /// <param name="newEditingContext"></param> /// <param name="templateStrategy"></param> /// <param name="dlControlFlags"> /// For Mail, these flags should always include DLCTL_DLIMAGES | DLCTL_VIDEOS | DLCTL_BGSOUNDS so that local /// images, videos and sounds are loaded. To block external content, it should also include /// DLCTL_PRAGMA_NO_CACHE | DLCTL_FORCEOFFLINE | DLCTL_NO_CLIENTPULL so that external images are not loaded /// and are displayed as a red X instead. /// </param> /// <param name="color"></param> private void ContentEditorProxyCore(ContentEditorFactory factory, IContentEditorSite contentEditorSite, IInternetSecurityManager internetSecurityManager, string wysiwygHTML, string previewHTML, IBlogPostEditingContext newEditingContext, BlogPostHtmlEditorControl.TemplateStrategy templateStrategy, int dlControlFlags, string color) { try { Debug.Assert(contentEditorSite is IUIFramework, "IContentEditorSite must also implement IUIFramework"); Debug.Assert(contentEditorSite is IDropTarget, "IContentEditorSite must also implement IDropTarget"); ApplyInstalledCulture(); this.factory = factory; _wysiwygHTML = wysiwygHTML; _previewHTML = previewHTML; _contentEditorSite = contentEditorSite; IntPtr p = _contentEditorSite.GetWindowHandle(); WINDOWINFO info = new WINDOWINFO(); User32.GetWindowInfo(p, ref info); panel = new Panel(); panel.Top = 0; panel.Left = 0; panel.Width = Math.Max(info.rcWindow.Width, 200); panel.Height = Math.Max(info.rcWindow.Height, 200); panel.CreateControl(); User32.SetParent(panel.Handle, p); accountAdapter = new ContentEditorAccountAdapter(); mainFrame = new MainFrameWindowAdapter(p, panel, _contentEditorSite, accountAdapter.Id); context = newEditingContext; contentEditor = new ContentEditor(mainFrame, panel, mainFrame, internetSecurityManager, templateStrategy, dlControlFlags); // Prevents asserts contentEditor.DisableSpelling(); contentEditor.OnEditorAccountChanged(accountAdapter); contentEditor.DocumentComplete += new EventHandler(blogPostHtmlEditor_DocumentComplete); contentEditor.GotFocus += new EventHandler(contentEditor_GotFocus); contentEditor.LostFocus += new EventHandler(contentEditor_LostFocus); contentEditor.Initialize(context, accountAdapter, wysiwygHTML, previewHTML, false); if (!string.IsNullOrEmpty(color)) { contentEditor.IndentColor = color; } } catch (Exception ex) { // Something went wrong, make sure we don't reuse a cached editor HtmlEditorControl.DisposeCachedEditor(); Trace.Fail(ex.ToString()); Trace.Flush(); throw; } }
public ContentEditorProxy(ContentEditorFactory factory, IContentEditorSite contentEditorSite, IInternetSecurityManager internetSecurityManager, IHTMLDocument2 htmlDocument, HtmlInsertOptions options, int dlControlFlags, string color, string wpost) { string content = htmlDocument.body.innerHTML; htmlDocument.body.innerHTML = "{post-body}"; string wysiwygHTML = HTMLDocumentHelper.HTMLDocToString(htmlDocument); BlogPost documentToBeLoaded = null; IBlogPostEditingContext editingContext = null; if (string.IsNullOrEmpty(wpost) || !File.Exists(wpost)) { documentToBeLoaded = new BlogPost(); editingContext = new BlogPostEditingContext(ContentEditorAccountAdapter.AccountId, documentToBeLoaded); } else { PostEditorFile wpostxFile = PostEditorFile.GetExisting(new FileInfo(wpost)); editingContext = wpostxFile.Load(false); editingContext.BlogPost.Contents = ""; } if (!string.IsNullOrEmpty(content)) delayedInsertOperations.Enqueue(new DelayedInsert(content, options)); ContentEditorProxyCore(factory, contentEditorSite, internetSecurityManager, wysiwygHTML, null, editingContext, new ContentEditorTemplateStrategy(), dlControlFlags, color); }
public IContentEditor CreateEditorFromMoniker(IContentEditorSite contentEditorSite, IInternetSecurityManager internetSecurityManager, IMoniker moniker, uint codepage, HtmlInsertOptions options, string color, int dlControlFlags, string wpost) { codepage = EmailShim.GetCodepage(codepage); string name; string html = HTMLDocumentHelper.MonikerToString(moniker, codepage, out name); if (CultureHelper.IsRtlCodepage(codepage)) { EmailContentTarget target = GlobalEditorOptions.ContentTarget as EmailContentTarget; if (target != null) { target.EnableRtlMode(); } } if (string.IsNullOrEmpty(html)) html = "<html><body></body></html>"; html = EmailShim.GetContentHtml(name, html); // Create a IHtmlDocument2 from the html which will then be loaded into the editor IHTMLDocument2 htmlDocument; htmlDocument = HTMLDocumentHelper.StringToHTMLDoc(html, name); return new ContentEditorProxy(this, contentEditorSite, internetSecurityManager, htmlDocument, options, dlControlFlags, color, wpost); }
public IContentEditor CreateEditorFromHtmlDocument(IContentEditorSite contentEditorSite, IInternetSecurityManager internetSecurityManager, IHTMLDocument2 htmlDocument, HtmlInsertOptions options, int dlControlFlags) { return(new ContentEditorProxy(this, contentEditorSite, internetSecurityManager, htmlDocument, options, dlControlFlags, null, null)); }
public IContentEditor CreateEditorFromDraft(IContentEditorSite contentEditorSite, IInternetSecurityManager internetSecurityManager, string wysiwygHtml, string pathToDraftFile, int dlControlFlags) { return(new ContentEditorProxy(this, contentEditorSite, internetSecurityManager, wysiwygHtml, null, pathToDraftFile, dlControlFlags)); }
public ContentEditorProxy(ContentEditorFactory factory, IContentEditorSite contentEditorSite, IInternetSecurityManager internetSecurityManager, string wysiwygHTML, string previewHTML, string pathToFile, int dlControlFlags) { ContentEditorProxyCore(factory, contentEditorSite, internetSecurityManager, wysiwygHTML, previewHTML, PostEditorFile.GetExisting(new FileInfo(pathToFile)).Load(false), new ContentEditorTemplateStrategy(), dlControlFlags, null); }
public ContentEditorProxy(ContentEditorFactory factory, IContentEditorSite contentEditorSite, IInternetSecurityManager internetSecurityManager, string wysiwygHTML, string previewHTML, int dlControlFlags) { ContentEditorProxyCore(factory, contentEditorSite, internetSecurityManager, wysiwygHTML, previewHTML, new BlogPostEditingContext(ContentEditorAccountAdapter.AccountId, new BlogPost()), new ContentEditorTemplateStrategy(), dlControlFlags, null); }
public void Dispose() { _contentEditorSite = null; }