public void SetServiceProvider(IServiceProviderRaw serviceProvider)
 {
     // Everytime we switch the service provider we need to clear out who
     // the editor thinks it's site is.  This will force it to ask for the
     // the service provider again.  If you don't do this, any editor that is reused for
     // multiple windows in Mail will contain a stale pointer to objects that were
     // quired through the service provider.  The most obvious being behaviors won't work
     // because it has cached behavior manager will not have access to the new editor resulting
     // in smart content not bring selected correctly or images not being resamples when resized.
     _serviceProvider = serviceProvider;
     oleObject.SetClientSite(null);
     oleObject.SetClientSite((IOleClientSite)this);
 }
        /// <summary>
        /// Construction. Some initialization is done here, the rest of the initialiation is
        /// deferred until the document readyState is "complete"
        /// </summary>
        public MshtmlEditor(IServiceProviderRaw serviceProvider, MshtmlOptions mshtmlOptions, bool protectFocus)
        {
            // initialize properties
            BackColor = SystemColors.Window;

            // initialize MSHTML
            InitializeMshtmlControl(serviceProvider, mshtmlOptions, protectFocus);

            _active = true;

            // watch for ReadyState == "complete" so we can finish initialization once
            // the document is loaded
            mshtmlControl.DocumentEvents.ReadyStateChanged += new EventHandler(ReadyStateChangedHandler);
        }
        /// <summary>
        /// Create the MSHTML control and add it to our client area
        /// </summary>
        private void InitializeMshtmlControl(IServiceProviderRaw serviceProvider, MshtmlOptions mshtmlOptions, bool protectFocus)
        {
            UpdateOptions(mshtmlOptions, true);

            // initialize mshtml control
            mshtmlControl = new MshtmlControl(serviceProvider, protectFocus);
            mshtmlControl.InstallDocHostUIHandler(this);
            mshtmlControl.SetDLControlFlags(mshtmlOptions.DLCTLOptions);
            mshtmlControl.Init();
            mshtmlControl.SetEditMode(true);

            // get a reference to the htmlDocument
            htmlDocument = mshtmlControl.HTMLDocument;

            /// Hook Mshtml document GotFocus so we can notify .NET when our control
            /// gets focus (allows Enter and Leave events to be fired correctly so
            /// that commands can be managed correctly)
            mshtmlControl.DocumentEvents.GotFocus += new EventHandler(DocumentEvents_GotFocus);

            // add the control to our client area
            mshtmlControl.Dock = DockStyle.Fill;
            Controls.Add(mshtmlControl);
        }
 public void SetServiceProvider(IServiceProviderRaw serviceProvider)
 {
     mshtmlControl.SetServiceProvider(serviceProvider);
 }
 public MshtmlControl(IServiceProviderRaw serviceProvider, bool protectFocus)
 {
     _serviceProvider = serviceProvider;
     ProtectFocus = protectFocus;
 }