-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindow.xaml.cs
More file actions
52 lines (41 loc) · 2.14 KB
/
MainWindow.xaml.cs
File metadata and controls
52 lines (41 loc) · 2.14 KB
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
51
52
using System.Linq;
using DevExpress.Xpf.Core;
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
namespace DXRichEdit_TrackChanges
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : ThemedWindow
{
public MainWindow()
{
InitializeComponent();
richEditControl1.LoadDocument("DocumentWithRevisions.docx");
richEditControl1.AnnotationOptions.VisibleAuthors.Remove("Michael Suyama");
AcceptAndRejectRevisions();
richEditControl1.Document.SaveDocument("DocumentWithRevisions.docx", DocumentFormat.OpenXml);
}
private void AcceptAndRejectRevisions()
{
RevisionCollection documentRevisions = richEditControl1.Document.Revisions;
//Reject all revisions in the firts page's header:
SubDocument header = richEditControl1.Document.Sections[0].BeginUpdateHeader(HeaderFooterType.First);
documentRevisions.RejectAll(header);
richEditControl1.Document.Sections[0].EndUpdateHeader(header);
//Reject all revisions from the specific author on the first section:
var sectionRevisions = documentRevisions.Get(richEditControl1.Document.Sections[0].Range).Where(x => x.Author == "Janet Leverling");
foreach (Revision revision in sectionRevisions)
revision.Reject();
//Accept all format changes:
documentRevisions.AcceptAll(x => x.Type == RevisionType.CharacterPropertyChanged || x.Type == RevisionType.ParagraphPropertyChanged || x.Type == RevisionType.SectionPropertyChanged);
}
private void RichEditControl_TrackedMovesConflict(object sender, TrackedMovesConflictEventArgs e)
{
//Compare the length of the original and new location ranges
//Keep text from the location whose range is the smallest
e.ResolveMode = (e.OriginalLocationRange.Length <= e.NewLocationRange.Length) ? TrackedMovesConflictResolveMode.KeepOriginalLocationText : TrackedMovesConflictResolveMode.KeepNewLocationText;
}
}
}