Exemplo n.º 1
0
        private void EditorTextChangedHandler(object sender, EventArgs e)
        {
            C1RibbonEditorXhtml ed = Editor as C1RibbonEditorXhtml;

            if (ed != null && ed.Mode == EditorMode.Source && !_isFixing)
            {
                _validateDocument.Enabled = true;
            }
        }
Exemplo n.º 2
0
        private void UpdateEditorModeButtons()
        {
            C1RibbonEditorXhtml ed = Editor as C1RibbonEditorXhtml;

            _modeDesign.Visible  = ed != null;
            _modeSource.Visible  = ed != null;
            _modePreview.Visible = ed != null;
            if (ed != null)
            {
                _modeDesign.Pressed          = ed.Mode == EditorMode.Design;
                _modeSource.Pressed          = ed.Mode == EditorMode.Source;
                _modePreview.Pressed         = ed.Mode == EditorMode.Preview;
                Groups["Validation"].Visible = ed.Mode == EditorMode.Source;
            }
        }
Exemplo n.º 3
0
        private void SetEditorMode(EditorMode mode)
        {
            C1RibbonEditorXhtml ed = Editor as C1RibbonEditorXhtml;

            ed.Mode                   = mode;
            _fixErrors.Enabled        = false;
            _validateDocument.Enabled = false;
            UpdateEditorModeButtons();
            if (ed.Mode == mode)
            {
                UpdateRibbonState(mode);
            }
            if (ed.Mode != mode && ed.Mode == EditorMode.Source)
            {
                _fixErrors.Enabled        = true;
                _validateDocument.Enabled = false;
            }
        }
Exemplo n.º 4
0
 // ** object model
 public DialogResult ShowDialog(C1RibbonEditorXhtml editor)
 {
     _editor = editor;
     return(ShowDialog());
 }
