1
private bool Proc()
2
{
3
string selectedText;
4
string name = "成员变量";
5
EditPoint startPoint = ((TextSelection)_applicationObject.ActiveDocument.Selection).TopPoint.CreateEditPoint();
6
EditPoint endPoint = ((TextSelection)_applicationObject.ActiveDocument.Selection).BottomPoint.CreateEditPoint();
7
8
if (startPoint.EqualTo(endPoint)) return false;
9
if (!startPoint.AtStartOfLine) startPoint.StartOfLine();
10
11
_applicationObject.UndoContext.Open("Insert a region", true);
12
try
13
{
14
selectedText = startPoint.GetText(startPoint.LineLength);
15
startPoint.Insert(String.Concat("\r\n #region ", name, "\r\n\r\n"));
16
endPoint.Insert("\r\n\r\n #endregion");
17
}
18
catch (Exception ex)
19
{
20
Debug.WriteLine(ex.Message);
21
}
22
finally
23
{
24
_applicationObject.UndoContext.Close();
25
}
26
27
return true;
28
}

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
