-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomCommandService.cs
41 lines (37 loc) · 1.4 KB
/
CustomCommandService.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
using DevExpress.Xpf.Core;
using DevExpress.Xpf.Spreadsheet;
using DevExpress.XtraSpreadsheet;
using DevExpress.XtraSpreadsheet.Commands;
using DevExpress.XtraSpreadsheet.Services;
using System;
using System.Windows;
namespace WpfSpreadsheet_CustomCommand
{
public class CustomService : SpreadsheetCommandFactoryServiceWrapper
{
public CustomService(ISpreadsheetCommandFactoryService service)
: base(service)
{
}
public SpreadsheetControl Control { get; set; }
public override SpreadsheetCommand CreateCommand(SpreadsheetCommandId id)
{
if (id == SpreadsheetCommandId.FormatClearContents || id == SpreadsheetCommandId.FormatClearContentsContextMenuItem)
return new CustomFormatClearContentsCommand(Control);
return base.CreateCommand(id);
}
}
public class CustomFormatClearContentsCommand : DevExpress.XtraSpreadsheet.Commands.FormatClearContentsCommand
{
public CustomFormatClearContentsCommand(ISpreadsheetControl control) :
base(control)
{
}
protected override void ExecuteCore()
{
MessageBoxResult result = DXMessageBox.Show("Do you want to clear the cell content?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning);
if (result == MessageBoxResult.Yes)
base.ExecuteCore();
}
}
}