/
CustomRichEditCommandFactoryService.cs
50 lines (44 loc) · 1.55 KB
/
CustomRichEditCommandFactoryService.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using DevExpress.XtraRichEdit;
using DevExpress.Xpf.RichEdit;
using DevExpress.XtraRichEdit.Services;
using DevExpress.XtraRichEdit.Commands;
using DevExpress.Utils;
namespace DXApplication36
{
#region #CustomRichEditCommandFactoryService
public class CustomRichEditCommandFactoryService : IRichEditCommandFactoryService
{
readonly IRichEditCommandFactoryService service;
readonly RichEditControl control;
public CustomRichEditCommandFactoryService(RichEditControl control,
IRichEditCommandFactoryService service) {
Guard.ArgumentNotNull(control, "control");
Guard.ArgumentNotNull(service, "service");
this.control = control;
this.service = service;
}
public RichEditCommand CreateCommand(RichEditCommandId id) {
if(id == RichEditCommandId.FileSave)
return new CustomSaveDocumentCommand(control);
return service.CreateCommand(id);
}
}
#endregion #CustomRichEditCommandFactoryService
#region #customsavedocumentcommand
public class CustomSaveDocumentCommand:SaveDocumentCommand{
public CustomSaveDocumentCommand(IRichEditControl control)
: base(control)
{
}
protected override void ExecuteCore()
{
base.ExecuteCore();
MessageBox.Show("Custom SaveDocument command was executed");
}
}
#endregion #customsavedocumentcommand
}