本文整理汇总了VB.NET中System.Windows.Automation.Provider.ITransformProvider.Resize方法的典型用法代码示例。如果您正苦于以下问题:VB.NET ITransformProvider.Resize方法的具体用法?VB.NET ITransformProvider.Resize怎么用?VB.NET ITransformProvider.Resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。
在下文中一共展示了ITransformProvider.Resize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Resize
''' <summary>
''' Resizes the provider to the specified height and width.
''' </summary>
''' <param name="height">The specified height.</param>
''' <param name="width">The specified width.</param>
Private Sub Resize(ByVal width As Double, ByVal height As Double) Implements ITransformProvider.Resize
If Not(CType(Me, ITransformProvider)).CanResize Then
Throw New InvalidOperationException("Operation cannot be performed.")
End If
If width <= 0 Or height <= 0 Then
Throw New InvalidOperationException("Operation cannot be performed.")
End If
Dim widthInt As Integer = CInt(width)
Dim heightInt As Integer = CInt(height)
' Resize should never be allowed to place a control outside the
' bounds of its container; the control should always be accessible
' using the keyboard or mouse.
' Use the bounds of the parent window to limit the placement
' of the custom control.
Dim MaxSize As New Size(Me.customControl.formWidth - 20, Me.customControl.formHeight - 20)
Dim MinSize As New Size(10, 10)
If widthInt > MaxSize.Width Then
widthInt = MaxSize.Width
End If
If heightInt > MaxSize.Height Then
heightInt = MaxSize.Height
End If
If widthInt < MinSize.Width Then
widthInt = MinSize.Width
End If
If heightInt < MinSize.Height Then
heightInt = MinSize.Height
End If
' Invoke control method on separate thread to avoid clashing with UI.
' Use anonymous method for simplicity.
Me.customControl.Invoke(New MethodInvoker(Sub() Me.customControl.Size = New Size(widthInt, heightInt)))
End Sub