All docs
V21.2
21.2
21.1
20.2
20.1
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

IRichEditAndReviewingPaneCommandFactoryService Interface

Defines a service used to create RichEdit with Reviewing Pane commands.

Namespace: DevExpress.XtraRichEdit.Services

Assembly: DevExpress.RichEdit.v21.2.Core.dll

Declaration

[ComVisible(true)]
public interface IRichEditAndReviewingPaneCommandFactoryService :
    IRichEditCommandFactoryService

Remarks

Use this service instead of IRichEditCommandFactoryService to replace RichEditControl’s built-in commands when the Review Pane is displayed.

Example

The code sample below replaces the IRichEditCommandFactoryService service with the IRichEditAndReviewingPaneCommandFactoryService implementation to use a custom Save As command:

public partial class Form1 : RibbonForm
{
  public Form1()
  {
      InitializeComponent();

      // Replace service with a custom implementation:
      var myCommandFactory = new CustomRichEditCommandFactoryService(richEditControl1, richEditControl1.GetService<IRichEditCommandFactoryService>() as IRichEditAndReviewingPaneCommandFactoryService);
      richEditControl1.ReplaceService<IRichEditCommandFactoryService>(myCommandFactory);
  }
}

public class CustomRichEditCommandFactoryService : IRichEditAndReviewingPaneCommandFactoryService
{
  readonly IRichEditAndReviewingPaneCommandFactoryService service;
  readonly IRichEditControl control;

  public CustomRichEditCommandFactoryService(IRichEditControl control, IRichEditAndReviewingPaneCommandFactoryService service)
  {
      DevExpress.Utils.Guard.ArgumentNotNull(control, "control");
      DevExpress.Utils.Guard.ArgumentNotNull(service, "service");
      this.control = control;
      this.service = service;
  }

  // Override service methods to execute custom commands:
  public RichEditCommand CreateCommand(RichEditCommandId id, IRichEditControl control)
  {
      if (id == RichEditCommandId.FileSaveAs)
      {
          return new CustomSaveDocumentAsCommand(control);
      }
      if (id == RichEditCommandId.FileSave)
      {
          return new CustomSaveDocumentCommand(control);
      }
      return service.CreateCommand(id, control);
  }

  public RichEditCommand CreateCommand(RichEditCommandId id)
  {
      if (id == RichEditCommandId.FileSaveAs)
      {
          return new CustomSaveDocumentAsCommand(control);
      }
      if (id == RichEditCommandId.FileSave)
      {
          return new CustomSaveDocumentCommand(control);
      }
      return service.CreateCommand(id);
  }
}

// Create a custom Save command:
public class CustomSaveDocumentCommand : SaveDocumentCommand
{
    public CustomSaveDocumentCommand(IRichEditControl richEdit) : base(richEdit) { }

    protected override void ExecuteCore()
    {
        base.ExecuteCore();
        if (!DocumentServer.Modified)
        {
            MessageBox.Show("Document is saved successfully");
        }
    }
}

// Create a custom Save As command:
public class CustomSaveDocumentAsCommand : SaveDocumentAsCommand
{
    public CustomSaveDocumentAsCommand(IRichEditControl richEdit) : base(richEdit) { }

    protected override void ExecuteCore()
    {
        DocumentServer.Modified = true;
        base.ExecuteCore();
        if (!DocumentServer.Modified)
        {
            MessageBox.Show("Document is saved successfully");
        }
    }
}
See Also