public static BlogPostHtmlEditor Create(IMainFrameWindow mainFrameWindow, Control editorContainer, IBlogPostEditingSite postEditingSite)
        {
            Panel panelBase = new Panel();

            panelBase.Dock = DockStyle.Fill;
            editorContainer.Controls.Add(panelBase);
            return(new BlogPostHtmlEditor(mainFrameWindow, panelBase, postEditingSite));
        }
Ejemplo n.º 2
0
        public ContentEditor(IMainFrameWindow mainFrameWindow, Control editorContainer, IBlogPostEditingSite postEditingSite, IInternetSecurityManager internetSecurityManager, BlogPostHtmlEditorControl.TemplateStrategy templateStrategy, int dlControlFlags)
        {
            // create a docked panel to host the editor
            Panel panel = new Panel();
            panel.Dock = DockStyle.Fill;

            if (!BidiHelper.IsRightToLeft)
                panel.DockPadding.Right = 0;
            else
                panel.DockPadding.Left = 0;

            editorContainer.Controls.Add(panel);
            panel.Resize += new EventHandler(panel_Resize);
            if (BidiHelper.IsRightToLeft)
                editorContainer.RightToLeft = RightToLeft.Yes;

            // save references
            _mainFrameWindow = mainFrameWindow;
            _editorContainer = panel;
            _postEditingSite = postEditingSite;

            _commandManager = new CommandManager();

            _userPreferencesMonitor = new UserPreferencesMonitor();

            // To be high-contrast-aware we need to respond to changes in the high contrast mode
            // by invalidating commands, forcing the ribbon to ask us for new high contrast images.
            _userPreferencesMonitor.AccessibilityUserPreferencesChanged +=
                new EventHandler(delegate (object sender, EventArgs args)
                                     {
                                         _commandManager.InvalidateAllImages();
                                     });

            _imageDecoratorsManager = new LazyLoader<ImageDecoratorsManager>(() => new ImageDecoratorsManager(components, CommandManager, GlobalEditorOptions.SupportsFeature(ContentEditorFeature.ImageBorderInherit)));
            _emoticonsManager = new EmoticonsManager(this, this);

            // initialize commands
            InitializeCommands();

            // initialize normal editor
            InitializeNormalEditor(postEditingSite, internetSecurityManager, templateStrategy, dlControlFlags);

            // initialize source editor
            if (GlobalEditorOptions.SupportsFeature(ContentEditorFeature.SourceEditor))
                InitializeSourceEditor();

            InitializeViewCommands();

            // initialize custom content
            InitializeContentSources();

            // bring main editor panel to front (this must be here for the sidebar to work!!!!)
            panel.BringToFront();
        }
        /// <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);
        }
        /// <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);
        }
        //ToDo: OLW Spell Checker
        //public BlogPostHtmlEditorControl(IMainFrameWindow mainFrameWindow, IStatusBar statusBar, MshtmlOptions options, IBlogPostImageEditingContext imageEditingContext, IBlogPostSidebarContext sidebarContext, IContentSourceSidebarContext sourceContext, SmartContentResizedListener resizedListener, IBlogPostSpellCheckingContext spellingContext, IImageReferenceFixer referenceFixer, IInternetSecurityManager internetSecurityManager, CommandManager commandManager, TemplateStrategy strategy, IEditingMode editingModeContext)  : base(mainFrameWindow, statusBar, options, internetSecurityManager, commandManager)
        public BlogPostHtmlEditorControl(IMainFrameWindow mainFrameWindow, IStatusBar statusBar, MshtmlOptions options, IBlogPostImageEditingContext imageEditingContext, IBlogPostSidebarContext sidebarContext, IContentSourceSidebarContext sourceContext, SmartContentResizedListener resizedListener, IImageReferenceFixer referenceFixer, IInternetSecurityManager internetSecurityManager, CommandManager commandManager, TemplateStrategy strategy, IEditingMode editingModeContext)
            : base(mainFrameWindow, statusBar, options, internetSecurityManager, commandManager)
        {
            _strategy = strategy;
            _imageEditingContext = imageEditingContext;
            _sidebarContext = sidebarContext;
            _sourceContext = sourceContext;
            _resizedListener = resizedListener;
            //ToDo: OLW Spell Checker
            //_spellingContext = spellingContext;

            //_spellingManager = new SpellingManager(CommandManager);
            _keyBoardHandler = new PostEditorKeyboardHandler(this, imageEditingContext, editingModeContext);
            _referenceFixer = referenceFixer;

            InitializeTableEditingManager();

            InitializeElementBehaviors();

            SelectionChanged += BlogPostHtmlEditorControl_SelectionChanged;
            KeyPress += new HtmlEventHandler(BlogPostHtmlEditorControl_KeyPress);
        }
        private BlogPostHtmlEditor(IMainFrameWindow mainFrameWindow, Panel panelEditorContainer, IBlogPostEditingSite postEditingSite)
            : base(mainFrameWindow, panelEditorContainer, postEditingSite, new BlogPostHtmlEditorControl.BlogPostHtmlEditorSecurityManager(), new BlogPostTemplateStrategy(), MshtmlOptions.DEFAULT_DLCTL)
        {
            _editorContainer = panelEditorContainer;
            //InitializeCommandBar(commandBarDefinition);

            //_editorCommandBar.VerticalLineX = (BidiHelper.IsRightToLeft ? _htmlEditorSidebarHost.Right - 1 : _htmlEditorSidebarHost.Left);
            //_editorCommandBar.DrawVerticalLine = _htmlEditorSidebarHost.Visible;

            panelEditorContainer.SizeChanged += new EventHandler(editorContainer_SizeChanged);

            _htmlEditorSidebarHost.VisibleChanged += new EventHandler(_htmlEditorSidebarHost_VisibleChanged);

            CreateTabs();

            InitializePropertyEditors();

            ApplySpellingSettings(null, EventArgs.Empty);
            SpellingSettings.SpellingSettingsChanged += ApplySpellingSettings;

            EditorLoaded    += new EventHandler(BlogPostHtmlEditor_EditorLoaded);
            FixCommandEvent += new FixCommendsDelegate(BlogPostHtmlEditor_FixCommandEvent);
        }
