public LiveClipboardFormatHandler(LiveClipboardContentSourceAttribute lcAttribute, ContentSourceInfo contentSource)
        {
            ResourceManager resMan             = new ResourceManager(contentSource.GetType());
            string          resourceNamePrefix = "LiveClipboardContentSource." + lcAttribute.Name + ".";

            _format            = new LiveClipboardFormat(lcAttribute.ContentType, lcAttribute.Type);
            _formatName        = LoadResourcedString(resMan, resourceNamePrefix + "Name", lcAttribute.Name);
            _formatDescription = LoadResourcedString(resMan, resourceNamePrefix + "Description", lcAttribute.Description);
            _formatImagePath   = lcAttribute.ImagePath;
            _contentSource     = contentSource;
        }
Exemple #2
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);
                }
            }
        }
Exemple #3
0
        protected override bool DoInsertData(DataAction action, MarkupPointer begin, MarkupPointer end)
        {
            // lookup the content-source
            ContentSourceInfo contentSource = ContentSourceManager.FindContentSourceForUrl(Url);

            if (contentSource != null)
            {
                // 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();

                try
                {
                    if (contentSource.Instance is SmartContentSource)
                    {
                        return(InsertSmartContentFromUrl(contentSource, Url));
                    }
                    else if (contentSource.Instance is ContentSource)
                    {
                        return(InsertSimpleContentFromUrl(contentSource, Url));
                    }
                    else
                    {
                        Debug.Fail("Unexpected content source type: " + contentSource.GetType());
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    Trace.Fail("Unexpected exception inserting content: " + ex.ToString());
                    return(false);
                }
            }
            else
            {
                Debug.Fail("No content source found during marshalling!");
                return(false);
            }
        }