Exemplo n.º 5
0
        //---------------------------------------------------------------------------
        #region ** handle commands

        internal override void HandleItemEvent(RibbonEventArgs e)
        {
            C1RibbonEditorXhtml ed   = Editor;
            HtmlList            list = null;
            RibbonItem          item = (RibbonItem)e.Item;

            if (e.EventType == RibbonEventType.Click)
            {
                switch (item.ID)
                {
                // find/replace
                case "Find":
                    ed.Find();
                    break;

                case "Replace":
                    ed.FindAndReplace();
                    break;

                // clibpboard
                case "Cut":
                    ed.Cut();
                    break;

                case "Copy":
                    ed.Copy();
                    break;

                case "Paste":
                    ed.Paste(false);
                    break;

                case "PasteText":
                    ed.Paste(true);
                    break;

                case "PasteSpecial":
                    ed.Paste(true);
                    break;

                // font
                case "Bold":
                    ed.SelectionFontBold = ((RibbonToggleButton)item).Pressed;
                    break;

                case "Italic":
                    ed.SelectionFontItalic = ((RibbonToggleButton)item).Pressed;
                    break;

                case "Underline":
                    ed.SelectionFontUnderline = ((RibbonToggleButton)item).Pressed;
                    break;

                case "Strikethrough":
                    ed.SelectionFontStrikethrough = ((RibbonToggleButton)item).Pressed;
                    break;

                case "IncreaseFontSize":
                    ed.SelectionFontBig = ((RibbonToggleButton)item).Pressed;
                    break;

                case "DecreaseFontSize":
                    ed.SelectionFontSmall = ((RibbonToggleButton)item).Pressed;
                    break;

                case "Subscript":
                    Editor.SelectionSubscript = ((RibbonToggleButton)item).Pressed;
                    UpdateUI();
                    break;

                case "Superscript":
                    Editor.SelectionSuperscript = ((RibbonToggleButton)item).Pressed;
                    UpdateUI();
                    break;

                //color
                case "FontColor":
                    Editor.SelectionColor = ((RibbonColorPicker)item).Color;
                    break;

                case "HighlightColor":
                    Editor.SelectionBackColor = ((RibbonColorPicker)item).Color;
                    break;

                case "BackgroundColor":
                    Editor.SelectionParagraphColor = ((RibbonColorPicker)item).Color;
                    break;

                // paragraph
                case "AlignLeft":
                    ed.SelectionAlignment = TextAlignment.Left;
                    break;

                case "Center":
                    ed.SelectionAlignment = TextAlignment.Center;
                    break;

                case "AlignRight":
                    ed.SelectionAlignment = TextAlignment.Right;
                    break;

                case "Justify":
                    ed.SelectionAlignment = TextAlignment.Justify;
                    break;

                case "Bullets":
                    list      = ed.Editor.Selection.List;
                    list.Type = ((RibbonToggleButton)item).Pressed ? HtmlList.ListType.Bulleted : HtmlList.ListType.None;
                    break;

                case "Numbering":
                case "MultiLevel":
                    list      = ed.Editor.Selection.List;
                    list.Type = ((RibbonToggleButton)item).Pressed ? HtmlList.ListType.Numbered : HtmlList.ListType.None;
                    break;

                case "DecreaseIndent":
                    if (ed.IsSelectionInsideList())
                    {
                        list = ed.Editor.Selection.List;
                        list.Execute(HtmlList.Action.DecreaseLevel);
                    }
                    else
                    {
                        ed.DecreaseIndent();
                    }
                    break;

                case "IncreaseIndent":
                    if (ed.IsSelectionInsideList())
                    {
                        list = ed.Editor.Selection.List;
                        list.Execute(HtmlList.Action.IncreaseLevel);
                    }
                    else
                    {
                        ed.IncreaseIndent();
                    }
                    break;

                // clear formatting
                case "ClearFormatting":
                    ed.ClearFontFormatting();
                    ed.SelectionColor          = System.Drawing.Color.Empty;
                    ed.SelectionBackColor      = System.Drawing.Color.Empty;
                    ed.SelectionParagraphColor = System.Drawing.Color.Empty;
                    UpdateUI();
                    break;

                case "SelectAll":
                    ed.Select(0, int.MaxValue);
                    UpdateUI();
                    break;

                // character casing
                case "LowerCase":
                    ed.SelectionChangeCase(CharCasing.LowerCase);
                    break;

                case "UpperCase":
                    ed.SelectionChangeCase(CharCasing.UpperCase);
                    break;

                case "CapitalizeCase":
                    ed.SelectionChangeCase(CharCasing.CapitalizeWords);
                    break;

                default:
                    if (item.Parent.Equals(GetItemByID("LineSpacing")))
                    {
                        float  spacing;
                        string text = ((RibbonButton)item).Text;
                        text = text.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.CurrencyDecimalSeparator);
                        if (float.TryParse(text, out spacing))
                        {
                            ed.SelectionLineSpacing = spacing;
                        }
                    }
                    else if (item.Parent.Equals(GetItemByID("FontColor")))
                    {
                        ed.SelectionColor = ((RibbonColorPicker)item.Parent).Color;
                    }
                    else if (item.Parent.Equals(GetItemByID("HighlightColor")))
                    {
                        ed.SelectionBackColor = ((RibbonColorPicker)item.Parent).Color;
                    }
                    else if (item.Parent.Equals(GetItemByID("BackgroundColor")))
                    {
                        ed.SelectionParagraphColor = ((RibbonColorPicker)item.Parent).Color;
                    }
                    break;
                }
            }
            else if (e.EventType == RibbonEventType.ChangeCommitted)
            {
                switch (item.ID)
                {
                // font
                case "FontFace":
                    ed.SelectionFontName = (((RibbonComboBox)item).Text);
                    break;

                case "FontSize":
                    ed.SelectionFontSize = (((RibbonComboBox)item).Text);
                    break;
                }
            }
        }