顺手给vs2008写了个Region this插件,设置个快捷键后,还真爽!
 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        }
posted on 2007-10-13 20:01  xiaowy  阅读(275)  评论(1编辑  收藏  举报