예제 #1
0
        protected override void DoDragDrop(IHTMLEventObj pIEventObj)
        {
            IHTMLElement element = pIEventObj.srcElement;

            // Make sure the element is an image.
            IHTMLImgElement imgElement = element as IHTMLImgElement;

            if (imgElement == null)
            {
                return;
            }

            // We'll need to uniquely identify this image when its inserted at a new spot.
            string oldElementId = element.id;

            element.id = Guid.NewGuid().ToString();

            IDataObject dataObject = SmartContentDataObject.CreateFrom(element, EditorContext.EditorId);

            // do the drag and drop
            using (new Undo(EditorContext))
            {
                EditorContext.DoDragDrop(dataObject, DragDropEffects.Move);
            }

            // Revert back to the old id after drag/drop is done.
            element.id = oldElementId;
        }
예제 #2
0
        protected override void DoDragDrop(IHTMLEventObj pIEventObj)
        {
            SmartContentSelection smartSelection = EditorContext.Selection as SmartContentSelection;

            if (smartSelection == null)
            {
                return;
            }

            // allow each of the drop source format handlers a chance to create the
            // drop-source data object
            IDataObject dataObject = SmartContentDataObject.CreateFrom(smartSelection.HTMLElement, EditorContext.EditorId);

            // do the drag and drop
            using (new Undo(EditorContext))
            {
                EditorContext.DoDragDrop(dataObject, DragDropEffects.Move);
            }

            // If the user dragged into a restrcited area(like an edit field) the markup range is destroyed
            // when we strip out the html, so dont try to select it
            IHTMLElement e = smartSelection.HTMLElement;

            if (e.sourceIndex < 0 || e.document == null || ((IHTMLDocument2)e.document).body == null)
            {
                return;
            }

            //re-select the smartContent item now that the drag/dropis done
            SmartContentSelection.SelectIfSmartContentElement(EditorContext, smartSelection.HTMLElement, smartSelection.ContentState);

            // Update the area around the smart content for inline spelling
            MarkupRange range = EditorContext.MarkupServices.CreateMarkupRange(smartSelection.HTMLElement, true);

            EditorContext.DamageServices.AddDamage(range);
        }