TransformPattern.Resize(Double, Double) Metoda

Definicja

Zmienia rozmiar kontrolki.

public:
 void Resize(double width, double height);
public void Resize (double width, double height);
member this.Resize : double * double -> unit
Public Sub Resize (width As Double, height As Double)

Parametry

width
Double

Nowa szerokość okna w pikselach.

height
Double

Nowa wysokość okna w pikselach.

Wyjątki

Właściwość CanResize ma wartość false.

Przykłady

W poniższym przykładzie TransformPattern wzorzec kontrolki jest uzyskiwany z elementu AutomationElement , a następnie używany do zmiany rozmiaru AutomationElementelementu .

///--------------------------------------------------------------------
/// <summary>
/// Obtains a TransformPattern control pattern from 
/// an automation element.
/// </summary>
/// <param name="targetControl">
/// The automation element of interest.
/// </param>
/// <returns>
/// A TransformPattern object.
/// </returns>
///--------------------------------------------------------------------
private TransformPattern GetTransformPattern(
    AutomationElement targetControl)
{
    TransformPattern transformPattern = null;

    try
    {
        transformPattern =
            targetControl.GetCurrentPattern(TransformPattern.Pattern)
            as TransformPattern;
    }
    catch (InvalidOperationException)
    {
        // object doesn't support the TransformPattern control pattern
        return null;
    }

    return transformPattern;
}
'''--------------------------------------------------------------------
''' <summary>
''' Obtains a TransformPattern control pattern from 
''' an automation element.
''' </summary>
''' <param name="targetControl">
''' The automation element of interest.
''' </param>
''' <returns>
''' A TransformPattern object.
''' </returns>
'''--------------------------------------------------------------------
Private Function GetTransformPattern( _
ByVal targetControl As AutomationElement) As TransformPattern
    Dim transformPattern As TransformPattern = Nothing

    Try
        transformPattern = DirectCast( _
        targetControl.GetCurrentPattern(transformPattern.Pattern), _
        TransformPattern)
    Catch exc As InvalidOperationException
        ' object doesn't support the TransformPattern control pattern
        Return Nothing
    End Try

    Return transformPattern

End Function 'GetTransformPattern
///--------------------------------------------------------------------
/// <summary>
/// Calls the TransformPattern.Resize() method for an associated 
/// automation element.
/// </summary>
/// <param name="transformPattern">
/// The TransformPattern control pattern obtained from
/// an automation element.
/// </param>
/// <param name="width">
/// The requested width of the automation element.
/// </param>
/// <param name="height">
/// The requested height of the automation element.
/// </param>
///--------------------------------------------------------------------
private void ResizeElement(
    TransformPattern transformPattern, double width, double height)
{
    try
    {
        if (transformPattern.Current.CanResize)
        {
            transformPattern.Resize(width, height);
        }
    }
    catch (InvalidOperationException)
    {
        // object is not able to perform the requested action
        return;
    }
}
'''--------------------------------------------------------------------
''' <summary>
''' Calls the TransformPattern.Resize() method for an associated 
''' automation element.
''' </summary>
''' <param name="transformPattern">
''' The TransformPattern control pattern obtained from
''' an automation element.
''' </param>
''' <param name="width">
''' The requested width of the automation element.
''' </param>
''' <param name="height">
''' The requested height of the automation element.
''' </param>
'''--------------------------------------------------------------------
Private Sub ResizeElement( _
ByVal transformPattern As TransformPattern, _
ByVal width As Double, ByVal height As Double)
    Try
        If transformPattern.Current.CanResize Then
            transformPattern.Resize(width, height)
        End If
    Catch
        ' object is not able to perform the requested action
        Return
    End Try

End Sub

Uwagi

Po wywołaniu kontrolki obsługującej okienka podzielone ta metoda może mieć efekt uboczny zmiany rozmiaru innych ciągłych okienek.

Nie można przenosić, zmieniać rozmiaru ani obracać obiektu w taki sposób, że jego wynikowa lokalizacja ekranu byłaby całkowicie poza współrzędnymi kontenera i niedostępna dla klawiatury lub myszy. Na przykład gdy okno najwyższego poziomu zostanie przeniesione całkowicie poza ekran lub obiekt podrzędny zostanie przeniesiony poza granice okienka widoku kontenera. W takich przypadkach obiekt jest umieszczany tak blisko żądanych współrzędnych ekranu, jak to możliwe, ze współrzędnymi u góry lub lewej przesłoniętą, aby mieścić się w granicach kontenera.

Dotyczy