public void ShowDialogWithDelay(IWin32Window owner, OpenLiveWriter.CoreServices.AsyncOperation asyncOperation, int delayMs) { // JJA: THIS TECHNIQUE DOES NOT WORK AND CAUSES ALL KINDS OF PROBLEMS! WE NEED A DIFFERENT // TECHNIQUE THAT DOES NOT STARVE THE UI THREAD. DO NOT UNDER ANY CONDITIONS RESTORE // THIS CODE!!!!!! /* // start out by polling the get post operation for completion for the delay interval using ( new WaitCursor() ) { const int SPLICE_MS = 100 ; int waitMs = 0 ; while( waitMs < delayMs ) { if ( asyncOperation.IsDone ) { return ; } else { Thread.Sleep(SPLICE_MS); waitMs += SPLICE_MS ; } } } */ // got past the delay interval, need to signup for events and show the dialog _asyncOperation = asyncOperation; if (_asyncOperation.IsDone) return; // show the dialog ShowDialog(owner); }
protected internal override void HandleResult(OpenLiveWriter.Extensibility.BlogClient.BlogPost blogPost, ITestResults results) { if (blogPost.Categories.Length == 2) results.AddResult("supportsMultipleCategories", YES); else results.AddResult("supportsMultipleCategories", NO); }
internal ExtendedHtmlEditorMashallingHandler(IHtmlMarshallingTarget editorContext, IContentSourceSite sourceSite, IHtmlEditorHost blogEditor, OpenLiveWriter.Interop.Com.IDropTarget unhandledDropTarget) : base(editorContext) { _insertionSite = sourceSite; _blogEditor = blogEditor; _unhandledDropTarget = unhandledDropTarget; }
protected internal override void PreparePost(Blog blog, IBlogClient blogClient, OpenLiveWriter.Extensibility.BlogClient.BlogPost blogPost, ref bool? publish) { BlogPostCategory[] categories = blogClient.GetCategories(blog.BlogId); if (categories.Length < 2) throw new InvalidOperationException("Blog " + blog.HomepageUrl + " does not have enough categories for the SupportsMultipleCategories test to be performed"); BlogPostCategory[] newCategories = new BlogPostCategory[2]; newCategories[0] = categories[0]; newCategories[1] = categories[1]; blogPost.Categories = newCategories; }
protected override void ConfigureClientOptions(OpenLiveWriter.BlogClient.Providers.BlogClientOptions clientOptions) { base.ConfigureClientOptions(clientOptions); clientOptions.SupportsCategories = true; clientOptions.SupportsMultipleCategories = true; clientOptions.SupportsNewCategories = true; clientOptions.SupportsCustomDate = true; clientOptions.SupportsExcerpt = true; clientOptions.SupportsSlug = true; clientOptions.SupportsFileUpload = true; }
/// <summary> /// Method that is delegated to by the presentation editor's implementation of /// IDocHostCustomUI.GetDropTarget. Replaces the default drop target implementation /// with our own. Note that the main purpose of this method for us is to get a reference /// to the MSHTML drop target implementaiton. While in this method we do in fact replace /// thier implementation with our own, this is probabaly redundant as we also disable /// their drop target (see below comment on Initialize). We replace their implementation /// in any case just so that if they have any internal state or behavior that depends /// upon knowing whether their drop target implementation is active then it can be /// set correctly. /// </summary> /// <param name="pDropTarget">default implementation</param> /// <param name="ppDropTarget">our implemetation</param> /// <returns>S_OK to indicate that we replaced implementation, otherwise E_NOTIMPL</returns> public int GetDropTarget(OpenLiveWriter.Interop.Com.IDropTarget pDropTarget, out OpenLiveWriter.Interop.Com.IDropTarget ppDropTarget) { // Note: Drop target can be null after the user clicks on an <option> element. // save a reference to the mshtml drop target mshtmlDropTargetImpl = pDropTarget; // replace the mshtml implementaiton with our own (will delegate as necessary) ppDropTarget = this; // indicate that we replaced the implementation return HRESULT.S_OK; }
internal RefreshableContentManager(BlogPostExtensionDataList extensionDataList, OpenLiveWriter.PostEditor.ContentEditor editor) { _missedCallbackExtensionData = new List<IExtensionData>(); _extensionDataList = extensionDataList; _editor = editor; _editor.UndoExecuted += new EventHandler(_editorContentsChanged); _editor.RedoExecuted += new EventHandler(_editorContentsChanged); _editor.PasteExecuted += new EventHandler(_editorContentsChanged); _editor.PasteSpecialExecuted += new EventHandler(_editorContentsChanged); _extensionDataList.RefreshableCallbackTriggered += _extensionDataList_RefreshableCallbackTriggered; _refreshableContentTimer = new Timer(); _refreshableContentTimer.Interval = INTERVAL_TICK; _refreshableContentTimer.Tick += refreshableContentTimer_Tick; }
public override void DoTest(BlogRunner.Core.Config.Blog blog, OpenLiveWriter.Extensibility.BlogClient.IBlogClient blogClient, ITestResults results) { BlogPost post = new BlogPost(); post.Contents = "foo"; post.Title = ""; string etag; XmlDocument remotePost; try { string newPostId = blogClient.NewPost(blog.BlogId, post, null, true, out etag, out remotePost); results.AddResult("supportsEmptyTitles", YES); if (CleanUpPosts) blogClient.DeletePost(blog.BlogId, newPostId, true); } catch { results.AddResult("supportsEmptyTitles", NO); } }
internal void Add(OpenLiveWriter.Mshtml.MarkupRange SelectedMarkupRange) { listBoxSelection.Items.Insert(0, new SelectionItem(SelectedMarkupRange)); }
internal static string ReferenceFixer(BeginTag tag, string reference, ISupportingFileService _fileService, OpenLiveWriter.PostEditor.ContentEditor editor) { // If it isnt a file url, then it wont be an image from supporting files. if (!UrlHelper.IsFile(reference)) return reference; Uri uri = new Uri(reference); BlogPostImageData imageData = BlogPostImageDataList.LookupImageDataByInlineUri(editor.ImageList, uri); if (imageData == null) { if (BlogPostImageDataList.LookupImageDataByLinkedUri(editor.ImageList, uri) != null) return null; return reference; } return imageData.ImageSourceFile.Uri.AbsoluteUri; }
public void DragOver(MK grfKeyState, POINT pt, ref OpenLiveWriter.Interop.Com.DROPEFFECT pdwEffect) { _contentEditorSite.DragOver(grfKeyState, pt, ref pdwEffect); }
private void DocumentEvents_Click(object o, OpenLiveWriter.Mshtml.HtmlEventArgs e) { //fix bug 306300 - if the editor is clicked in the body outside of the editor's main //editable regions, we may not receive a selection change event (even though the selection //will be changed to none), so we also update the sidebar state on click. if (!e.WasCancelled) UpdateSidebarState(); }
public int InvalidateUICommand(uint commandId, OpenLiveWriter.Interop.Com.Ribbon.CommandInvalidationFlags flags, IntPtr keyPtr) { return 0; }
public int Initialize(IntPtr frameWnd, OpenLiveWriter.Interop.Com.Ribbon.IUIApplication application) { return 0; }
public override int ShowContextMenu(int dwID, ref OpenLiveWriter.Interop.Windows.POINT ppt, object pcmdtReserved, object pdispReserved) { return HRESULT.S_OK; }
private static void screenCapture_HtmlDocumentAvailable(object sender, OpenLiveWriter.Api.HtmlDocumentAvailableEventArgs e) { IHTMLDocument3 document = (IHTMLDocument3)e.Document; IHTMLElement mapElement = document.getElementById("map"); if (mapElement == null || mapElement.getAttribute("loaded", 2) == System.DBNull.Value) e.DocumentReady = false; else e.DocumentReady = true; }
public int GetDropTarget(OpenLiveWriter.Interop.Com.IDropTarget pDropTarget, out OpenLiveWriter.Interop.Com.IDropTarget ppDropTarget) { // log access to method LOG("IDocHostUIHandler", "GetDropTarget"); return docHostUIHandler.GetDropTarget(pDropTarget, out ppDropTarget); }
public void DragOver(OpenLiveWriter.Interop.Windows.MK grfKeyState, OpenLiveWriter.Interop.Windows.POINT pt, ref OpenLiveWriter.Interop.Com.DROPEFFECT pdwEffect) { pdwEffect = DROPEFFECT.NONE; }
public int _mshtmlEditor_GetDropTarget(OpenLiveWriter.Interop.Com.IDropTarget pDropTarget, out OpenLiveWriter.Interop.Com.IDropTarget ppDropTarget) { try { return mshtmlEditorDragAndDropTarget.GetDropTarget(pDropTarget, out ppDropTarget); } catch (Exception e) { UnexpectedErrorMessage.Show(e); ppDropTarget = null; return HRESULT.E_NOTIMPL; } }
public void Drop(OpenLiveWriter.Interop.Com.IOleDataObject pDataObj, OpenLiveWriter.Interop.Windows.MK grfKeyState, OpenLiveWriter.Interop.Windows.POINT pt, ref OpenLiveWriter.Interop.Com.DROPEFFECT pdwEffect) { pdwEffect = DROPEFFECT.NONE; }
private void _editorControl_KeyDown(object o, OpenLiveWriter.Mshtml.HtmlEventArgs e) { switch ((Keys)e.htmlEvt.keyCode) { case Keys.Back: //Bug fix: The backspace key triggers an extra selection change event that causes word damage to be //inappropriately committed, so we use a flag to suppress the selection change event for //this case. suppressSelectionChangeForDelete = true; break; } wordRangeDamager.OnKeyDown(e); _commitStrategy.OnKeyDown(e); }
public EmlMessageHandler(DataObjectMeister dataObject, DataFormatHandlerContext handlerContext, OpenLiveWriter.Interop.Com.IDropTarget unhandledDropTarget) : base(dataObject, handlerContext, unhandledDropTarget) { }
/// <summary> /// Delegate to DragAndDropManager for GetDropTarget /// </summary> /// <param name="pDropTarget">default implementation</param> /// <param name="ppDropTarget">our implemetation</param> /// <returns>S_OK to indicate that we replaced implementation, otherwise E_NOTIMPL</returns> int IDocHostUIHandler2.GetDropTarget(OpenLiveWriter.Interop.Com.IDropTarget pDropTarget, out OpenLiveWriter.Interop.Com.IDropTarget ppDropTarget) { if (DropTargetHandler != null) { return DropTargetHandler(pDropTarget, out ppDropTarget); } else { ppDropTarget = null; return HRESULT.E_NOTIMPL; } }
public UnhandledDropTarget(DataObjectMeister dataObject, DataFormatHandlerContext handlerContext, OpenLiveWriter.Interop.Com.IDropTarget unhandledDropTarget) : base(dataObject, handlerContext) { _unhandledDropTarget = unhandledDropTarget; _oleDataObject = MshtmlEditorDragAndDropTarget.ExtractOleDataObject(DataMeister.IDataObject); }
public void Drop(OpenLiveWriter.Interop.Com.IOleDataObject pDataObj, MK grfKeyState, POINT pt, ref OpenLiveWriter.Interop.Com.DROPEFFECT pdwEffect) { _contentEditorSite.Drop(pDataObj, grfKeyState, pt, ref pdwEffect); }
/// <summary> /// Inserts a set of images into the current editor, optionally assigning each image an id. /// </summary> /// <param name="imagePaths">paths of the images to insert</param> internal static void InsertImagesCore(IBlogPostHtmlEditor currentEditor, ISupportingFileService fileService, IEditorAccount editorAccount, OpenLiveWriter.PostEditor.ContentEditor editor, string[] imagePaths) { using (OpenLiveWriter.PostEditor.ContentEditor.EditorUndoUnit undo = new OpenLiveWriter.PostEditor.ContentEditor.EditorUndoUnit(currentEditor)) { StringBuilder htmlBuilder = new StringBuilder(); //calculate the size for inserted images (based on the user's saved default for this blog) DefaultImageSettings defaultImageSettings = new DefaultImageSettings(editorAccount.Id, editor.DecoratorsManager); Size defaultImageSize = defaultImageSettings.GetDefaultInlineImageSize(); //Generate the default img HTML for the image paths. Initially, the images are linked to the source image //path so that the DOM version of the HTML can be loaded. Once the images are loaded into the DOM, we can apply //the image decorators to generate scaled images, borders, etc. ImagePropertiesInfo[] imageInfos = new ImagePropertiesInfo[imagePaths.Length]; // don't insert into the title currentEditor.FocusBody(); for (int i = 0; i < imageInfos.Length; i++) { string imagePath = imagePaths[i]; Uri imgUri; if (UrlHelper.IsUrl(imagePath)) imgUri = new Uri(imagePath); else imgUri = new Uri(UrlHelper.CreateUrlFromPath(imagePath)); Size imageSize = new Size(1, 1); if (imgUri.IsFile && File.Exists(imagePath)) { if (!File.Exists(imgUri.LocalPath)) Trace.Fail("Error inserting image - the image URL was corrupted: " + imagePath); else { try { //check the validity of the image file imageSize = ImageUtils.GetImageSize(imagePath); } catch (Exception) { Trace.WriteLine("There is a problem with the image file: " + imagePath); // Insert anyway, MSHTML will show a red X in place of the image. htmlBuilder.AppendFormat(CultureInfo.InvariantCulture, "<img src=\"{0}\" />", HtmlUtils.EscapeEntities(UrlHelper.SafeToAbsoluteUri(imgUri))); continue; } } } // If the image has an embedded thumbnail, we'll use it as a place holder for the <img src="..."> // until we generate an inline image and apply decorators. Stream embeddedThumbnailStream = ImageHelper2.GetEmbeddedThumbnailStream(imagePath); if (embeddedThumbnailStream != null) { // Save thumbnail to disk. ISupportingFile imageFileEmbeddedThumbnail = fileService.CreateSupportingFile(Path.GetFileName(imagePath), Guid.NewGuid().ToString(), embeddedThumbnailStream); imageSize = ImageUtils.GetScaledImageSize(defaultImageSize.Width, defaultImageSize.Height, imageSize); //insert the default image html String imageElementAttrs = String.Format(CultureInfo.InvariantCulture, " width=\"{0}\" height=\"{1}\"", imageSize.Width, imageSize.Height); htmlBuilder.AppendFormat(CultureInfo.InvariantCulture, "<img src=\"{0}\" srcDelay=\"{1}\" {2} />", HtmlUtils.EscapeEntities(UrlHelper.SafeToAbsoluteUri(imageFileEmbeddedThumbnail.FileUri)), HtmlUtils.EscapeEntities(imgUri.ToString()), imageElementAttrs); } else if (currentEditor is BlogPostHtmlEditorControl && (imagePaths.Length > DELAYED_IMAGE_THRESHOLD || imageSize.Width * imageSize.Height > 16777216/*4096 X 4096*/)) { // If we are using a delayed loading tactic then we insert using the srcdelay htmlBuilder.Append(MakeHtmlForImageSourceDelay(imgUri.ToString())); } else { imageSize = ImageUtils.GetScaledImageSize(defaultImageSize.Width, defaultImageSize.Height, imageSize); //insert the default image html String imageElementAttrs = imgUri.IsFile ? String.Format(CultureInfo.InvariantCulture, " width=\"{0}\" height=\"{1}\"", imageSize.Width, imageSize.Height) : String.Empty; htmlBuilder.AppendFormat(CultureInfo.InvariantCulture, "<img src=\"{0}\" {1} />", HtmlUtils.EscapeEntities(UrlHelper.SafeToAbsoluteUri(imgUri)), imageElementAttrs); } } //insert the HTML into the editor currentEditor.InsertHtml(htmlBuilder.ToString(), false); selectionChanged = false; BlogPostHtmlEditorControl blogPostEditor = currentEditor as BlogPostHtmlEditorControl; if (blogPostEditor != null) blogPostEditor.SelectionChanged += blogPostEditor_SelectionChanged; //now that the image HTML is inserted into the editor, apply the default settings to the new images. undo.Commit(); } }