Ejemplo n.º 7
0
        private BlogPostHtmlEditor(IMainFrameWindow mainFrameWindow, Panel panelEditorContainer, IBlogPostEditingSite postEditingSite)
            : base(mainFrameWindow, panelEditorContainer, postEditingSite, new BlogPostHtmlEditorControl.BlogPostHtmlEditorSecurityManager(), new BlogPostTemplateStrategy(), MshtmlOptions.DEFAULT_DLCTL)
        {
            _editorContainer = panelEditorContainer;
            //InitializeCommandBar(commandBarDefinition);

            //_editorCommandBar.VerticalLineX = (BidiHelper.IsRightToLeft ? _htmlEditorSidebarHost.Right - 1 : _htmlEditorSidebarHost.Left);
            //_editorCommandBar.DrawVerticalLine = _htmlEditorSidebarHost.Visible;

            panelEditorContainer.SizeChanged += new EventHandler(editorContainer_SizeChanged);

            _htmlEditorSidebarHost.VisibleChanged += new EventHandler(_htmlEditorSidebarHost_VisibleChanged);

            CreateTabs();

            InitializePropertyEditors();

            ApplySpellingSettings(null, EventArgs.Empty);
            SpellingSettings.SpellingSettingsChanged += ApplySpellingSettings;

            EditorLoaded += new EventHandler(BlogPostHtmlEditor_EditorLoaded);
            FixCommandEvent += new FixCommendsDelegate(BlogPostHtmlEditor_FixCommandEvent);
        }
