Exemple #1
0
        private void richEditControl_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e)
        {
            if ((e.MenuType & RichEditMenuType.TableCell) != 0)
            {
                // Remove the "Paste" menu item:
                e.Menu.RemoveMenuItem(RichEditCommandId.PasteSelection);

                // Disable the "Hyperlink..." menu item:
                e.Menu.DisableMenuItem(RichEditCommandId.CreateHyperlink);

                // Create a RichEdit command, which inserts an inline picture into a document:
                IRichEditCommandFactoryService service = (IRichEditCommandFactoryService)richEditControl.GetService(typeof(IRichEditCommandFactoryService));
                RichEditCommand cmd = service.CreateCommand(RichEditCommandId.InsertPicture);

                //Create a menu item for the new command:
                RichEditMenuItemCommandWinAdapter menuItemCommandAdapter = new RichEditMenuItemCommandWinAdapter(cmd);
                RichEditMenuItem menuItem = (RichEditMenuItem)menuItemCommandAdapter.CreateMenuItem(DevExpress.Utils.Menu.DXMenuItemPriority.Normal);
                menuItem.BeginGroup = true;
                e.Menu.Items.Add(menuItem);

                // Insert a new item into the Richedit popup menu and handle its click event:
                RichEditMenuItem myItem = new RichEditMenuItem("Highlight Selection", new EventHandler(MyClickHandler));
                e.Menu.Items.Add(myItem);
            }
        }
        static void buttonCustomAction_ItemClick_Commands(object sender, ItemClickEventArgs e)
        {
            RichEditControl richEdit = e.Item.Tag as RichEditControl;

            richEdit.SelectAll();

            RichEditCommand capCommand = richEdit.CreateCommand(RichEditCommandId.CapitalizeEachWordTextCase);

            capCommand.ForceExecute(capCommand.CreateDefaultCommandUIState());

            RichEditCommand boldCommand = richEdit.CreateCommand(RichEditCommandId.ToggleFontBold);

            boldCommand.ForceExecute(boldCommand.CreateDefaultCommandUIState());

            RichEditCommand changeFontColorCommand = richEdit.CreateCommand(RichEditCommandId.ChangeFontBackColor);

            DevExpress.Utils.Commands.ICommandUIState state = changeFontColorCommand.CreateDefaultCommandUIState();
            state.EditValue = Color.Yellow;
            changeFontColorCommand.ForceExecute(state);

            RichEditCommand previewCommand = richEdit.CreateCommand(RichEditCommandId.PrintPreview);

            previewCommand.ForceExecute(previewCommand.CreateDefaultCommandUIState());

            richEdit.DeselectAll();
        }
        private void QuoteButton_Click(object sender, EventArgs e) //quoute
        {
            DocumentRange       range = MainRichTextBox.Document.Selection;
            CharacterProperties crp   = MainRichTextBox.Document.BeginUpdateCharacters(range);

            crp.FontName  = crp.FontName;
            crp.FontSize  = 12;
            crp.ForeColor = Color.Black;

            if (crp.Italic == false)
            {
                crp.Italic = true;
            }

            RichEditCommand paragraphAlignmentCenter = MainRichTextBox.CreateCommand(RichEditCommandId.ToggleParagraphAlignmentCenter);

            paragraphAlignmentCenter.ForceExecute(paragraphAlignmentCenter.CreateDefaultCommandUIState());

            MainRichTextBox.Document.EndUpdateCharacters(crp);
        }
        private void Justify_Click(object sender, EventArgs e) //allign justify
        {
            RichEditCommand paragraphAlignmentJustify = MainRichTextBox.CreateCommand(RichEditCommandId.ToggleParagraphAlignmentJustify);

            paragraphAlignmentJustify.ForceExecute(paragraphAlignmentJustify.CreateDefaultCommandUIState());
        }
        private void MiddleAlign_Click(object sender, EventArgs e) //middle allign
        {
            RichEditCommand paragraphAlignmentCenter = MainRichTextBox.CreateCommand(RichEditCommandId.ToggleParagraphAlignmentCenter);

            paragraphAlignmentCenter.ForceExecute(paragraphAlignmentCenter.CreateDefaultCommandUIState());
        }
        private void RightAlign_Click(object sender, EventArgs e) //right allign
        {
            RichEditCommand paragraphAlignmentRight = MainRichTextBox.CreateCommand(RichEditCommandId.ToggleParagraphAlignmentRight);

            paragraphAlignmentRight.ForceExecute(paragraphAlignmentRight.CreateDefaultCommandUIState());
        }
        private void button16_Click_1(object sender, EventArgs e)//left indendetation scaling
        {
            RichEditCommand decreaseIndent = MainRichTextBox.CreateCommand(RichEditCommandId.DecreaseIndent);

            decreaseIndent.ForceExecute(decreaseIndent.CreateDefaultCommandUIState());
        }
        private void button15_Click_1(object sender, EventArgs e)//right indendetation scaling
        {
            RichEditCommand increaseIndent = MainRichTextBox.CreateCommand(RichEditCommandId.IncreaseIndent);

            increaseIndent.ForceExecute(increaseIndent.CreateDefaultCommandUIState());
        }
        private void Number_Click(object sender, EventArgs e)//number list
        {
            RichEditCommand numberlist = MainRichTextBox.CreateCommand(RichEditCommandId.ToggleNumberingListItem);

            numberlist.ForceExecute(numberlist.CreateDefaultCommandUIState());
        }
        private void Bullet_Click(object sender, EventArgs e) // bulleting numbers
        {
            RichEditCommand bulletCommand = MainRichTextBox.CreateCommand(RichEditCommandId.ToggleBulletedListItem);

            bulletCommand.ForceExecute(bulletCommand.CreateDefaultCommandUIState());
        }
        private void button1_Click(object sender, EventArgs e)
        {
            RichEditCommand bulletedlist = MainRichTextBox.CreateCommand(RichEditCommandId.None);

            bulletedlist.ForceExecute(bulletedlist.CreateDefaultCommandUIState());
        }