-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpreadsheetSpellChecker.cs
43 lines (39 loc) · 1.64 KB
/
SpreadsheetSpellChecker.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
using DevExpress.Xpf.Core;
using DevExpress.Xpf.SpellChecker;
using DevExpress.Xpf.Spreadsheet;
using DevExpress.Xpf.Spreadsheet.Internal;
using DevExpress.XtraSpellChecker;
namespace SpreadsheetSpellchecking_WPF {
public class SpreadsheetSpellChecker : DXSpellCheckerBase<SpreadsheetControl> {
SpreadsheetControl Spreadsheet { get { return AssociatedObject; } }
protected override void OnAttached() {
base.OnAttached();
SpellingSettings.RegisterTextControl(typeof(XpfCellInplaceEditor));
SubscribeToEvents();
}
protected override void OnDetaching() {
UnsubscribeFromEvents();
SpellingSettings.UnregisterTextControl(typeof(XpfCellInplaceEditor));
base.OnDetaching();
}
void SubscribeToEvents() {
Spreadsheet.CellEditorOpened += OnSpreadsheet_CellEditorOpened;
SpellChecker.CheckCompleteFormShowing += OnChecker_CheckCompleteFormShowing;
}
void UnsubscribeFromEvents() {
Spreadsheet.CellEditorOpened -= OnSpreadsheet_CellEditorOpened;
SpellChecker.CheckCompleteFormShowing -= OnChecker_CheckCompleteFormShowing;
}
void OnSpreadsheet_CellEditorOpened(object sender, CellEditorOpenedEventArgs e) {
if (!e.IsCustom)
{
e.Editor.SetValue(ThemeManager.ThemeNameProperty, ApplicationThemeHelper.ApplicationThemeName);
SpellChecker.Check(e.Editor);
}
}
void OnChecker_CheckCompleteFormShowing(object sender, FormShowingEventArgs e)
{
e.Handled = true;
}
}
}