UndoContext.IsAborted 属性
获取指示 UndoContext 对象操作是否由 SetAborted 方法终止的值。
命名空间: EnvDTE
程序集: EnvDTE(在 EnvDTE.dll 中)
语法
声明
ReadOnly Property IsAborted As Boolean
Get
bool IsAborted { get; }
property bool IsAborted {
bool get ();
}
abstract IsAborted : bool
function get IsAborted () : boolean
属性值
类型:System.Boolean
一个布尔值,如果操作中止,则为 true,否则为 false。
备注
如果 UndoContext 对象关闭前被 SetAborted 禁用,则当关闭 UndoContext 对象时将放弃对参与的文档所做的一切更改。
示例
Sub IsAbortedExample()
' Before running, select text in an open document.
Dim txtSel As TextSelection
Dim strTS As String, strAnswer As String, bIsOpen As Boolean
txtSel = DTE.ActiveDocument.Selection
strTS = txtSel.Text
' Check to see if UndoContext object is already open.
If DTE.UndoContext.IsOpen = True Then
bIsOpen = True
Else
' Open the UndoContext object to track changes.
DTE.UndoContext.Open("RemoveNewLines", False)
End If
MsgBox("Current IsAborted value: " & DTE.UndoContext.IsAborted)
' Perform search for newline characters and remove them.
If strTS <> "" Then
txtSel.Delete()
strTS = Replace(strTS, vbNewLine, "", Compare:=vbTextCompare)
txtSel.Insert(strTS)
End If
' Check to see if you want to discard changes.
strAnswer = MsgBox("Do you want to discard all changes made?", vbYesNo & vbQuestion)
If strAnswer = True Then
DTE.UndoContext.SetAborted()
MsgBox("Current IsAborted value: " & DTE.UndoContext.IsAborted)
End If
' If UndoContext was already open, don't close it.
If bIsOpen = True Then
' Close the UndoContext object to commit the changes.
DTE.UndoContext.Close()
End If
End Sub
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。