Este artículo proviene de un motor de traducción automática. Mueva el puntero sobre las frases del artículo para ver el texto original. Más información.
Traducción
Original
Este tema aún no ha recibido ninguna valoración - Valorar este tema

TextPattern.IsReadOnlyAttribute (Campo)

identifica el atributo de IsReadOnly de un intervalo de texto.

Espacio de nombres:  System.Windows.Automation
Ensamblado:  UIAutomationClient (en UIAutomationClient.dll)
public static readonly AutomationTextAttribute IsReadOnlyAttribute

Este atributo representa el estado de sólo lectura del documento asociado con el intervalo de texto de la llamada.

NotaNota

Si un documento o un archivo es de sólo lectura, pero todavía puede editarlo y guardarlo como un archivo, el texto no se considera de solo lectura.

este identificador es utilizado por las aplicaciones de Cliente de automatización de la interfaz de usuario . S paraProveedor de automatización de la interfaz de usuariodebe utilizar el campo equivalente en TextPatternIdentifiers.

S paraCliente de automatización de la interfaz de usuarioobtiene el valor del atributo llamando a GetAttributeValue.

Los valores de este atributo son de Booleanescrito. el valor predeterminado es false.

El ejemplo siguiente se muestra cómo obtener un valor de atributo para un intervalo de texto en Bloc de notas de Microsoft.

NotaNota

Bloc de notas de Microsoft se utiliza como fines del proveedor de texto por ejemplo únicamente. Bloc de notas de Microsoft no se garantiza para admitir el valor de atributo que se está solicitando.


private void GetIsReadOnlyAttribute()
{
    // Start application.
    Process p = Process.Start("Notepad.exe", "text.txt");

    // target --> The root AutomationElement.
    AutomationElement target = AutomationElement.FromHandle(p.MainWindowHandle);

    // Specify the control type we're looking for, in this case 'Document'
    PropertyCondition cond = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document);

    AutomationElement textProvider = target.FindFirst(TreeScope.Descendants, cond);

    TextPattern textpatternPattern = textProvider.GetCurrentPattern(TextPattern.Pattern) as TextPattern;

    if (textpatternPattern == null)
    {
        Console.WriteLine("Root element does not contain a descendant that supports TextPattern.");
        return;
    }

    Object oAttribute = textpatternPattern.DocumentRange.GetAttributeValue(TextPattern.IsReadOnlyAttribute);
    if (oAttribute == TextPattern.MixedAttributeValue)
    {
        Console.WriteLine("Mixture of readonly and non-readonly.");
    }
    else
    {
        Console.WriteLine(oAttribute.ToString());
    }
}



Private Sub GetIsReadOnlyAttribute()
    ' Start application.
    Dim p As Process = Process.Start("Notepad.exe", "text.txt")

    ' target --> The root AutomationElement.
    Dim target As AutomationElement = AutomationElement.FromHandle(p.MainWindowHandle)

    ' Specify the control type we're looking for, in this case 'Document'
    Dim cond As PropertyCondition = New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document)

    Dim textProvider As AutomationElement = target.FindFirst(TreeScope.Descendants, cond)

    Dim textpatternPattern As TextPattern = CType(textProvider.GetCurrentPattern(TextPattern.Pattern), TextPattern)

    If (textpatternPattern Is Nothing) Then
        Console.WriteLine("Root element does not contain a descendant that supports TextPattern.")
        Return
    End If

    Dim oAttribute As Object = textpatternPattern.DocumentRange.GetAttributeValue(TextPattern.IsReadOnlyAttribute)
    If (oAttribute = TextPattern.MixedAttributeValue) Then
        Console.WriteLine("Mixture of readonly and non-readonly.")
    Else
        Console.WriteLine(oAttribute.ToString())
    End If
End Sub


.NET Framework

Compatible con: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Compatible con: 4, 3.5 SP1

Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (no se admite el rol Server Core), Windows Server 2008 R2 (se admite el rol Server Core con SP1 o versiones posteriores; no se admite Itanium)

.NET Framework no admite todas las versiones de todas las plataformas. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.
¿Te ha resultado útil?
(Caracteres restantes: 1500)

Adiciones de comunidad

AGREGAR
© 2013 Microsoft. Reservados todos los derechos.