TransformPattern.Move(Double, Double) Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Sposta il controllo.
public:
void Move(double x, double y);
public void Move(double x, double y);
member this.Move : double * double -> unit
Public Sub Move (x As Double, y As Double)
Parametri
- x
- Double
Coordinate dello schermo assolute del lato sinistro del controllo.
- y
- Double
Coordinate dello schermo assolute della parte superiore del controllo.
Eccezioni
La CanMove proprietà è false.
Esempio
Nell'esempio seguente viene ottenuto un TransformPattern pattern di controllo da un oggetto AutomationElement e successivamente usato per spostare l'oggetto AutomationElement.
///--------------------------------------------------------------------
/// <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.Move() method for an associated
/// automation element.
/// </summary>
/// <param name="transformPattern">
/// The TransformPattern control pattern obtained from
/// an automation element.
/// </param>
/// <param name="x">
/// The number of screen pixels to move the automation element
/// horizontally.
/// </param>
/// <param name="y">
/// The number of screen pixels to move the automation element
/// vertically.
/// </param>
///--------------------------------------------------------------------
private void MoveElement(
TransformPattern transformPattern, double x, double y)
{
try
{
if (transformPattern.Current.CanMove)
{
transformPattern.Move(x, y);
}
}
catch (InvalidOperationException)
{
// object is not able to perform the requested action
return;
}
}
'''--------------------------------------------------------------------
''' <summary>
''' Calls the TransformPattern.Move() method for an associated
''' automation element.
''' </summary>
''' <param name="transformPattern">
''' The TransformPattern control pattern obtained from
''' an automation element.
''' </param>
''' <param name="x">
''' The number of screen pixels to move the automation element
''' horizontally.
''' </param>
''' <param name="y">
''' The number of screen pixels to move the automation element
''' vertically.
''' </param>
'''--------------------------------------------------------------------
Private Sub MoveElement( _
ByVal transformPattern As TransformPattern, _
ByVal x As Double, ByVal y As Double)
Try
If transformPattern.Current.CanMove Then
transformPattern.Move(x, y)
End If
Catch exc As InvalidOperationException
' object is not able to perform the requested action
Return
End Try
End Sub
Commenti
Non è possibile spostare, ridimensionare o ruotare un oggetto in modo che la posizione dello schermo risultante sia completamente esterna alle coordinate del contenitore e non accessibile alla tastiera o al mouse. Ad esempio, quando una finestra di primo livello viene spostata completamente fuori schermo o un oggetto figlio viene spostato al di fuori dei limiti del riquadro di visualizzazione del contenitore. In questi casi l'oggetto viene posizionato il più vicino possibile alle coordinate dello schermo richieste con le coordinate superiore o sinistra sottoposte a override all'interno dei limiti del contenitore.