Ejemplo n.º 8
0
        public HtmlEditorControl(IMainFrameWindow mainFrameWindow, IStatusBar statusBar, MshtmlOptions options, ISpellingChecker spellingChecker, IInternetSecurityManager internetSecurityManager, CommandManager commandManager)
        {
            _commandManager = commandManager;

            // save reference to main frame window
            _mainFrameWindow = mainFrameWindow;
            _statusBar = statusBar;

            _spellingChecker = spellingChecker;

            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            //initialize the data format handlers for this control
            DataFormatHandlerFactory = new HtmlEditorMarshallingHandler(this);
            MarshalImagesSupported = true;
            MarshalFilesSupported = true;
            MarshalUrlSupported = true;
            MarshalHtmlSupported = true;
            MarshalTextSupported = true;

            // The version host service provider tells MSHTML what feature versions are available (e.g. VML 1.0).
            VersionHostServiceProvider = new VersionHostServiceProvider(new DisableVmlVersionHost());

            // initialize the html editor
            if (_editorCache == null)
            {
                _internetSecurityManager = new InternetSecurityManagerShim(internetSecurityManager);
                // If mainFrameWindow == null, then we are pre-caching mshtml and don't want it to steal focus
                _mshtmlEditor = new MshtmlEditor(this, options, (mainFrameWindow == null));
            }
            else
            {
                _mshtmlEditor = _editorCache.Editor;
                _internetSecurityManager = _editorCache.SecurityManager;
                _internetSecurityManager.SecurityManager = internetSecurityManager;

                _editorCache = null;
                _mshtmlEditor.Active = true;
                _mshtmlEditor.MshtmlControl.ProtectFocus = false;
                _mshtmlEditor.ClearContextMenuHandlers();
                _mshtmlEditor.SetServiceProvider(this);
                _mshtmlEditor.UpdateOptions(options, true);
            }

            _mshtmlOptions = options;
            this.DefaultBlockElement = _mshtmlOptions.UseDivForCarriageReturn
                                           ? (DefaultBlockElement)new DivDefaultBlockElement()
                                           : new ParagraphDefaultBlockElement();

            PostEditorEvent += new MshtmlEditor.EditDesignerEventHandler(HtmlEditorControl_PostEditorEvent);
            HandleClear += new HtmlEditorSelectionOperationEventHandler(TryMoveIntoNextTable);

            // Hook the editor into the stream of the security manager so we
            // can allow our own objects (smart content, image resizing) to load in the editor
            _internetSecurityManager.HandleProcessUrlAction = HandleProcessUrlAction;

            //  Automation uses this to find the editor to automate it
            _mshtmlEditor.Name = "BorderControl";

            // subscribe to key events
            _mshtmlEditor.DocumentComplete += new EventHandler(_mshtmlEditor_DocumentComplete);
            _mshtmlEditor.DocumentEvents.GotFocus += htmlEditor_GotFocus;
            _mshtmlEditor.DocumentEvents.LostFocus += htmlEditor_LostFocus;
            _mshtmlEditor.DocumentEvents.KeyDown += new HtmlEventHandler(DocumentEvents_KeyDown);
            _mshtmlEditor.DocumentEvents.KeyUp += new HtmlEventHandler(DocumentEvents_KeyUp);
            _mshtmlEditor.DocumentEvents.KeyPress += new HtmlEventHandler(DocumentEvents_KeyPress);
            _mshtmlEditor.DocumentEvents.MouseDown += new HtmlEventHandler(DocumentEvents_MouseDown);
            _mshtmlEditor.DocumentEvents.MouseUp += new HtmlEventHandler(DocumentEvents_MouseUp);
            _mshtmlEditor.DocumentEvents.SelectionChanged += new EventHandler(DocumentEvents_SelectionChanged);
            _mshtmlEditor.DisplayChanged += new EventHandler(_mshtmlEditor_DisplayChanged);
            _mshtmlEditor.DocumentEvents.Click += new HtmlEventHandler(DocumentEvents_Click);
            _mshtmlEditor.CommandKey += new KeyEventHandler(_mshtmlEditor_CommandKey);
            _mshtmlEditor.DropTargetHandler = new MshtmlEditor.DropTargetUIHandler(_mshtmlEditor_GetDropTarget);
            _mshtmlEditor.BeforeShowContextMenu += new EventHandler(_mshtmlEditor_BeforeShowContextMenu);
            _mshtmlEditor.MshtmlControl.DLControlFlagsChanged += new EventHandler(_mshtmlControl_DLControlFlagsChanged);
            _mshtmlEditor.TranslateAccelerator += new HtmlEditDesignerEventHandler(_mshtmlEditor_TranslateAccelerator);

            InitDamageServices();

            // notify subclasses that the editor has been created
            OnEditorCreated();
        }
        private void Init(IMainFrameWindow mainFrameWindow, IBlogPostEditingContext editingContext)
        {
            // save reference to the frame window and workspace border manager
            _mainFrameWindow = mainFrameWindow;

            // This call is required by the Windows.Forms Form Designer.
            Font = Res.DefaultFont;
            InitializeComponent();

            // initialize UI
            InitializeUI();

            // Initialize the editing manager
            InitializeEditingManager();

            // initialize our commands
            InitializeCommands();

            //subscribe to global events
            BlogSettings.BlogSettingsDeleted += new BlogSettings.BlogSettingsListener(HandleBlogDeleted);

            // edit the post
            _editingManager.EditPost(editingContext, false);

            InitializeRibbon();
        }
Ejemplo n.º 10
0
 public PostEditorMainControl(IMainFrameWindow mainFrameWindow, IBlogPostEditingContext editingContext)
 {
     Init(mainFrameWindow, editingContext);
 }
Ejemplo n.º 11
0
        public static BlogPostHtmlEditor Create(IMainFrameWindow mainFrameWindow, Control editorContainer, IBlogPostEditingSite postEditingSite)
        {
            Panel panelBase = new Panel();
            panelBase.Dock = DockStyle.Fill;
            editorContainer.Controls.Add(panelBase);
            return new BlogPostHtmlEditor(mainFrameWindow, panelBase, postEditingSite);

        }