Share via


UndoContext.IsOpen 속성

실행 취소 작업이 현재 적용되는지 또는 솔루션이 열려 있는지 여부를 가져옵니다.

네임스페이스:  EnvDTE
어셈블리:  EnvDTE(EnvDTE.dll)

구문

‘선언
ReadOnly Property IsOpen As Boolean
bool IsOpen { get; }
property bool IsOpen {
    bool get ();
}
abstract IsOpen : bool with get
function get IsOpen () : boolean

속성 값

형식: Boolean
실행 취소 작업이 적용되거나 솔루션이 열려 있으면 true를 나타내고 그렇지 않으면 false를 나타내는 부울 값입니다.

설명

실행 취소 작업은 UndoContext 개체가 열려 있는 경우 적용됩니다.

솔루션이 열려 있더라도 아직 이 솔루션을 저장하지 않았을 수 있으므로 솔루션 파일(.sln)이 없을 수 있습니다.

예제

Sub IsOpenExample(ByVal dte As DTE2)

    ' Create a new text file.
    dte.ItemOperations.NewFile()

    Dim doc As TextDocument = _
        CType(dte.ActiveDocument.Object("TextDocument"), TextDocument)
    Dim done As Boolean = False

    Do While Not done
        If dte.UndoContext.IsOpen = False Then
            Try
                dte.UndoContext.Open("Insert 10 Lines")

                ' Insert 10 lines of text into the new document.
                Dim point As EditPoint = doc.StartPoint.CreateEditPoint
                Dim i As Integer

                For i = 1 To 10
                    point.Insert("This is a test." & vbCrLf)
                Next

                done = True
            Catch
            Finally
                If done Then dte.UndoContext.Close()
            End Try
        End If
    Loop

End Sub
public void IsOpenExample(DTE2 dte)
{
    // Create a new text file.
    dte.ItemOperations.NewFile(@"General\Text File", "", 
        Constants.vsViewKindPrimary);

    TextDocument doc = 
        (TextDocument)dte.ActiveDocument.Object("TextDocument");
    bool done = false;

    while (!done)
    {
        if (!dte.UndoContext.IsOpen)
        {
            try
            {
                dte.UndoContext.Open("Insert 10 Lines", false);

                // Insert 10 lines of text into the new document.
                EditPoint point = doc.StartPoint.CreateEditPoint();

                for (int i = 0; i < 10; ++i)
                    point.Insert("This is a test.\n");

                done = true;
            }
            catch
            {
            }
            finally
            {
                if (done) dte.UndoContext.Close();
            }
        }
    }
}

.NET Framework 보안

참고 항목

참조

UndoContext 인터페이스

EnvDTE 네임스페이스

기타 리소스

방법: 자동화 개체 모델 코드의 예제 컴파일 및 실행