コード例 #1
0
        public static void InsertEditorHtmlIntoElement(IContentSourceSidebarContext contentSourceContext, SmartContentSource source, ISmartContent sContent, IHTMLElement element)
        {
            string content = source.GenerateEditorHtml(sContent, contentSourceContext);

            // If the plugin returned null has the HTML it would like to insert, remove the element from the editor
            if (content == null)
                HTMLElementHelper.RemoveElement(element);
            else
                InsertContentIntoElement(content, sContent, contentSourceContext, element);
        }
コード例 #2
0
        public EditableSmartContent(IContentSourceSidebarContext context, SmartContentSource contentSource, IHTMLElement smartContentElement)
        {
            GC.SuppressFinalize(this);
            _contentSourceContext = context;
            _contentSource = contentSource;
            _smartContentElement = smartContentElement;

            ContentSourceManager.ParseContainingElementId(_smartContentElement.id, out _contentSourceId, out _smartContentId);

            _smartContent = _contentSourceContext.FindSmartContent(_smartContentId);
            _extensionData = _contentSourceContext.FindExtentsionData(_smartContentId);

            _properties = new EditableRootProperties();
            _layout = new EditableLayoutStyle();
            _supportingFiles = new EditableSupportingFiles();
            MakeSmartContentEditable();
        }
コード例 #3
0
        internal static void PlainTextTransform(IPublishingContext site, SmartContentSource source, ISmartContent sContent, ref string content)
        {
            if (source is IInternalSmartContentSource)
            {
                try
                {
                    content = ((IInternalSmartContentSource)source).GeneratePlainTextHtml(sContent, site);
                }
                catch (Exception ex)
                {
                    Trace.WriteLine("Content Source failed to generate plain text html: " + ex);
                    Trace.Flush();
                    throw;
                }

            }
        }
コード例 #4
0
 public SmartUrlContentRetreivalAsyncOperation(
     ISynchronizeInvoke invokeTarget, SmartContentSource contentSource, string url, string title, ISmartContent newContent)
     : base(invokeTarget, contentSource, url, title)
 {
     _newContent = newContent;
 }
コード例 #5
0
            internal void DoPublishWork(IPublishingContext site, SmartContentSource source, ISmartContent sContent, ref string content)
            {
                if (source is IPublishTimeWorker)
                {
                    try
                    {
                        // For each piece of IPublishTimeWorker smart content we find we need to ask if it has
                        // work to do while publishing.  We pass null as the external context because that object
                        // is only for use when providing external code a chance to interact with the publish.
                        content = ((IPublishTimeWorker)source).DoPublishWork(_form, sContent, _blog.Id, site, null);

                    }
                    catch (WebException ex)
                    {
                        HttpRequestHelper.LogException(ex);
                        _exception = ex;
                        throw;
                    }
                    catch (Exception ex)
                    {
                        Trace.WriteLine("Content Source failed to do publish work: " + ex);
                        _exception = ex;
                        throw;
                    }

                }
            }
コード例 #6
0
        protected override void OnElementAttached()
        {
            SmartContent content = SmartContent;
            if (content == null)
                return;

            ContentSourceInfo contentSourceInfo = _contentSourceContext.FindContentSource(ContentSourceId);
            _contentSource = contentSourceInfo.Instance as SmartContentSource;

            if (_contentSource != null && _contentSource.ResizeCapabilities != ResizeCapabilities.None)
            {
                Resizable = true;
                PreserveAspectRatio = ResizeCapabilities.PreserveAspectRatio == (_contentSource.ResizeCapabilities & ResizeCapabilities.PreserveAspectRatio);
                _realtimeResizing = ResizeCapabilities.LiveResize == (_contentSource.ResizeCapabilities & ResizeCapabilities.LiveResize);
            }
            else
                Resizable = false;

            EditorContext.CommandKey += new KeyEventHandler(EditorContext_CommandKey);
            EditorContext.DocumentEvents.DoubleClick += new HtmlEventHandler(EditorContext_DoubleClick);
            EditorContext.SelectionChanged += new EventHandler(EditorContext_SelectionChanged);
            EditorContext.PostEventNotify += new MshtmlEditor.EditDesignerEventHandler(EditorContext_PostEventNotify);
            EditorContext.CommandManager.BeforeExecute += new CommandManagerExecuteEventHandler(CommandManager_BeforeExecute);
            EditorContext.CommandManager.AfterExecute += new CommandManagerExecuteEventHandler(CommandManager_AfterExecute);
            EditorContext.HtmlInserted += new EventHandler(EditorContext_HtmlInserted);

            base.OnElementAttached();

            foreach (IHTMLElement el in EditFields)
            {
                InlineEditField field = new InlineEditField(el, content, EditorContext, HTMLElement, this);

                if (!field.ContentEditable && EditorContext.EditMode)
                {
                    field.ContentEditable = true;
                }

                field.SetDefaultText();
            }
        }
