public HtmlMarginEditor(CommandManager commandManager)
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

            marginCommand = (MarginCommand)commandManager.Get(CommandId.MarginsGroup);

            this.label3.Text = Res.Get(StringId.ImgSBMarginTop);
            this.label4.Text = Res.Get(StringId.ImgSBMarginRight);
            this.label5.Text = Res.Get(StringId.ImgSBMarginLeft);
            this.label6.Text = Res.Get(StringId.ImgSBMarginBottom);

            comboBoxMargins.Initialize();
            comboBoxMargins.SelectedIndexChanged += new EventHandler(comboBoxMargins_SelectedIndexChanged);
            comboBoxMargins.SelectedIndex = 0;
            panelCustomMargin.VisibleChanged += new EventHandler(panelCustomMargin_VisibleChanged);

            comboBoxMargins.AccessibleName = ControlHelper.ToAccessibleName(Res.Get(StringId.ImgSBMargins));

            marginCommand.MarginChanged += new EventHandler(marginCommand_MarginChanged);
        }
 private void InitializeAlignmentMarginChunkCommands()
 {
     _alignmentCommand = (AlignmentCommand)_editorContext.CommandManager.Get(CommandId.AlignmentGallery);
     _marginCommand = (MarginCommand)_editorContext.CommandManager.Get(CommandId.MarginsGroup);
 }
        // Shared group commands need to be here.
        protected virtual void InitializeCommands()
        {
            CommandManager.BeginUpdate();

            CommandManager.Add(new Command(CommandId.FontGroup)); // Has it's own icon.
            CommandManager.Add(new Command(CommandId.SemanticHtmlGroup));

            MarginCommand marginCommand = new MarginCommand(CommandManager);
            marginCommand.Enabled = false;
            CommandManager.Add(marginCommand);

            AlignmentCommand alignmentCommand = new AlignmentCommand(CommandManager);
            CommandManager.Add(alignmentCommand);

            CommandManager.Add(new Command(CommandId.TextEditingGroup));

            Command commandActivateContextualTab = new Command(CommandId.ActivateContextualTab);
            commandActivateContextualTab.Execute +=
                new EventHandler(
                   delegate (object sender, EventArgs args)
                   {
                       ContentEditor_BeforeInitialInsertion(this, EventArgs.Empty);
                       UpdateContextAvailability();
                       ContentEditor_AfterInitialInsertion(this, EventArgs.Empty);
                   });
            CommandManager.Add(commandActivateContextualTab);

            // Video contextual tab
            commandVideoContextTabGroup = new ContextAvailabilityCommand(CommandId.VideoContextTabGroup);
            CommandManager.Add(commandVideoContextTabGroup);
            commandFormatVideoTab = new ContextAvailabilityCommand(CommandId.FormatVideoTab);
            CommandManager.Add(commandFormatVideoTab);

            // Image contextual tab
            commandImageContextTabGroup = new ContextAvailabilityCommand(CommandId.ImageContextTabGroup);
            CommandManager.Add(commandImageContextTabGroup);
            commandFormatImageTab = new ContextAvailabilityCommand(CommandId.FormatImageTab);
            CommandManager.Add(commandFormatImageTab);

            // Map contextual tab
            commandMapContextTabGroup = new ContextAvailabilityCommand(CommandId.MapContextTabGroup);
            CommandManager.Add(commandMapContextTabGroup);
            commandFormatMapTab = new ContextAvailabilityCommand(CommandId.FormatMapTab);
            CommandManager.Add(commandFormatMapTab);
            CommandManager.Add(new Command(CommandId.FormatMapGroup));
            CommandManager.Add(new Command(CommandId.FormatMapPropertiesGroup));

            // Tag contextual tab
            commandTagContextTabGroup = new ContextAvailabilityCommand(CommandId.TagContextTabGroup);
            CommandManager.Add(commandTagContextTabGroup);
            commandFormatTagTab = new ContextAvailabilityCommand(CommandId.FormatTagTab);
            CommandManager.Add(commandFormatTagTab);
            CommandManager.Add(new Command(CommandId.FormatTagPropertiesGroup));
            CommandManager.Add(new Command(CommandId.FormatTagProvidersGroup));
            CommandManager.Add(new Command(CommandId.AddTagProvider));
            CommandManager.Add(new Command(CommandId.ManageTagProviders));
            CommandManager.Add(new Command(CommandId.EditTags));

            // Table contextual tab
            commandTableContextTabGroup = new ContextAvailabilityCommand(CommandId.TableContextTabGroup);
            CommandManager.Add(commandTableContextTabGroup);
            commandFormatTableTab = new ContextAvailabilityCommand(CommandId.FormatTableTab);
            CommandManager.Add(commandFormatTableTab);
            CommandManager.Add(new Command(CommandId.FormatTablePropertiesGroup));
            CommandManager.Add(new Command(CommandId.FormatTableInsertGroup));
            CommandManager.Add(new Command(CommandId.FormatTableMoveGroup));
            CommandManager.Add(new Command(CommandId.FormatTableEditingGroup));

            commandViewNormal = new Command(CommandId.ViewNormal);
            commandViewNormal.Execute += new EventHandler(commandViewNormal_Execute);
            CommandManager.Add(commandViewNormal);
            if (!GlobalEditorOptions.SupportsFeature(ContentEditorFeature.ViewNormalEditorShortcut))
                CommandManager.IgnoreShortcut(commandViewNormal.Shortcut);

            commandViewPlainText = new Command(CommandId.ViewPlainText);
            commandViewPlainText.Execute += new EventHandler(commandViewPlainText_Execute);
            commandViewPlainText.On = GlobalEditorOptions.SupportsFeature(ContentEditorFeature.PlainTextEditor);
            CommandManager.Add(commandViewPlainText);

            commandViewWebPreview = new Command(CommandId.ViewPreview);
            commandViewWebPreview.Execute += new EventHandler(commandViewWebPreview_Execute);
            commandViewWebPreview.On = GlobalEditorOptions.SupportsFeature(ContentEditorFeature.PreviewMode);
            CommandManager.Add(commandViewWebPreview);

            commandViewCode = new Command(CommandId.ViewCode);
            commandViewCode.Execute += new EventHandler(commandViewCode_Execute);
            commandViewCode.On = GlobalEditorOptions.SupportsFeature(ContentEditorFeature.SourceEditor);
            CommandManager.Add(commandViewCode);

            commandViewSidebar = new Command(CommandId.ViewSidebar);
            commandViewSidebar.BeforeShowInMenu += new EventHandler(commandViewSidebar_BeforeShowInMenu);
            commandViewSidebar.Execute += new EventHandler(commandViewSidebar_Execute);
            CommandManager.Add(commandViewSidebar);

            commandInsertPicture = CommandManager.Add(CommandId.InsertPictureFromFile, commandInsertPicture_Execute);

            _videoProvidersFeatureEnabled = MarketizationOptions.IsFeatureEnabled(MarketizationOptions.Feature.VideoProviders);
            commandInsertVideoFromFile = new Command(CommandId.InsertVideoFromFile);
            commandInsertVideoFromFile.Enabled = _videoProvidersFeatureEnabled;
            commandInsertVideoFromFile.Execute += new EventHandler(commandInsertVideoFromFile_Execute);
            CommandManager.Add(commandInsertVideoFromFile);

            commandInsertVideoFromWeb = new Command(CommandId.InsertVideoFromWeb);
            commandInsertVideoFromWeb.Enabled = _videoProvidersFeatureEnabled;
            commandInsertVideoFromWeb.Execute += new EventHandler(commandInsertVideoFromWeb_Execute);
            CommandManager.Add(commandInsertVideoFromWeb);

            bool tagProvidersFeatureEnabled = MarketizationOptions.IsFeatureEnabled(MarketizationOptions.Feature.TagProviders);
            CommandManager.Add(CommandId.InsertTags, commandInsertTags_Execute, tagProvidersFeatureEnabled);

            commandInsertEmoticon = new EmoticonsGalleryCommand(CommandId.InsertEmoticon, this);
            CommandManager.Add(commandInsertEmoticon, commandInsertEmoticon_Execute);

            commandInsertVideoFromService = new Command(CommandId.InsertVideoFromService);
            commandInsertVideoFromService.Enabled = _videoProvidersFeatureEnabled;
            commandInsertVideoFromService.Execute += new EventHandler(commandInsertVideoFromService_Execute);
            CommandManager.Add(commandInsertVideoFromService);

            _mapsFeatureEnabled = MarketizationOptions.IsFeatureEnabled(MarketizationOptions.Feature.Maps);
            commandInsertMap = new Command(CommandId.InsertMap);
            commandInsertMap.Enabled = _mapsFeatureEnabled;
            commandInsertMap.Execute += commandInsertMap_Execute;
            CommandManager.Add(commandInsertMap);

            _tagProvidersFeatureEnabled = MarketizationOptions.IsFeatureEnabled(MarketizationOptions.Feature.TagProviders);
            commandInsertTags = new Command(CommandId.InsertTags);
            commandInsertTags.Enabled = _tagProvidersFeatureEnabled;
            commandInsertTags.Execute += commandInsertTags_Execute;
            CommandManager.Add(commandInsertTags);

            commandInsertTable = new Command(CommandId.InsertTable);
            commandInsertTable.Execute += new EventHandler(commandInsertTable_Execute);
            commandInsertTable.CommandBarButtonContextMenuDefinition = new TableContextMenuDefinition();
            commandInsertTable.CommandBarButtonContextMenuDefinition.CommandBar = true;
            CommandManager.Add(commandInsertTable);

            commandInsertTable2 = new Command(CommandId.InsertTable2);
            commandInsertTable2.Execute += new EventHandler(commandInsertTable_Execute);
            CommandManager.Add(commandInsertTable2);

            commandAddPlugin = new Command(CommandId.AddPlugin);
            commandAddPlugin.Execute += new EventHandler(commandAddPlugin_Execute);
            CommandManager.Add(commandAddPlugin);

            commandInsertHorizontalLine = new OverridableCommand(CommandId.InsertHorizontalLine);
            commandInsertHorizontalLine.Execute += commandInsertHorizontalLine_Execute;
            CommandManager.Add(commandInsertHorizontalLine);

            commandInsertClearBreak = CommandManager.Add(CommandId.InsertClearBreak, commandInsertClearBreak_Execute);

            CommandManager.Add(new Command(CommandId.FontGroup));

#if SUPPORT_FILES
            commandInsertFile = new Command(CommandId.InsertFile);
            commandInsertFile.Execute += new EventHandler(commandInsertFile_Execute);
            CommandManager.Add(commandInsertFile);
#endif

            CommandManager.Add(new CommandRecentPost());
            CommandManager.Add(CommandId.WordCount, new EventHandler(WordCount_Execute));
            if (ApplicationDiagnostics.TestMode)
            {
                CommandManager.Add(CommandId.ShowVideoErrorMessage, new EventHandler(commandShowVideoErrorMessage_Execute));
                CommandManager.Add(CommandId.ShowImageUploadError, new EventHandler(commandShowImageUploadError_Execute));
            }

            // Debug functions command to Mail and Writer.
            if (ApplicationDiagnostics.TestMode)
            {
                CommandManager.Add(CommandId.ViewSource, new EventHandler(commandViewSource_Execute));
            }

            CommandManager.EndUpdate();

            CommandManager.CommandStateChanged += new EventHandler(CommandManager_CommandStateChanged);

            wordCountTimer = new Timer();
            wordCountTimer.Interval = 250;
            wordCountTimer.Tick += new EventHandler(wordCountUpdate);
            WordCountSettings.SettingsChanged += new EventHandler(wordCountUpdate);
        }
 /// <summary>
 /// Must be called by inheriting classes to avoid null references!
 /// </summary>
 /// <param name="commandManager"></param>
 protected void InitializeAlignmentMarginCommands(CommandManager commandManager)
 {
     _marginCommand = (MarginCommand)commandManager.Get(CommandId.MarginsGroup);
     _alignmentCommand = (AlignmentCommand)commandManager.Get(CommandId.AlignmentGallery);
 }