Exemplo n.º 1
0
        public void Initialize(string registrySettingsPath, IContentEditorLogger logger, IContentTarget contentTarget, ISettingsProvider settingsProvider)
        {
            try
            {
                GlobalEditorOptions.Init(contentTarget, settingsProvider);
                HtmlEditorControl.AllowCachedEditor();

                Assembly assembly = Assembly.GetExecutingAssembly();
                ApplicationEnvironment.Initialize(assembly, Path.GetDirectoryName(assembly.Location), registrySettingsPath, contentTarget.ProductName);
                ContentSourceManager.Initialize(false);

                Trace.Listeners.Clear();
                if (logger != null)
                {
                    _logger = new RedirectionLogger(logger);

                    Trace.Listeners.Add(_logger);
                }

#if DEBUG
                Trace.Listeners.Add(new DefaultTraceListener());
#endif
            }
            catch (Exception e)
            {
                Trace.Fail("Failed to initialize Shared Canvas: " + e);
                Trace.Flush();
                throw;
            }
        }
        public WordRangeDamager(HtmlEditorControl editorControl, MshtmlEditor mshtmlControl)
        {
            _editorControl = editorControl;
            _mshtmlEditor  = mshtmlControl;

            damageQueue = new DamageRegionQueue();
            Reset();
        }
        public HtmlEditorControlDamageServices(HtmlEditorControl editorControl, MshtmlEditor mshtmlControl, DamageCommitStrategy commitStrategy)
        {
            _editorControl   = editorControl;
            _mshtmlControl   = mshtmlControl;
            wordRangeDamager = new WordRangeDamager(editorControl, mshtmlControl);

            _commitStrategy = commitStrategy;
            _commitStrategy.CommitDamage += new EventHandler(damageCommitStrategy_CommitDamage);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes the IContentEditor.
        /// </summary>
        /// <param name="factory"></param>
        /// <param name="contentEditorSite"></param>
        /// <param name="internetSecurityManager"></param>
        /// <param name="wysiwygHTML"></param>
        /// <param name="previewHTML"></param>
        /// <param name="newEditingContext"></param>
        /// <param name="templateStrategy"></param>
        /// <param name="dlControlFlags">
        /// For Mail, these flags should always include DLCTL_DLIMAGES | DLCTL_VIDEOS | DLCTL_BGSOUNDS so that local
        /// images, videos and sounds are loaded. To block external content, it should also include
        /// DLCTL_PRAGMA_NO_CACHE | DLCTL_FORCEOFFLINE | DLCTL_NO_CLIENTPULL so that external images are not loaded
        /// and are displayed as a red X instead.
        /// </param>
        /// <param name="color"></param>
        private void ContentEditorProxyCore(ContentEditorFactory factory, IContentEditorSite contentEditorSite, IInternetSecurityManager internetSecurityManager, string wysiwygHTML, string previewHTML, IBlogPostEditingContext newEditingContext, BlogPostHtmlEditorControl.TemplateStrategy templateStrategy, int dlControlFlags, string color)
        {
            try
            {
                Debug.Assert(contentEditorSite is IUIFramework, "IContentEditorSite must also implement IUIFramework");
                Debug.Assert(contentEditorSite is IDropTarget, "IContentEditorSite must also implement IDropTarget");

                ApplyInstalledCulture();

                this.factory = factory;

                _wysiwygHTML       = wysiwygHTML;
                _previewHTML       = previewHTML;
                _contentEditorSite = contentEditorSite;

                IntPtr     p    = _contentEditorSite.GetWindowHandle();
                WINDOWINFO info = new WINDOWINFO();
                User32.GetWindowInfo(p, ref info);
                panel        = new Panel();
                panel.Top    = 0;
                panel.Left   = 0;
                panel.Width  = Math.Max(info.rcWindow.Width, 200);
                panel.Height = Math.Max(info.rcWindow.Height, 200);
                panel.CreateControl();
                User32.SetParent(panel.Handle, p);

                accountAdapter = new ContentEditorAccountAdapter();
                mainFrame      = new MainFrameWindowAdapter(p, panel, _contentEditorSite, accountAdapter.Id);
                context        = newEditingContext;
                contentEditor  = new ContentEditor(mainFrame, panel, mainFrame, internetSecurityManager, templateStrategy, dlControlFlags);

                // Prevents asserts
                contentEditor.DisableSpelling();

                contentEditor.OnEditorAccountChanged(accountAdapter);
                contentEditor.DocumentComplete += new EventHandler(blogPostHtmlEditor_DocumentComplete);
                contentEditor.GotFocus         += new EventHandler(contentEditor_GotFocus);
                contentEditor.LostFocus        += new EventHandler(contentEditor_LostFocus);
                contentEditor.Initialize(context, accountAdapter, wysiwygHTML, previewHTML, false);

                if (!string.IsNullOrEmpty(color))
                {
                    contentEditor.IndentColor = color;
                }

                this.factory.GlobalSpellingOptionsChanged += GlobalSpellingOptionsChangedHandler;
            }
            catch (Exception ex)
            {
                // Something went wrong, make sure we don't reuse a cached editor
                HtmlEditorControl.DisposeCachedEditor();
                Trace.Fail(ex.ToString());
                Trace.Flush();
                throw;
            }
        }
Exemplo n.º 5
0
 public void Shutdown()
 {
     HtmlEditorControl.DisposeCachedEditor();
     TempFileManager.Instance.Dispose();
     Trace.Listeners.Clear();
     if (_logger != null)
     {
         _logger.Dispose();
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Cosntructor.
        /// </summary>
        public MailSenderForm()
        {
            this.InitializeComponent();

            this.htmlEditorControl                = new HtmlEditorControl();
            this.htmlEditorControl.Dock           = DockStyle.Fill;
            this.htmlEditorControl.AutoWordWrap   = true;
            this.htmlEditorControl.AutoScroll     = true;
            this.htmlEditorControl.ToolbarVisible = true;
            this.htmlEditorControl.ToolbarDock    = DockStyle.Top;
            this.panelEditor.Controls.Add(htmlEditorControl);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Event handler for select all action.
 /// </summary>
 /// <param name="sender">The sender object.</param>
 /// <param name="e">The event arguments.</param>
 private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Control activeControl = this.ActiveControl;
     if (activeControl != null && activeControl is TextBox)
     {
         TextBox textBox = (TextBox)activeControl;
         textBox.SelectAll();
     }
     else if (activeControl != null && activeControl is HtmlEditorControl)
     {
         HtmlEditorControl textBox = (HtmlEditorControl)activeControl;
         textBox.TextSelectAll();
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// Event handler for cut action.
 /// </summary>
 /// <param name="sender">The sender object.</param>
 /// <param name="e">The event arguments.</param>
 private void toolStripButtonCut_Click(object sender, EventArgs e)
 {
     Control activeControl = this.ActiveControl;
     if (activeControl != null && activeControl is TextBox)
     {
         TextBox textBox = (TextBox)activeControl;
         textBox.Cut();
     }
     else if (activeControl != null && activeControl is HtmlEditorControl)
     {
         HtmlEditorControl textBox = (HtmlEditorControl)activeControl;
         textBox.TextCut();
     }
 }
        /// <summary>
        /// Link navigator used for navigating to links from within
        /// an editing session
        /// </summary>
        /// <param name="editorControl">presentation editor context</param>
        public EditorLinkNavigator(HtmlEditorControl editorControl, IMainFrameWindow editorFrame, IStatusBar statusBar, IMshtmlDocumentEvents events)
        {
            // save references
            _htmlEditorContext = editorControl as IHtmlEditorComponentContext;
            _htmlEditorControl = editorControl;
            _editorFrame       = editorFrame;
            _statusBar         = statusBar;
            _documentEvents    = events;

            // sign up for editor events
            _editorFrame.Deactivate                 += new EventHandler(_editorFrame_Deactivate);
            _htmlEditorContext.PreHandleEvent       += new HtmlEditDesignerEventHandler(presentationEditor_PreHandleEvent);
            _htmlEditorContext.TranslateAccelerator += new HtmlEditDesignerEventHandler(presentationEditor_TranslateAccelerator);
            _documentEvents.LostFocus               += new EventHandler(_documentEvents_LostFocus);
        }
Exemplo n.º 10
0
 public override bool PreProcessMessage(ref Message msg)
 {
     if (prevMsg.Msg == WM_KEYDOWN && prevMsg.WParam == new IntPtr(CTRL_WPARAM) && msg.Msg == WM_KEYDOWN && msg.WParam == new IntPtr(VKEY_WPARAM))
     {
         // Do not let this Control process Ctrl-V, we'll do it manually.
         HtmlEditorControl parentControl = this.Parent as HtmlEditorControl;
         if (parentControl != null)
         {
             parentControl.ExecuteCommandDocument("Paste");
         }
         return(true);
     }
     prevMsg = msg;
     return(base.PreProcessMessage(ref msg));
 }
Exemplo n.º 11
0
        private void _copyTextToHtml(bool direction_text2html, bool treat_as_html = false)
        {
            HtmlEditorControl html = EditHtml1._HtmlEditor;

            if (direction_text2html)
            {
                if (treat_as_html)
                {
                    html.InnerHtml = EditText1.Text;
                }
                else
                {
                    html.InnerText = EditText1.Text;
                }
            }
            else
            {
                EditText1.Text = html.InnerText;
            }
        }
Exemplo n.º 12
0
 public void UpdateInlineImageSize(Size newSize, ImageDecoratorInvocationSource invocationSource, HtmlEditorControl currentEditor)
 {
     ImagePropertiesInfo.InlineImageSize = newSize;
     ApplyImageDecorations(ImagePropertyType.InlineSize, invocationSource);
 }
Exemplo n.º 13
0
 public static void ApplyBlockStyle(HtmlEditorControl editor, _ELEMENT_TAG_ID styleTagId, MarkupRange selection, MarkupRange maximumBounds, MarkupRange postOpSelection)
 {
     new HtmlBlockFormatHelper(editor).ApplyBlockStyle(styleTagId, selection, maximumBounds, postOpSelection);
 }
Exemplo n.º 14
0
 public HtmlBlockFormatHelper(HtmlEditorControl editor)
 {
     _editor         = editor;
     _markupServices = (_editor as IHtmlEditorComponentContext).MarkupServices;
 }