private bool InsertSimpleContentFromUrl(ContentSourceInfo contentSource, string url) { string title = String.Empty; string content = String.Empty; if (UrlContentRetreivalWithProgress.ExecuteSimpleContentRetreival( EditorContext.FrameWindow, contentSource, url, ref title, ref content)) { _contentSourceSite.InsertContent(content, false); return(true); } else { return(false); } }
private bool InsertSmartContentFromEmbed(string embed) { ContentSourceInfo contentSource = ContentSourceManager.FindContentSource(typeof(VideoContentSource)); if (contentSource != null) { SmartContentSource smartSource = contentSource.Instance as SmartContentSource; VideoContentSource videoSource = smartSource as VideoContentSource; IExtensionData extensionData = _contentSourceSite.CreateExtensionData(Guid.NewGuid().ToString()); ISmartContent smartContent = new SmartContent(extensionData); videoSource.CreateContentFromEmbed(embed, smartContent); // generate html and insert it string content = videoSource.GenerateEditorHtml(smartContent, _contentSourceSite); if (content != null) { _contentSourceSite.InsertContent(VideoContentSource.ID, content, extensionData); return(true); } else { Trace.Fail("Video Source content generated from embed tag was empty"); return(false); } } Trace.Fail("Cannot find the video plugin"); return(false); }
private bool InsertSimpleContentFromLiveClipboard(ContentSourceInfo contentSource, XmlDocument lcDocument) { ContentSource lcContentSource = contentSource.Instance as ContentSource; if (lcContentSource == null) { Trace.Fail("Unexpected failure to get live clipboard content-source!"); return(false); } // create the content string content = String.Empty; if (lcContentSource.CreateContentFromLiveClipboard(EditorContext.FrameWindow, lcDocument, ref content) == DialogResult.OK) { _contentSourceSite.InsertContent(content, false); return(true); } else { return(false); } }
public static void PerformInsertion(IContentSourceSite sourceSite, ContentSourceInfo contentSource) { // record use of content-source (used to list source in MRU order on the sidebar) RecordContentSourceUsage(contentSource.Id); try { if (contentSource.Instance is SmartContentSource) { SmartContentSource scSource = (SmartContentSource)contentSource.Instance; IExtensionData extensionData = sourceSite.CreateExtensionData(Guid.NewGuid().ToString()); // SmartContentSource implementations *must* be stateless (see WinLive 126969), so we wrap up the // internal smart content context and pass it in as a parameter to the CreateContent call. ISmartContent sContent; if (scSource is IInternalSmartContentSource) { sContent = new InternalSmartContent(extensionData, sourceSite as IInternalSmartContentContextSource, contentSource.Id); } else { sContent = new SmartContent(extensionData); } if (scSource.CreateContent(sourceSite.DialogOwner, sContent) == DialogResult.OK) { string content = scSource.GenerateEditorHtml(sContent, sourceSite); if (content != null) { sourceSite.InsertContent(contentSource.Id, content, extensionData); sourceSite.Focus(); if (ApplicationPerformance.ContainsEvent(MediaInsertForm.EventName)) ApplicationPerformance.EndEvent(MediaInsertForm.EventName); } } } else if (contentSource.Instance is ContentSource) { ContentSource sSource = (ContentSource)contentSource.Instance; string newContent = String.Empty; // default try { if (sourceSite.SelectedHtml != null) newContent = sourceSite.SelectedHtml; } catch { } // safely try to provide selected html if (sSource.CreateContent(sourceSite.DialogOwner, ref newContent) == DialogResult.OK) { sourceSite.InsertContent(newContent, contentSource.Id == WebImageContentSource.ID); sourceSite.Focus(); } } } catch (Exception ex) { DisplayContentRetreivalError(sourceSite.DialogOwner, ex, contentSource); } }