示例#1
0
        protected override bool DoInsertData(DataAction action, MarkupPointer begin, MarkupPointer end)
        {
            // get the live clipboard data
            LiveClipboardData lcData = DataMeister.LiveClipboardData;

            if (lcData == null)
            {
                Trace.Fail("Unexpected failure to get LC data!");
                return(false);
            }

            // lookup the content-source
            ContentSourceInfo contentSource =
                LiveClipboardManager.FindContentSourceForLiveClipboard(lcData.Formats);

            if (contentSource == null)
            {
                Trace.Fail("Unexpected failure to find content soure!");
                return(false);
            }

            using (new WaitCursor())
            {
                try
                {
                    // HACK: drive the selection textRange to the caret so we can call generic
                    // content-source routines that work off the current selection
                    // Note that we do the same thing below for Images so we can use the common
                    // InsertImages method -- we may want to bake this into core marshalling
                    // or add MarkupRange parameters to the image and content-source routines
                    EditorContext.MarkupServices.CreateMarkupRange(begin, end).ToTextRange().select();

                    if (contentSource.Instance is SmartContentSource)
                    {
                        return(InsertSmartContentFromLiveClipboard(contentSource, lcData.Document));
                    }
                    else if (contentSource.Instance is ContentSource)
                    {
                        return(InsertSimpleContentFromLiveClipboard(contentSource, lcData.Document));
                    }
                    else
                    {
                        Debug.Fail("Unexpected content source type: " + contentSource.GetType());
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    ContentSourceManager.DisplayContentRetreivalError(EditorContext.FrameWindow, ex, contentSource);
                    return(false);
                }
            }
        }
示例#2
0
 public static bool CanCreateFrom(DataObjectMeister data)
 {
     return(data.LiveClipboardData != null &&
            LiveClipboardManager.FindContentSourceForLiveClipboard(data.LiveClipboardData.Formats) != null);
 }