コード例 #7
0
        public override void UpdateView(object htmlSelection, bool force)
        {
            if (htmlSelection == null) //true when the a non-smartcontent element is selected
            {
                //reset the selected smart content (fixes bug 492456)
                _selectedElement = null;
                _selectedSmartContentId = null;
                UnloadCurrentEditor();
                return;
            }

            Debug.Assert(htmlSelection is SmartContentSelection || (htmlSelection is IHtmlEditorSelection && InlineEditField.IsEditField(htmlSelection)));

            IHTMLElement selectedElement = null;
            SmartContentSelection smartContentSelection = htmlSelection as SmartContentSelection;
            if (smartContentSelection != null && smartContentSelection.ContentState == SmartContentState.Enabled)
            {
                selectedElement = smartContentSelection.HTMLElement;
            }
            else if (htmlSelection is IHtmlEditorSelection)
            {
                selectedElement = ContentSourceManager.GetContainingSmartContent(
                    ((IHtmlEditorSelection)(htmlSelection)).SelectedMarkupRange.ParentElement());
            }

            _currentSelection = htmlSelection;
            if (selectedElement != null)
            {
                //if the selected element id is still the same, then the sidebar is currently
                //in synch with the smart content.
                //Note: the element id will change each time an edit is made to the smart content
                if (!force && _selectedElement != null && _selectedSmartContentId != null && selectedElement.id == _selectedSmartContentId)
                    return;
                else
                {
                    _selectedElement = selectedElement;
                    _selectedSmartContentId = selectedElement.id;

                    if (_currentEditor != null)
                    {
                        UnloadCurrentEditor();
                    }
                }

                ContentSourceManager.ParseContainingElementId(_selectedElement.id, out _contentSourceId, out _contentItemId);

                SmartContentEditor editor = (SmartContentEditor)_contentSourceControls[_contentSourceId];
                ContentSourceInfo contentSource = _contentSourceContext.FindContentSource(_contentSourceId);
                if (contentSource != null && contentSource.Instance is SmartContentSource)
                {
                    _contentSource = (SmartContentSource)contentSource.Instance;

                    if (_editableSmartContent != null)
                        _editableSmartContent.Dispose();
                    _editableSmartContent = new EditableSmartContent(_contentSourceContext, _contentSource, _selectedElement);

                    if (editor == null)
                    {
                        editor = _contentSource.CreateEditor(this);

                        if (editor is IActiveSmartContentEditor)
                            ((IActiveSmartContentEditor)editor).ForceContentEdited += new EventHandler(ContentSourceSidebarControl_ForceContentEdited);

                        //apply the current scale the new control
                        if (editor != null)
                        {
                            editor.Scale(new SizeF(scale.Width, scale.Height));
                        }
                        _contentSourceControls[_contentSourceId] = editor;
                    }

                    if (editor != null)
                    {
                        editor.ContentEdited += new EventHandler(_editor_ContentEdited);
                        editor.SelectedContent = _editableSmartContent;

                        EnableableSmartContentEditor enableableSmartContentEditor = editor as EnableableSmartContentEditor;
                        if (enableableSmartContentEditor != null)
                            enableableSmartContentEditor.ContentEnabled = true;

                        if (editor != _currentEditor)
                        {
                            if (enableableSmartContentEditor != null)
                                Controls.Clear();
                            else
                            {
                                //load the new editor
                                editor.Dock = DockStyle.Fill;
                                editor.Width = Width - DockPadding.Left - DockPadding.Right;
                                this.Controls.Add(editor);
                            }

                            // set the title caption
                            // Text = String.Format( CultureInfo.CurrentCulture, Res.Get(StringId.PluginSidebarTitle), contentSource.InsertableContentSourceSidebarText ) ;
                        }

                    }
                }
                _currentEditor = editor;
            }
            else
                _currentEditor = null;
        }
コード例 #8
0
        private SmartContentEditor CreateSmartContentEditor(string contentSourceId)
        {
            Debug.Assert(!_contentSourceControls.Contains(contentSourceId));

            SmartContentEditor smartContentEditor = null;
            ContentSourceInfo contentSource = _contentSourceContext.FindContentSource(contentSourceId);
            if (contentSource != null && contentSource.Instance is SmartContentSource)
            {
                _contentSource = (SmartContentSource)contentSource.Instance;
                smartContentEditor = _contentSource.CreateEditor(this);
                _contentSourceControls[contentSourceId] = smartContentEditor;

                if (smartContentEditor is IActiveSmartContentEditor)
                    ((IActiveSmartContentEditor)smartContentEditor).ForceContentEdited += new EventHandler(ContentSourceSidebarControl_ForceContentEdited);

                //apply the current scale the new control
                if (smartContentEditor != null)
                {
                    smartContentEditor.Scale(new SizeF(scale.Width, scale.Height));
                }
            }
            else
            {
                Trace.Fail("Incorrectly calling GetSmartContentEditor for a source that is not a SmartContentSource.");
            }
            return smartContentEditor;
        }
コード例 #9
0
 private void GetStructuredPublishHtml(IPublishingContext site, SmartContentSource source, ISmartContent sContent, ref string content)
 {
     content = source.GeneratePublishHtml(sContent, site);
 }
コード例 #10
0
 private void GetStructuredEditorHtml(IPublishingContext site, SmartContentSource source, ISmartContent sContent, ref string content)
 {
     using (new SmartContentForceInvalidateNotify(sContent))
         content = source.GenerateEditorHtml(sContent, site);
 }